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

Minimum timeout for waitForAndFindElement is not as documented


The documentation for $browser.waitForAndFindElement(locator: $driver.Locator [, timeout: number) indicates the timeout value is a default of 1000ms.

I have a script which indicates that the default is actually 10,000ms and anything less than this will not be honored, but values greater than 10000 will be honored. Is this known and as designed? If so, the docs need to be updated ASAP. If not, hopefully this can be logged as a bug and fixed?

I am in need of a way to try to find an element with potentially two different mutually exclusive xpaths. The hope was to try one way, fail quickly if not found and then try the second way. At this point, I cannot fail faster than 10s and with repeated calls to this I’m eating up a tremendous amount of my 180s budget.

Any ideas are appreciated!


Hi @toconnor1 - the default timeout, if not specified, is 10000. You can pass in your own timeout value to suit your needs. So in your example, you could use something like the below psuedo-code to wait 2 seconds for the first element prior to failing then 5 seconds for the second.

It is common to set a variable to set the timeout value that you expect across your scripts.

return $browser.waitForAndFindElement(locator for first element, 2000).then(function(){
  return $browser.waitForAndFindElement(locator for second element, 5000);


Hi @stefan_garnham. Thank you for taking the time to reply.

As I indicated in my question, the documentation indicates a default timeout of 1000ms but it appears to actually be 10000ms. Furthermore, I have tried specifying a timeout value of less than 10000ms and it is not being honored. That is my question, why does the behavior not match the docs and why can’t I use a timeout less than 10s?

Lastly, if this function cannot timeout in less than 10s, then is there any guidance on how this can be accomplished with a faster timeout? I need to “fail fast” in my script as it is a common case to have the first xpath not be within the DOM but a second will. Need to be able to check both as fast as possible.


Just wanted to update folks on this thread to what @toconnor1 and I found in a separate ticket looking into this behavior.

What is factoring into the 10s wait, is implicit wait . This is a default wait timeout that is applied globally to all DOM polling methods. In our environment, we set the default implicit wait to 10 seconds.

So what is happening here is the timeout for waitForAndFindElement is being stacked on top of that implicit wait. So if you were to set the waitForAndFindElement timeout to 10,000ms this would equate to a 20,000ms wait time. Fortunately, implicit wait can be managed with the following method:

  • $browser.manage().timeouts().implicitlyWait(0)

In this case, one could set this to 1000 or 0 ms depending on your preference here.