-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSample8.java
46 lines (38 loc) · 1.49 KB
/
Sample8.java
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
package selenium.sample;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import static org.junit.Assert.assertEquals;
public class Sample8 {
WebDriver driver;
// method which is being run before each test
@Before
public void startingTests() throws Exception {
// from Sample 1:
String libWithDriversLocation = System.getProperty("user.dir") + "\\lib\\";
System.setProperty("webdriver.chrome.driver", libWithDriversLocation + "chromedriver.exe");
// declaration above:
driver = new ChromeDriver();
//open page:
driver.get("https://kristinek.github.io/site/examples/styles");
}
// method which is being run after each test
@After
public void endingTests() throws Exception {
driver.quit();
}
@Test
public void styleChecks() throws Exception {
WebElement h1 = 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"));
WebElement div_h1 = driver.findElement(By.xpath("//div[h1]"));
assertEquals("rgba(241, 241, 241, 1)", div_h1.getCssValue("background-color"));
}
}