Selenium race condition waitForPageToLoad?

We use Selenium to test smoke on the Java Spring MVC website. We invoke it using JUnit and the Java Selenium client. In most cases, our tests work fine, but we tend to get timeouts in selenium.waitForPageToLoad in obviously random places. (That is, run the test suite several times, and the location and number of timeouts will vary greatly.)

By running it with the server in the foreground, I can monitor the execution of the tests. When one of these timeouts occurs, selenium.click crashed before the wait, but the wait does not appear. Right-click on the page and select Refresh to clear the lock.

For me, this suggests a race condition between click and waitForPageToLoad. Other problems are related to waitForPageToLoad, but do not describe the state of the race. Some of them suggested problems with the previous call to selenium.click, but I do not see this here. Has anyone else seen what I watched?

I saw several suggestions not to use waitForPageToLoad, but workarounds often suggest using waitForElementPresent or manually polling for the presence of an element. With our application, which would seem to require HTML tools with identifiers that will be used only by tests. Is there a non-intrusive approach to this method?

+3
source share
4 answers

Selenium waitForPageToLoad() - , - , . Firefox, Selenium RC , , Internet Explorer. , .

, , - " ?" , , , , . , WireShark Fiddler - . , , Selenium RC captureNetworkTraffic() , .

+1

, , , , .

@Ross, " ". , , - JavaScript, , - , , , , .

, , selenium , selenium set_speed(time_in_ms).

$self->{sel}->open_ok("/", $self->{browser});
# Inject 2000 ms in between selenium calls
$self->{sel}->set_speed("2000");

, , 1000 .

+1

Selenium RC 2.25/Windows 7/IE 9.

:

  • Java ( cmd.exerun as administrator)
  • Internet Explorer .

.

+1

. window.location (, window.location = "#myAnchor" ) . , URL waitForPageToLoad, , , , , .

(100 ) "setTimeout", window.location.

Selenium .

+1

Source: https://habr.com/ru/post/1753364/


All Articles