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

前端 未结 11 1132
死守一世寂寞
死守一世寂寞 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:59

    I'm not sure, but every watir-webdriver element has the - (Object) wait_until_present(timeout = 30) method.

    if this step is optional, you should check for visibility:

    element = driver.findElement(By.xpath("//div[@class = 'T-Jo-auh']"));
    
    if (element.isDisplayed()) {
      element.click();
    }
    

    Please note, I'm not a java guru, and the code above was not tested. Give it a try.

提交回复
热议问题