TaskTimedOut: Task timed-out waiting for element to be visible -Wait timed out after 30025ms

I’m getting tasked timedout exception when trying to use “waitForAndFindElement”.

//log(12.1, 'IndexSpeed');
        $browser.waitForAndFindElement(By.xpath("//ot-i18n[@ot-token='Refresh']"), stepTimeout) //wait for search results
        .then(function(resultsText){
            $browser.sleep(5000);
            resultsText.click().catch(function(err){
              $browser.findElement(By.xpath("//div[@title='Refresh']")).click();
              console.log("clicked Refresh button!");
            });

Hello @amony -

Thanks for posting in the community! The most common reason for this to fail is because the element you are testing is behind another element or has a size of zero. There’s a bit about that in our documentation here:

https://docs.newrelic.com/docs/synthetics/synthetic-monitoring/scripting-monitors/introduction-scripted-browser-monitors/#wait-page-element

If neither of those are the issue, please let us know and we can troubleshoot with you.

1 Like