Your data. Anywhere you go.

New Relic for iOS or Android

Download on the App Store    Android App on Google play

New Relic Insights App for iOS

Download on the App Store

Learn more

Close icon

waitForAndFindElement seems not working



Actual request is:
When the web page is fails to load an element with in 2sec/ 5sec it should fail, but it is resulting not as exepected now. Can someone help us in fixing it.
waitForAndFindElement seems not working

//Find the user name field by specifying its id, then enter the user name. 
$browser.waitForAndFindElement($"email"), 2000).then(function(){ 
return $browser.findElement($"email")).sendKeys("XXXXXXXX"); 
//Find the password field by specifying its id, then enter the password 
return $browser.findElement($"password")).sendKeys("XXXXXXXX"); 
//Click the submit button. 
return $browser.findElement($driver.By.css("button.btn")).click(); 
// Wait for page to Load 
$browser.waitForAndFindElement($driver.By.css(".tenants table"), 5000).then(function(){



Hi @siteops-group - The findElement and waitForAndFindElement both return a promise. If you do not put return on each line which returns a promise, you break the promise chain and the functions will fire randomly. Take a look at the synthetic script samples to get a better understanding.

Note for @RyanVeitch - The documentation example for Wait for a page element has a broken promise chain from the $browser.get which could be causing some confusion.


Thanks @stefan_garnham - I’ll look into that example today and get the docs updated.