In the-automator Newsletter and recent YouTube channel, a way to wait for a Browser to be loaded was shared.
After some research, I share here a better way to wait for a browser page to be loaded.
Problem description
For many automation task with the browser, you want to be able to wait till a page/url is loaded in the Browser, avoiding a fixed paused i.e. pausing only the minimum necessary time.
Benchmark
There are different solutions available in the net to implement this. Some using Image/Pixel Search.
Best Solution
The best solution - but that was not posted as answer in the forums is to use the UIA.
It is implemented in Descolada's UIA_Browser library:
You can load an url with the option to wait untill the page is loaded using the function Navigate or call the WaitPageLoad method separately.
Navigate(url, targetTitle="", waitLoadTimeOut=-1, sleepAfter=500)
Navigates to URL and waits page to load
WaitPageLoad(targetTitle="", timeOut=-1, sleepAfter=500, titleMatchMode=3, titleCaseSensitive=True)
Waits the browser page to load to targetTitle, default timeOut is indefinite waiting, sleepAfter additionally sleeps for 200ms after the page has loaded.
The implementation checks that the refresh button has changed to the load button.
(The solution shared by the-Automator is far from the best. I can't understand why the comment I have posted on their the YouTube video was deleted.)
No comments:
Post a Comment