How I can avoid “Element is not currently visible and so may not be interacted with ” Selenium Webdriver

前端 未结 11 1125
死守一世寂寞
死守一世寂寞 2020-12-16 14:02

Am using selenium webdriver 2.210 + JAVA for testing.I have a sample code for selecting all mails in gmail.But the code throws an \"Element is not currently visible and so m

11条回答
  •  时光取名叫无心
    2020-12-16 14:57

    JavascriptExecutor executor = (JavascriptExecutor)driver;
    executor.executeScript("document.getElementById('id').setAttribute('visibility', 'true');");
    
    driver.findElement(By.id("id")).click();
    

    by changing the visibility of the element you can perform your action. you can either click with selenium or with JavascriptExecutor

提交回复
热议问题