简体   繁体   中英

ElementNotInteractableException error identifying a Select element using Selenium

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.

Here is my DOM 在此处输入图像描述

As per the HTML, the 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM