C# - Element Not Interactable error



  • I am unable to select a value from dropdown for span type I've got the error

    Element Not Interactable Exception

    in Selenium .

    I am running Selenium in C#.



  • Element Not Interactable may be cause by two reasons:

    1 - The element is hidden from the view, although exist in the DOM:

    Dropdown's option are hidden when the dropdown is closed. A usual pattern you have to follow to deal with such options is:

    1.1 - Open the dropdown

    driver.findElement(BY_OBJECT_FOR_THE_DROPDOWN).click();
    

    1.2 - Wait for the visibility of the option

    new WebDriverWait(driver, 10).until(
    ExpectedConditions.visibilityOfElementLocated(BY_OBJECT_FOR_A_PARTICULAR_OPTION));
    

    1.3 - Click on the option

    driver.findElement(BY_OBJECT_FOR_A_PARTICULAR_OPTION).click();
    

    2 - The option WebElement was visible at search (findElement) time, but some action made it hidden

    Let's say you have made the steps 1.1 and 1.2 and run the following:

    WebElement option = driver.findElement(BY_OBJECT_FOR_A_PARTICULAR_OPTION); // Option is visible and ok to use
    driver.findElement(BY_OBJECT_FOR_THE_DROPDOWN).click(); // Dropdown closing hides the option
    option.click(); // This option is no longer iteractable
    

    In this case, you would need to run 1.1 and 1.2 again, to get a fresh WebElement attached to the option DOM node.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2