- Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathSample10.java
More file actions
Latest commit
72 lines (61 loc) · 2.37 KB
/
Copy pathSample10.java
File metadata and controls
72 lines (61 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
packageselenium.sample;
importorg.junit.After;
importorg.junit.Before;
importorg.junit.Test;
importorg.openqa.selenium.WebDriver;
importorg.openqa.selenium.chrome.ChromeDriver;
importorg.openqa.selenium.support.PageFactory;
importselenium.pages.AgeSamplePage;
importselenium.pages.AgeSubmittedSamplePage;
importjava.io.File;
importjava.util.concurrent.TimeUnit;
publicclassSample10 {
staticWebDriverdriver;
staticAgeSamplePageagePage;
staticAgeSubmittedSamplePageageSubmittedPage;
@Before
publicvoidopenPage() throwsInterruptedException {
StringlibWithDriversLocation = System.getProperty("user.dir") + File.separator + "lib" + File.separator;
System.setProperty("webdriver.chrome.driver", libWithDriversLocation + "chromedriver" + newselenium.ChangeToFileExtension().extension());
driver = newChromeDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("https://kristinek.github.io/site/examples/age");
agePage = PageFactory.initElements(driver, AgeSamplePage.class);
ageSubmittedPage = PageFactory.initElements(driver, AgeSubmittedSamplePage.class);
}
@After
publicvoidcloseBrowser() {
driver.close();
}
@Test
publicvoidcheckCleanPage() throwsException {
agePage.checkThatFormIsClean();
}
@Test
publicvoidcheckErrorMessageOnEmptyAge() throwsException {
agePage.clickSubmit();
agePage.checkErrorMessage("You haven't entered anything in age field");
}
@Test
publicvoidcheckErrorMessageOnEmptyName() throwsException {
agePage.enterAge(3);
agePage.clickSubmit();
agePage.checkErrorMessage("You haven't entered anything in name field");
}
@Test
publicvoidcheckSuccessfulMessageForKid() throwsException {
agePage.enterNameAgeAndClickSubmit("Ann", 5);
ageSubmittedPage.checkMessageText("Hello, Ann, you are a kid");
}
@Test
publicvoidcheckSuccessfulMessageForAdult() throwsException {
agePage.enterNameAgeAndClickSubmit("Tom", 55);
ageSubmittedPage.checkMessageText("Hello, Tom, you are an adult");
}
@Test
publicvoidcheckBackButton() throwsException {
agePage.enterNameAgeAndClickSubmit("Tom", 55);
ageSubmittedPage.clickBackButton();
agePage.checkThatFormIsClean();
}
}