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 by js expression syntax



Is this correct syntax for the js expression?

return $browser.waitForAndFindElement(
    .then(function(e) {;

I get this error…

TaskTimedOut: Task timed-out waiting for element to be located using: function(driver) {

Yet the following code appears to work correctly…

return $browser.executeScript("document.getElementsByClassName('button-add-compare')[0].click();");


Hi, @william.krick: See if this helps:


Thanks. I was missing the “return” at the beginning of the expression…

return $browser.waitForAndFindElement(
    $driver.By.js("return document.getElementsByClassName('button-add-compare')[0]"))
    .then(function(e) {;