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

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

    If you application uses jQuery, you may do the clicks using Javascript. I created this simple helper for clicking elements that WebDriver refuses to find:

    public static void jqClick(String selector, JavascriptExecutor driver) {
        driver.executeScript("$('" + selector + "').click()");
    }
    

    As the "driver", you can use, for instance a org.openqa.selenium.firefox.FirefoxDriver.

    This was the only solution that worked for me.

提交回复
热议问题