0
votes

When I try to select a drop down with Style display: none;

option 1:

WebElement sysDropDown = driver.findElement(By.id("ctl00_ContentPlaceHolder1_ddlFeedStatus")); 

Select sDropdown = new Select(sysDropDown); 
sDropdown.selectByVisibleText("01 - Quarantined");

The above code renders error:

element not interactable: Element is not currently visible and may not be manipulated

Option 2:

WebElement hiddenWebElement =driver.findElement(By.xpath("//select[@name='ctl00$ContentPlaceHolder1$ddlFeedStatus']"));

((JavascriptExecutor)driver).executeScript("arguments[0].click()",hiddenWebElement);

Option2 recognizes the drop down but unable to select an item from the drop down.

Any help would be appreciated.

Tried few options i see in the site but didtn't help much

2

2 Answers

0
votes

You could try altering the style attribute using Javascript, as such:

hiddenWebElement = driver.findElement(
    By.xpath("//select[@name='ctl00$ContentPlaceHolder1$ddlFeedStatus']")); 

((JavascriptExecutor)driver).executeScript(
    "arguments[0].style.display = 'block';", hiddenWebElement);

After that, you can try a Javascript click or regular click.

0
votes

Could you right click -> Inspect and see if it is really a dropdown? If drop down is visible and still getting this error, it might not an html dropdown. It may look like one but can only confirm if you inspect or look at code.

If element is an html drop down, use the following code to see if it works:

    WebElement sysDropDown = driver.findElement(By.id("ctl00_ContentPlaceHolder1_ddlFeedStatus")); 
    Coordinates coordinate = ((Locatable) sysDropDown).getCoordinates();
    coordinate.onPage();
    coordinate.inViewPort();

    Select sDropdown = new Select(sysDropDown); 
    sDropdown.selectByVisibleText("01 - Quarantined");