Forum Discussion

vijaysimha's avatar
vijaysimha
Occasional Contributor
6 years ago

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

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    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.)