cancel
Showing results for 
Search instead for 
Did you mean: 

Waiting for XPath or CSS elements(TimeOut)

Highlighted
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
Highlighted
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
================================
Highlighted
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 Gorbunova
SmartBear Community Manager

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
Highlighted
Occasional Contributor

Re: Waiting for XPath or CSS elements(TimeOut)

Hi @TanyaGorbunova 

 

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.

 

Highlighted
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
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!

Challenge Status

How to execute remote test and obtain results via Test Runner REST API

Participate!

Comparing content of HTML table with Excel file data

Participate!

Compare HTML table with Excel file and correct data in the file

Participate!

Retrieve Data from a Web Page

Participate!