18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
Curious about the implicit wait mechanism
Hi,
One of the features I like about Sahi is the implicit wait mechanism. The ability to wait for the UI widget to become available before proceeding makes test execution much more reliable. It works much better than Selenium did with our application (smartGWT based).
I am curious to learn more about how this works exactly. It may be our application, but there are a few sporadic spots in our application where we do see some sporadic timing related failures. It is very sporadic ... perhaps centering around pop-up windows which are very complex.
I notice some of this is configurable in sahi.properties ...
#Time (in milliseconds) delay between steps
script.time_between_steps=100
#Time (in milliseconds) delay between retries once an error occurs
script.time_between_steps_on_error=2000
#Number of retries once an error occurs
script.max_reattempts_on_error=5
#Number of cycles Sahi will wait for the page to load before it proceeds with execution
#Time spent is (script.max_cycles_for_page_load x script.time_between_steps) milliseconds
script.max_cycles_for_page_load=1200
#No of times Sahi should wait for stability of AJAX and page loads before continuing. min value is 1
Is there more I can learn about how this works, how to tweak it, etc...?
Thanks,
Michael Foley
One of the features I like about Sahi is the implicit wait mechanism. The ability to wait for the UI widget to become available before proceeding makes test execution much more reliable. It works much better than Selenium did with our application (smartGWT based).
I am curious to learn more about how this works exactly. It may be our application, but there are a few sporadic spots in our application where we do see some sporadic timing related failures. It is very sporadic ... perhaps centering around pop-up windows which are very complex.
I notice some of this is configurable in sahi.properties ...
#Time (in milliseconds) delay between steps
script.time_between_steps=100
#Time (in milliseconds) delay between retries once an error occurs
script.time_between_steps_on_error=2000
#Number of retries once an error occurs
script.max_reattempts_on_error=5
#Number of cycles Sahi will wait for the page to load before it proceeds with execution
#Time spent is (script.max_cycles_for_page_load x script.time_between_steps) milliseconds
script.max_cycles_for_page_load=1200
#No of times Sahi should wait for stability of AJAX and page loads before continuing. min value is 1
Is there more I can learn about how this works, how to tweak it, etc...?
Thanks,
Michael Foley
Comments
This is how Sahi's implicit wait works.
When a command like _click(_button("Login")) is sent to Sahi's engine on the browser, Sahi does this:
1) Check if the window and all frames/iframes in it are loaded. If not go into a loop which checks every 100 ms whether the page is loaded. It does this a maximum of 1200 times and then proceeds
2) If the windows was loaded, it checks for any open XMLHttpRequests (checks if status is 1,2,3). Sahi is able to monitor this by hooking into XHR's prototype. If there are any open XHRs, Sahi waits till these reach state 4.
3) There is one other parameter called stabilityIndex which Sahi looks at. This means after satisfying conditions 1 and 2, Sahi will not immediately execute the step, but wait stabilityIndex times to look for any new AJAX activity before it executes the step.
4) Once the above are satisfied, Sahi executes the step. If there is an error, it waits for 2000 ms before it retries the step. It will retry it 5 times.
If the step still fails, Sahi reports it as an error.
---
Why a step may fail in spite of the above checks:
Sometimes you may be wanting to do this:
Page A contains buttonX and buttonY
You wish to click buttonX, which triggers a delayed reload (via settimeout) and then click buttonY
The sahi script would look like
click buttonX
click buttonY
Now when Sahi clicks on buttonX, and suppose the reload kicks in after a small timeout, Sahi will go on to click buttonY also, before the page really reloads. This can cause unexpected results.
A way to handle this is:
click buttonX
assert on something that will be available only after page load
click buttonY
Hope that helps,
Narayan