Ask a Question

Why TC keeps waiting until the time expire while I can see the object I am waiting for is there

SOLVED
whuang
Regular Contributor

Why TC keeps waiting until the time expire while I can see the object I am waiting for is there

Hi Guys,

 

I was trying to get TC to click on a link and then click on another link on the page after. So I used a WaitChild method in the script, but it keeps waiting on the page until the 30 seconds expired, but I can see the object that I was waiting for was showing on the page as soon as the first link was clicked. Same issue when I used the WaitProperty method instead of the WaitChild. Can anyone tell me what wait method I should use in order to avoid uneccessary waiting?

 

sys.Browser("*").Page("*").Find("contentText","Photo, Video & Design",30).Click
call Sys.Browser("*").Page("*").WaitChild(Sys.Browser("*").Page("*").Find("contentText","Corel",30),30000)
sys.Browser("*").Page("*").Find("contentText","Corel",30).Click

 

Thanks!

 

 

15 REPLIES 15
AlexKaras
Community Hero

Hi,

 

Can you provide the final test log?

My expectation is that there are problems reported to the log caused by the fact that there is more than one browser process running in your system at the moment of test execution.

Basically, your test code commands this:

First line of code:

> sys.Browser("*").Page("*").Find("contentText","Photo, Video & Design",30).Click

-- Look for any browser process running in the system;

-- For the found arbitrary browser, get any page opened in it;

-- Within this page look for the web element with the "Photo, Video & Design" text;

-- Click on the found element.

 

Obviously, if, say, some browser process is running in the background with no page opened and this will be the process that TestComplete finds first, TestComplete will wait for the page and other web page elements.

 

Second line of code:

> call Sys.Browser("*").Page("*").WaitChild(Sys.Browser("*").Page("*").Find("contentText","Corel",30),30000)

-- Look for any browser process running in the system. Note - the found browser process well might be not the same that was used on previous step. This is because you are not reusing found process, but do search a-new;

-- For the found arbitrary browser, get any page opened in it. Same problem with the page;

-- Within this page, wait for a child web element, that is located on an arbitrary page of an arbitrary browser process that (web element) has the 'Corel' text. Again, note, that the first and second browser processes used in this line of code, likewise their respective pages, might be absolutely different ones (and differ from those found on first line) because you perform a search every time but do not reuse the found objects.

 

Third line of code:

> sys.Browser("*").Page("*").Find("contentText","Corel",30).Click

-- Look for any browser process running in the system. Again, the found browser process can be different than those been found previously;

-- For the found arbitrary browser, get any page opened in it. Same problem here;

-- Within this page look for the web element with the "Corel" text;

-- Click on the found element.

 

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
Regular Contributor

Hi @AlexKaras , I am new to TC and scripting, so I am kind of learning both at the same time.Here is the log screenshoot. There was only Chrome running, I killed Edge running at the back before running the test. How can I store and reuse the search result from the second line?

1.JPG

Update - I end up using sys.Browser("*").Page("*") to wait for the page to load and then continue the next step. It is much faster and it doesn't wait for unnecessary time. Is it safe to say that all the properties and objects are available to access once the wait is done by using this Wait method?

Hi,

 

Possible code (assuming that the initial page is already opened in the browser):

Dim page
Dim oControl

Set page = sys.Browser("*").Page("*<yourCompany>.com*")
Set oControl = page.Find("contentText", "Photo, Video & Design", 30)
If (oControl.Exists) Then
  Call oControl.Click()
Else
  Call Log.Warning("Web element with the 'Photo, Video & Design' text was not found", , , , page.PagePicture)
End If
Call page.Wait() ' waits until new page is loaded

Set oControl = page.Find("contentText", "Corel", 30)
If (oControl.Exists) Then
  Call oControl.Click()
Else
  Call Log.Warning("Web element with the 'Corel' text was not found", , , , page.PagePicture)
End If
Call page.Wait()

 

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
Regular Contributor

Thanks @AlexKaras This is much easier for me to understand. I noticed that if I use page.PagePicture to take screenshot in the log, my window jumps from the top of the screen to the bottom and then jump back to the top when it is taking screenshots, is that expected?

Hi,

 

if I use page.PagePicture to take screenshot [...], my window jumps [...], is that expected?

Yes, this is expected and as designed.

 

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
Regular Contributor

Hi @AlexKaras, after wait for the page to load, and then I perform a link click action, but for most of the time, it returned a "There was an attempt to perform an action on a zero-sized window." error. It worked for a few times with the same script. Do you have any idea why?

Capture.JPG

Thanks

Hi,

 

> Do you have any idea why?

Why what? 🙂
If you are wondering why the error is posted to test log, then I believe that the error message is quite self-descriptive: test code tries to click on the object (Panel("notice_only_opt_ins")) which is of zero size which makes click action to be impossible.

If you are wondering why this panel is of zero height, then this should be investigated with your given tested application. Maybe your test code references wrong object. Maybe your test code tries to reuse some object that was recreated and this invalidated its reference in test code. Maybe because of some other reason.

I would recommend to set a breakpoint on the problematic code line and check in debugger what objects test code tries to work with.

 

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
Regular Contributor

Sorry @AlexKaras I forget what I was asking in the last question, but that's ok the issue was solved.

 

Now I am wondering how I can use the wait property method,  when I use TestObj.WaitProperty("contentText", “Text I need to wait for", 15000),  the script keeps waiting until the time expire no matter the text is found on the page or not.

tristaanogre
Esteemed Contributor

Keep in mind that contentText may contain non-printing characters so while the text may APPEAR to be correct, in the contentText property there may be other characters that need to be accounted for.  I'm thinking that this might not be the best property to use for waiting.  


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
cancel
Showing results for 
Search instead for 
Did you mean: