Forum Discussion
My codes call the same action 6 times during the test, and they were all using the same default wait for page time, which is 40 sec. Sometimes only the second call complains object cannot be found, sometimes it is the fourth call, sometimes it could be the second and the third call both not finding the object, but the page was loding no problem, I was monitoring the test while it was running, visually I could see the page was loaded in less than 2 seconds, and the TC progress bar at the top right which display "waiting for page to load" went away after 2 or 3 seconds, so I assumed TC detected the page was loaded completly. So in this case how can I force it to wait longer? I gave it 40 seconds, but it only took a couple seconds and then go to the next line of codes.
Hi,
> it still reports object cannot be found after I told it to wait for the page to load
As per documentation, page.Wait() waits for the page to load. I.e. it waits until the last byte for the page request is received from the server. For usual static web pages this is enough.
The bad news is that modern dynamic web pages use a lot of scripting and data obtained from additional resources via additional requests. In the worst case, data load and subsequent rendering is implemented using lazy load technique.
The above means that in addition to wait for the page source to load, you need to wait for all scripts on the page to finish their execution (scripts often drastically change DOM structure of the page) and to wait for all additional data is loaded as well.
Exact algorithm of the wait depends on your tested application.
For example, if you know what element you will work with after page load, you may use this approach:
-- Wait for the page to load;
-- Wait for the element to appear on the page;
-- Optionally, if needed, wait until the element is populated with data;
-- Continue the test.
If you don't know what element you will work with (for example, if you need to delay until complete web page that utilizes lazy loads is loaded), the approach like this should work:
-- Wait for the page to load;
-- Wait for all scripts on the page to finish - this (usually) ensures that all external data is received and rendered;
-- Press Page Down key to scroll page one screen down. This will trigger additional data requests via lazy loads. Repeat the above step to wait until all additional data is loaded;
-- Continue pressing Page Down until some anchor element at the end of the page which is out of page viewport during data load (and thus is not visible on screen) becomes visible on screen;
-- Continue the test.
- vthomeschoolmom6 years agoSuper Contributor
"Why re-run the failed tests right away? They failed for a reason. Either the automation was created incorrectly and they failed due to coding errors. Or, they failed because a bug was found and needs to be corrected by the developers. Either way, re-running a failed test automatically will rarely, if ever, do any real good."
I would love this ability too. I disagree with both the above and the assumption of a timing issue. Many times I have seen Windows or the AUT barf in ways that only occur under test runs.
Related Content
- 12 months ago
- 4 years ago
- 2 years ago
Recent Discussions
- 9 hours ago
- 10 hours ago
- 16 hours ago