-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiSelect.java
More file actions
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
package com.qpiders;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.interactions.ClickAndHoldAction;
import org.openqa.selenium.remote.server.handler.html5.Utils;
import org.openqa.selenium.support.ui.Select;
public class MultiSelect {
/**
* @param args
*/
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("file:///home/raman/Desktop/Selenium/sample.html");
WebElement listBox = driver.findElement(By.id("mtr"));
Select select = new Select(listBox);
select.getOptions().get(0).sendKeys(Keys.CONTROL);
List<WebElement> allOptions = select.getOptions();
ArrayList<WebElement> arr= new ArrayList<WebElement>();
for(int i=0;i<allOptions.size();i++)
{
WebElement text= allOptions.get(i);
arr.add(text);
}
//clicking on the elements
for(WebElement e: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();}*/
}