Selenium click sometimes causes page to load and sometimes doesn't

Clicking on a button in my web page sometimes causes the entire page to load, and sometimes only part of it to load. How can I call waitForPageToLoad without the page loading, and to be able to run additional commands after all elements are present, or what other command can I use, that will wait for the page to be loaded and enable me to run additional commands on the page. (Using selenium 2.)


Clicking on a button in my web page sometimes causes the entire page to load, and sometimes only part of it to load.

I assume this is by design, and not the problem.

If you are testing, then you should know which behavior you are expecting. If you are expecting a full page load, then use clickAndWait . If you are expecting a partial load, then use click followed by waitForCondition .


You can use the wait() command to wait a specified amount of time, and continue with your actions afterward.

synchronized (driver) {
        try {
            driver.wait(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

It may be better to use clickAndWait or waitForCondition , but this is an alternative for just waiting in general.


等待要继续的元素,而不是等待页面加载

链接地址: http://www.djcxy.com/p/44862.html

上一篇: Selenium 2.0是否在等待元素/页面加载?

下一篇: 硒单击有时会导致页面加载,有时不会