Web tests - Wait till an URL is displayed
in web tests, I would like to understand if there is a way to wait till an url is changed.
I go in details with my situation:
- when I open my web page, I set the url "URL_X"
- automatically, because an authentication is required, the page is redirected to a completely different one for the login, with "URL_Y"
- then, I set username and password on textboxes and click on the login button
- now, the redirection to the page with "URL_X" for the logged user is done.
After that, on the test code I need to test my page on "URL_X".
To interact with the objects of the page "URL_X", I need to execute a page.Refresh() to update the object tree, but I must execute the refresh after that the page with "URL_X" is loaded (it could take some time after the click on the Login button), so I have added a fixed delay before the page.Refresh().
To prevent to have a fixed delay (sometimes the loading time could be a lot faster than the delay), is there a way on the code to "understand" that the url is changed, so to add a "wait till the page with URL_X is displayed".
Ask me if you need more information or clarification.
Thanks and regards,
Solved! Go to Solution.
Yes, you can use a Wait method to wait for the page to load, or a WaitProperty method to wait for the URL or href (or similar) property of the Page is updated.
Are you using Script or KeywordTests? For keyword tests you can drag an OnScreenAction or Call Object Method operation into your test, select the Page, then select the most relevant Wait method.
If you have recorded your test, TestComplete should automatically add Wait operations to the flow for page changes, but you can manually add more if needs be, using the above operations.
Some more options here - Waiting for Web Pages
Hope this helps
Thank you @mikef , I'll try with the suggestions from the page that you've linked.
Because I've got a complex page that loads some graphics (the performance are unfortunately not high, so they take long time to be loaded).. probably the best solution could be the one described within the "Waiting for an element on the page" paragraph.