TaskTimedOut: Task timed-out waiting for element to be visible using

Hi Team,

I am New to NR and trying to create an scripted monitor and running into above error . Please find my code base below .

/ Get browser capabilities and do nothing with it, so that we start with a then-able command
$browser.getCapabilities().then(function () { })

// Step 16
.then(function() {
log(16, ‘$browser.get(“http://dvtcbddd02:8080/”)’);
return $browser.get(“http://dvtcbddd02:8080/”); })

// Step 17
.then(function() {
log(17, ‘setElementText “//div/div/div/div/div[2]/div/div/div/div/input[1]”’);
return $browser.waitForAndFindElement(By.xpath("//div/div/div/div/div[2]/div/div/div/div/input[1]"), DefaultTimeout); })
.then(function (el) {
el.clear();
el.sendKeys(“xxxxxx”); })

// Step 18
.then(function() {
log(18, ‘setElementText “//div/div/div/div/div[2]/div/div/div/div/input[2]”’);
return $browser.waitForAndFindElement(By.xpath("//div/div/div/div/div[2]/div/div/div/div/input[2]"), DefaultTimeout); })
.then(function (el) {
el.clear();
el.sendKeys(“xxxxxxx”); })

// Step 19
.then(function() {
log(19, ‘clickElement “//div[@id=‘ember3850’]//button[.=‘Sign in’]”’);
return $browser.waitForAndFindElement(By.xpath("//div[@id=‘ember3850’]//button[.=‘Sign in’]"), DefaultTimeout); })
.then(function (el) { el.click(); })

// Step 20
.then(function() {
log(20, ‘mouseOverElement “div.row-fluid”’);
return $browser.waitForAndFindElement(By.css(“div.row-fluid”), DefaultTimeout); })
.then(function (el) { $browser.actions().mouseMove(el).perform(); })

// Step 21
.then(function() {
log(21, ‘$browser.get(“http://dvtcbddd02:8080/views/HIVE/1.5.0/HIVE_VIEW/#/queries/fixture_0”)’);
return $browser.get(“http://dvtcbddd02:8080/views/HIVE/1.5.0/HIVE_VIEW/#/queries/fixture_0”); })

// Step 22
.then(function () {
log(22, ‘waitForTextPresent “Query Editor”’);
$browser.wait(function () {
return $browser.findElement(By.tagName(‘body’)).getText().then(function (text) { return text.indexOf(“Query Editor”) != -1; }).then(function (bool) { return bool; });
}, DefaultTimeout);
})

// Step 23
.then(function() {
log(23, ‘clickElement “pre”’);
return $browser.waitForAndFindElement(By.css(“pre”), DefaultTimeout); })
.then(function (el) { el.click(); })

// Step 24
.then(function() {
log(24, ‘setElementText “//div/div/div/div[2]/div[1]/div/panel/div/div[2]/tabs/query-editor/div/div[1]/textarea”’);
return $browser.waitForAndFindElement(By.xpath("//div/div/div/div[2]/div[1]/div/panel/div/div[2]/tabs/query-editor/div/div[1]/textarea"), DefaultTimeout); })
.then(function (el) {
el.clear();
el.sendKeys(“show tables;”); })

// Step 25
.then(function () {
log(25, ‘waitForTextPresent “show tables;”’);
$browser.wait(function () {
return $browser.findElement(By.tagName(‘body’)).getText().then(function (text) { return text.indexOf(“show tables;”) != -1; }).then(function (bool) { return bool; });
}, DefaultTimeout);
})

// Step 26
.then(function() {
log(26, ‘clickElement “//div[@class=‘toolbox’]/button[1]”’);
return $browser.waitForAndFindElement(By.xpath("//div[@class=‘toolbox’]/button[1]"), DefaultTimeout); })
.then(function (el) { el.click(); })

// Step 27
.then(function () {
log(27, ‘waitForTextPresent “(Status: SUCCEEDED)”’);
$browser.wait(function () {
return $browser.findElement(By.tagName(‘body’)).getText().then(function (text) { return text.indexOf("(Status: SUCCEEDED)") != -1; }).then(function (bool) { return bool; });
}, DefaultTimeout);
})

// Step 28
.then(function() {
log(28, ‘$browser.get(“http://dvtcbddd02:8080/”)’);
return $browser.get(“http://dvtcbddd02:8080/”); })

// Step 29
.then(function() {
log(29, ‘mouseOverElement “div.row-fluid”’);
return $browser.waitForAndFindElement(By.css(“div.row-fluid”), DefaultTimeout); })
.then(function (el) { $browser.actions().mouseMove(el).perform(); })

// Step 30
.then(function() {
log(30, ‘clickElement “button.btn.dropdown-toggle”’);
return $browser.waitForAndFindElement(By.css(“button.btn.dropdown-toggle”), DefaultTimeout); })
.then(function (el) { el.click(); })

// Step 31
.then(function() {
log(31, ‘clickElement “i18n-13”’);
return $browser.waitForAndFindElement(By.id(“i18n-13”), DefaultTimeout); })
.then(function (el) { el.click(); })

.then(function() {
log(lastStep, ‘’);
console.log(‘Browser script execution SUCCEEDED.’);
}, function(err) {
console.log (‘Browser script execution FAILED.’);
throw(err);
});

Its failing at step 24. I have run it in firefox through selenilu builder and it workes fine .I know NR user Chrome drivers ,not able to figure out correct driver to identify the test field .

Regards
Bharad

Hi @Bharadwaj.Bhimavarap - When you say that the script fails, is it your output message or is the script failing with some other message?

HI Stefan,

I was able to resolve the issue . Thanks for asking .

Hey @Bharadwaj.Bhimavarap - thanks for letting us know! Could you share your solution? I’m sure it can benefit others in the future who run into similar issues. Thanks in advance.

1 Like

Hi Bhardwaj, i am also getting the same error that is TaskTimes out waiting for element to be visible using : By (xpath-------)
Could you please guide me here how to resolve the error…

Thanks in advance…

@swapnil_meshram - can you leave a small snippet of your script here? Specifically the part where it is failing with that error message?

I’m specifically curious if you are using findElement() or waitForAndFindElement()

The 2nd of which allows you to set a timeout value, with which the script will wait for the element to be interactable up to the point of that timeout, and then fails.

If you are using waitForAndFindElement, you could try increasing the timeout value to see if that allows enough time for that element to be available.

1 Like