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 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
精彩评论