...
Why do we need time.sleep(XXX)?
Related articles
Content by Label | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...
hidden | true |
---|
Lines 38 and 48 have time.sleep(XXX), which can be added from Selenium IDE using "pause" command, which waits for a specified number of seconds unconditionally.
This is a simple way to fix a timing issue. For example, line 38 is necessary because "Seismic Hazard" link can be already enabled if the user comes back to the "Site Selection" tab from the "Seismic Hazard" tab. When the "Set" button is clicked, there is a very short delay before "Seismic Hazard" link gets disabled. Without the time.sleep(3), it checks that the link is active, but when it clicks the link when it has already disabled - and the test gets stuck!
At the end of the test, Pytest kills the browser. The sleep at line 48 is necessary as the test immediately exits as soon as it "clicks" the download link - no download is actually taking place.
It is certainly better to check the existence of download file and check its correctness.
...