How to select value from dropdown and double click on same selected item in selenium webdriver.?

1.1k Views Asked by At

I am trying to select any value from drop down and double click on that selected item. Basic scenario is there is one text field and when i enter something in that text field and click on submit button one drop down appears containing different values. When i double click on any of the value from drop down the same value will be written and then i will proceed to for further task.

1

There are 1 best solutions below

0
On
Actions doubleClickAction = new Actions(driver); 
WebElement element = null;
element=driver.findElement(By.id("abs"));
List<WebElement> options1 = element.findElements(By.tagName("option"));
boolean isPresent = false;
for(WebElement option : options1){
    if(option.getText().equals(valueTobeSelected)){
        element.click();
        doubleClickAction.moveToElement(option).doubleClick().build().perform();
        isPresent = true;
        break;
    }
}