1

Should the automation scripts made in Selenium always contain wait calls like implicit, explicit and fluent, or could it be that waits are not needed?

1
  • 1
    You don't need waits unless you have dynamic interface that takes data from async requests.
    – Alexey R.
    Nov 12 '21 at 12:12
1

It depends, but probably yes (yes - you should have waits).

If you are interacting with web elements (and you are if you are using Selenium) that implies a network so there will be some change in speed of execution or network conditions that would make the tests without waits indeterministic. So, you will need waits - and which ones will depend on particular conditions of your app.

0

Wait calls are needed in my experience as long as you never wait for a set amount of time. Always wait only until the System Under Test (SUT) has responded in the way it should do.

Many systems you test might disable a button when you click it and then enable that button again when they are ready to respond to your next instruction. Or you might enter text in a field and then you wait until the OK button becomes enabled. You don't want your test to click on OK button that has not become enabled yet but will be enabled in half a second.

Also note that the checks your test perform on say a buttons enabled state can also impact the responsiveness of the SUT if the SUT runs on the same machine as your test executable. When testing an SUT with slow responsiveness, it is sometimes better to slow down your test and let the SUT catch up.

0

Selenium scripts doesnt need waits for page loads , selenium scripts need waits when the components are loaded asynchronously

https://www.selenium.dev/documentation/webdriver/page_loading_strategy/

The document.readyState property of a document describes the loading state of the current document. By default, WebDriver will hold off on responding to a driver.get() (or) driver.navigate().to() call until the document ready state is complete

so if the elements are loaded after the document.readystate is set , then you have to use wait

0

As a regular practice, the majority of the software/security testing services use waits in the selenium automation scripts to avoid fake failures during the script/test-suite execution.

Adding dynamic/Explicit waits to the scripts is considered a good approach because it ensures that elements/pages are loaded successfully before taking any action on the page. To exemplify, if a wait for the element load or a wait for a button to get enabled is missing -> then script will instantly fail which is not the actual results of the test script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.