Forum Discussion

BigBear's avatar
BigBear
Occasional Contributor
7 years ago

Are Wait related methods (Wait, WaitChild, WaitAliasChild, WaitProperty) working in Keyword Test?

Hello,

I use Keyword Test in TestComplete to test web applications. Usually when I record a new Keyword Test, the test will automatically record rows to Wait for certain web pages to load. In a normal situation, everything is working well. But sometimes, when the web application is slow (take longer response time to load the next page), I will have to increase the wait time or put wait related commands to wait for the page to load before doing something else.

 

I have a situation like this in Keyword Test:

 

(the script is doing something else .....)

Row 1 -> WebPageA.wait

Row 2 -> WebPageA.button1.click

(the script is doing something else .....)

 

When the web site is slow, the script always fails in Row 2 and the error message is "WebPageA" is not exist. I set the wait time to big numbers and my project default wait timeout is also a big number but it doesn't seem to be waiting at all.

I have tried Wait, WaitChild, WaitAliasChild, WaitProperty in this situation but none of them worked. So I ended up always had to comment out all these Wait commands and replaced with Delay command. But Delay is not a good way to do in this situation. I did a lot of research and it seems everyone else has suggested to use these Wait commands but they just don't work for me. I also tried the Wait on the mobile app that I am testing and it is also not waiting at all. Not sure what I am missing here. So far, I only tried on Keyword Test and haven't got a chance to try in a script yet but it should not make any difference. Any help is appreciated.

4 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    It would help to see a sample of your keyword test with the associated error to get better idea of what might go in unexpected way in your case.

    But in general, the situation is like this:

    -- Yes, .WaitXXX() methods must work for both, scripts and keyword tests;

    -- page.Wait() waits for the page to be loaded within either specified or default time interval. Note, that the page is considered to be loaded when complete response for the initial page request was obtained from the server. However, it may take additional noticeable time for the browser to parse and render the obtained page. Especially, if it contains a lot of scripting with a lot of computing-intensive calculations. Besides that, all additional requests sent from the page (Ajax or triggered by script code) are not counted while waiting for page load. (And this is correct.) All the above means that in addition to page.Wait() call, you might need to explicitly wait until this or that element appears on web page;

    -- .WaitXXX() methods work only when the object is sought for for the first time (i.e. when test code obtains the reference to it). After that, the object is 'cached', regardless of whether it was found or not, and the obtained result is used further in the code until the same object is sought for again (if needed);

    -- As for the error you are mentioning - "WebPageA" does not exist - it looks like that test code either did not obtain the reference to the tested page (this is assumed to be done before the  WebPageA.Wait() call), or the tested web page was reloaded and this invalidated the initially got reference to it.

     

    If the above does not help you then it would be nice to see your test and test log as I already wrote.

    • BigBear's avatar
      BigBear
      Occasional Contributor

      AlexKaras, these are good information to know. Thank you very much.

      I couldn't find a good example to post now. Next time when I encountered one, I will post an example. Usually it is when the web site is slow or when clicking on a button and the site is spinning (when processing the information) for a while before returning a result page.

       

      I also noticed something here:

       

      Wait method:
              WaitTime, Default value = -1 (the documentation does not tell you what -1 means here)

      WaitProperty method:
              If WaitTime is -1, the waiting time is specified by the Auto-wait timeout project property.

      WaitChild method:
              If WaitTime is -1, the waiting time is infinite.

      WaitAliasChild method:
              WaitTime, Default value = 0
              If WaitTime is -1, the waiting time is specified by the Auto-wait timeout project setting.

       

      When you give -1 for these methods, their meanings are different in each one. SmartBear is so inconsistent in the default values and the meanings of the default values.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Right click on the part of your test indicated as row 2, select "Set Auto-Wait Timeout for Operations".  This will allow you to increase or decrease the timeout for that particular row.  It acts much the same as the Wait methods you mentioned.

     

     

    • BigBear's avatar
      BigBear
      Occasional Contributor

      This "Set Auto-Wait Timeout for Operations" works great and without extra code. Thank you very much, Tristaanogre.