org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with

前端 未结 7 1640
终归单人心
终归单人心 2020-12-30 13:33

I am trying to execute below Selenium Web driver script, But I am getting org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may n

7条回答
  •  一生所求
    2020-12-30 14:19

    For some browsers it happens that once mouse hover action is performed, but the menu list disappear quickly before Selenium identify the next sub menu item. In that case it is better to use perform() action on the main menu to hold the menu list till the time Selenium identify the sub menu item and click on it.

    Here

    WebElement xWL = driver.findElement(By.xpath("x path text"));
    
    Actions xAct = new Actions(driver);
    

    Instead of this:

    xAct.moveToElement(xWL).build().perform();
    

    Below code will resolve the "element not visible" issue

    xAct.moveToElement(xWL);
    xAct.click();
    xAct.perform();
    

提交回复
热议问题