- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiSelect.java
More file actions
Latest commit
61 lines (48 loc) · 1.55 KB
/
Copy pathMultiSelect.java
File metadata and controls
61 lines (48 loc) · 1.55 KB
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
55
56
57
58
59
60
packagecom.qpiders;
importjava.util.ArrayList;
importjava.util.List;
importjava.util.concurrent.TimeUnit;
importorg.openqa.selenium.By;
importorg.openqa.selenium.Keys;
importorg.openqa.selenium.WebDriver;
importorg.openqa.selenium.WebElement;
importorg.openqa.selenium.firefox.FirefoxDriver;
importorg.openqa.selenium.interactions.Actions;
importorg.openqa.selenium.interactions.ClickAndHoldAction;
importorg.openqa.selenium.remote.server.handler.html5.Utils;
importorg.openqa.selenium.support.ui.Select;
publicclassMultiSelect {
/**
* @param args
*/
publicstaticvoidmain(String[] args) {
WebDriverdriver = newFirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("file:///home/raman/Desktop/Selenium/sample.html");
WebElementlistBox = driver.findElement(By.id("mtr"));
Selectselect = newSelect(listBox);
select.getOptions().get(0).sendKeys(Keys.CONTROL);
List<WebElement> allOptions = select.getOptions();
ArrayList<WebElement> arr= newArrayList<WebElement>();
for(inti=0;i<allOptions.size();i++)
{
WebElementtext= allOptions.get(i);
arr.add(text);
}
//clicking on the elements
for(WebElemente:arr)
{
e.click();
}
}
// for(int i=0;i<allOptions.size();i++)
// {
// allOptions.get(0).sendKeys(Keys.CONTROL);
// }
// Utils
/*
for(int i=0;i<allOptions.size();i++){
Actions builder = new Actions(driver);
builder.keyDown(Keys.CONTROL).click(select.getOptions().get(i)).keyUp(Keys.CONTROL);
builder.build().perform();}*/
}