-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdropdown.java
More file actions
30 lines (22 loc) · 1004 Bytes
/
dropdown.java
File metadata and controls
30 lines (22 loc) · 1004 Bytes
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
package selenium;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class dropdown {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "D:\\software\\chromedriver_win32 (2)\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://en-gb.facebook.com/");
driver.findElement(By.xpath("//*[@data-testid='open-registration-form-button']")).click();
Thread.sleep(3000);
//1st way - industry use mostly
List<WebElement> birthMonth = driver.findElements(By.xpath("//select[@id='month']/option"));
System.out.println("total dropdown values are:"+ birthMonth.size());
birthMonth.get(9).click();//september
System.out.println(birthMonth.get(1).isEnabled());
}
}