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

alerts

#1

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

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

}); 
});

#2

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.


#3

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