I learn Selenium in Java and I'm struggling with little problem. I'm working on handling dropdowns and to resolve my probelm I have to use Select class. I wrote a selector:
@FindBy(css="#speed")
WebElement selectSpeed;
Then I wrote a method:
public SelectMenuPage selectRandomSpeed(){
getWaitForTheElement().untilElementIsPresentCss("#speed");
//webDriverWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(locator)));
Select select = new Select(selectSpeed);
select.selectByIndex(0);
return this;
}
The problem is that when I use Select class the code simply does not work and I receive:
org.openqa.selenium.ElementNotInteractableException: element not interactable:
Element is not currently visible and may not be manipulated
It works very well when, instead of using Select, I just put the selectors of all the wanted elements and just simply interact with them. Unfortunately, I have to use Select class.
As per the HTML, the html-select tag is having the style
attribute set as display: none; .
Unless the element is visible within the HTML DOM Select()
may not work properly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.