- Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathSample8.java
More file actions
Latest commit
48 lines (39 loc) · 1.59 KB
/
Copy pathSample8.java
File metadata and controls
48 lines (39 loc) · 1.59 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
packageselenium.sample;
importorg.junit.After;
importorg.junit.Before;
importorg.junit.Test;
importorg.openqa.selenium.By;
importorg.openqa.selenium.WebDriver;
importorg.openqa.selenium.WebElement;
importorg.openqa.selenium.chrome.ChromeDriver;
importjava.io.File;
importstaticorg.junit.Assert.assertEquals;
publicclassSample8 {
WebDriverdriver;
// method which is being run before each test
@Before
publicvoidstartingTests() throwsException {
// from Sample 1:
StringlibWithDriversLocation = System.getProperty("user.dir") + File.separator + "lib" + File.separator;
System.setProperty("webdriver.chrome.driver", libWithDriversLocation + "chromedriver" + newselenium.ChangeToFileExtension().extension());
// declaration above:
driver = newChromeDriver();
//open page:
driver.get("https://kristinek.github.io/site/examples/styles");
}
// method which is being run after each test
@After
publicvoidendingTests() throwsException {
driver.close();
}
@Test
publicvoidstyleChecks() throwsException {
WebElementh1 = driver.findElement(By.xpath("//h1"));
assertEquals("block", h1.getCssValue("display"));
assertEquals("rgba(0, 0, 0, 1)", h1.getCssValue("color"));
assertEquals("64px", h1.getCssValue("font-size"));
assertEquals("rgba(0, 0, 0, 0)", h1.getCssValue("background-color"));
WebElementdiv_h1 = driver.findElement(By.xpath("//div[h1]"));
assertEquals("rgba(241, 241, 241, 1)", div_h1.getCssValue("background-color"));
}
}