-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDropdown.java
33 lines (22 loc) · 877 Bytes
/
Dropdown.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
package selenium;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
import java.util.concurrent.TimeUnit;
public class Dropdown {
public static void main(String[] args)throws InterruptedException {
System.setProperty("webdriver.chrome.driver","D:\\ChromeDriver\\chromedriver_win32\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
String baseUrl = "http://demo.guru99.com/test/newtours/register.php";
driver.get(baseUrl);
Select x = new Select(driver.findElement(By.name("country")));
x.selectByIndex(0);
System.out.println("DropBox index 0 selected");
Thread.sleep(4000);
x.selectByIndex(1);
System.out.println("DropBox index 1 selected");
x.deselectByIndex(1);
// driver.close();
}
}