Page wait method doesn't wait the time I provided
- 5 years ago
Hi,
> what wait method should I use if I want to wait for the next page to be fully loaded
Unfortunately, such method does not exist because the definition of the "fully loaded" page is specific to every given web page (an web application).
The generic approach is like this:
-- For every tested web page you must determine some web element (let's call it anchor) that: a) must exist on the page in order your test code can continue; and b) web page must be responsive when this anchor web element appears on the page (i.e. page can process user input when anchor element appears on it). This will be a definition of "fully loaded page" for this given page. For other page the anchor element might appear to be different, but the approach remains the same;
-- Use page.Wait() call every time a new page is requested from web server as a result of the click on some web element (link, button, etc.). This step can be skipped if the click does not initiates load of the new page but just triggers some script that changes page's DOM;
-- After .Wait() method returns, you should use the proper WaitXXX or FindXXX method (WaitAliasChild, FindChild, etc.) and use it in a loop until the anchor web element appears on the page. When the anchor web element appears on the page this means that the page is fully loaded and your test code may continue.
P.S. Note, that the above approach does not necessarily assume that all web elements have been loaded. But if you need this, then the approach remains the same - you must somehow determine what web element is loaded last and wait until this last web element is loaded.