cancel
Showing results for 
Search instead for 
Did you mean: 

Page wait method doesn't wait the time I provided

SOLVED
whuang
Frequent Contributor

Page wait method doesn't wait the time I provided

Hi there,

 

I was using sys.browser("*").Page("*WebStore/Checkout*").Wait(60000) to wait for my page, but it only waited for 5 seconds and then execute the next line. Does anybody know why and how I can fix it?

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
AlexKaras
Community Hero

Re: Page wait method doesn't wait the time I provided

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.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

4 REPLIES 4
AlexKaras
Community Hero

Re: Page wait method doesn't wait the time I provided

Hi,

 

> Does anybody know why and how I can fix it?

Because the page source was obtained from the server within 5 seconds.

As per documentation, .Wait() method waits for the page to be obtained from the server and the browser is ready to process user's input. Note, that this time does not include the time required for all scripts embedded on the page to complete. As well as it does not include the time required for all bells and whistles that all modern web pages are full of (AJAX) to finish. This is specific to every web page and you need explicitly wait for this or that element that is essential for your test to appear on the page before proceeding further.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
whuang
Frequent Contributor

Re: Page wait method doesn't wait the time I provided

Thanks for your answer, so what wait method should I use if I want to wait for the next page to be fully loaded and then execute the next line of code? What happens right now is I use this wait method, and it only waited for a few seconds and then execute the next line, but the browser was still processing on the previous page, that spinning circle was still spinning on the  browser tab. Below is the screenshot from the test log where TC failed to wait for the page I specified.

whuang_0-1604444557378.png

 

AlexKaras
Community Hero

Re: Page wait method doesn't wait the time I provided

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.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

whuang
Frequent Contributor

Re: Page wait method doesn't wait the time I provided

Thank you very much, that helps a lot.

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors