-
Notifications
You must be signed in to change notification settings - Fork 0
/
Checkbox.java
54 lines (37 loc) · 1.48 KB
/
Checkbox.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
47
48
49
50
51
52
53
54
package selenium;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class Checkbox {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","D:\\ChromeDriver\\chromedriver_win32\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
String baseUrl = "http://demo.guru99.com/test/radio.html";
driver.get(baseUrl);
WebElement option1 = driver.findElement(By.xpath("//*[@id=\"vfb-6-0\"]"));
option1.click();
System.out.println("Checbox1 Clicked");
if (option1.isSelected()) {
System.out.println("Checkbox1 is Toggled On");
}
option1.click();
if (!option1.isSelected()) {
System.out.println("Checkbox1 is Toggled off");
}
WebElement option2 = driver.findElement(By.xpath("//*[@id=\"vfb-6-1\"]"));
option2.click();
if (option2.isSelected()) {
System.out.println("Checkbox2 is Toggled On");
}
option2.click();
if (!option2.isSelected()) {
System.out.println("Checkbox2 is Toggled off");
}
WebElement option3 = driver.findElement(By.cssSelector("input[id = \"vfb-6-2\"]"));
option3.click();
if (option3.isSelected()) {
System.out.println("Checkbox2 is Toggled On");
}
}
}