开发者

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

开发者 https://www.devze.com 2023-04-11 09:05 出处:网络
Clicking on a button in my web page sometimes causes the entire page to load, and sometimes only part of it to load.

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 us开发者_JS百科e, 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.


Wait for element you want to proceed with instead of wait for page to load

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号