-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment175.java
More file actions
39 lines (23 loc) · 832 Bytes
/
Assignment175.java
File metadata and controls
39 lines (23 loc) · 832 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
31
32
33
34
35
36
37
38
39
package BasicsSelenium;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
//WAP to Print all options of dropdown & count all options in dropdown?
public class Assignment175 {
public static void main(String[] args) {
ChromeDriver driver = new ChromeDriver();
driver.get("https://www.amazon.in/");
driver.manage().window().maximize();
WebElement drop = driver.findElement(By.xpath("//select[@id='searchDropdownBox']"));
Select s1 = new Select(drop);
List<WebElement> opt = s1.getOptions();
int count = opt.size();
System.out.println(count);
for (int i = 0; i < count; i++) {
WebElement alldrop = opt.get(i);
System.out.println(alldrop.getText());
}
}
}