cancel
Showing results for 
Search instead for 
Did you mean: 

Waiting for XPath or CSS elements(TimeOut)

vijaysimha
Occasional Contributor

Waiting for XPath or CSS elements(TimeOut)

Hi All,

 

In Javascript for xpath Locators how can we provide implicit waitTime .

Below is the script designed ,can anyone help for below code.

 

browser = Sys.Browser(*);

page = browser.Page('myURL');

SignOut_Button = page.Buttons.FindChildByXPath('/*[@id='signout']/div[1]')

if (SignOut_Button.Exists) {

    SignOut_Button.Click();

}

 

Thanks

Vijaysimha

4 REPLIES 4
AlexKaras
Community Hero

Re: Waiting for XPath or CSS elements(TimeOut)

Hi,

 

a) No way. You must search within a loop and exit when the sought for object is found or timeout elapses;

b) Search by XPath is highly not recommended for TestComplete. Consider .FindXXX() methods instead. .FindChildEx() method has a parameter to specify the thing that you are looking for;

c) Your code is not correct. See the Result Value section of the FindChildByXPath() help topic - if the sough for object is not found then null is returned. (And if found, then either TC object that contains .Exists property or native DOM object that does not contain .Exists may be returned depending on what exact object was found.)

 

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
================================
TanyaYatskovska
Community Manager

Re: Waiting for XPath or CSS elements(TimeOut)

Hi @vijaysimha,

 

Could you please explain your task in detail?

Perhaps, we can suggest alternative solutions.

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
vijaysimha
Occasional Contributor

Re: Waiting for XPath or CSS elements(TimeOut)

Hi @TanyaYatskovska 

 

In Javascript i have written function  for  dynamic xpath which accept text as parameterized.

For this script i have to wait until visibility of xpath found in page.

Hence provide solution for waitTime with example.

 

Note: Delay keyword is not encourged in my Organisation.

 

AlexKaras
Community Hero

Re: Waiting for XPath or CSS elements(TimeOut)

Hi,

 

> Hence provide solution for waitTime

https://community.smartbear.com/t5/TestComplete-Desktop-Testing/Waiting-for-XPath-or-CSS-elements-Ti..., option a).

 

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
================================
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors