I am getting - ElementNotVisibleError: element not visible

ElementNotVisibleError: element not visible
(Session info: chrome=60.0.3112.101)
(Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Linux 3.13.0-123-generic x86_64)
at WebDriverError (/opt/runtimes/3.0.0/node_modules/selenium-webdriver/lib/error.js:27:5)
at ElementNotVisibleError (/opt/runtimes/3.0.0/node_modules/selenium-webdriver/lib/error.js:61:5)
at Object.checkLegacyResponse (/opt/runtimes/3.0.0/node_modules/selenium-webdriver/lib/error.js:529:15)
at parseHttpResponse (/opt/runtimes/3.0.0/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/opt/runtimes/3.0.0/node_modules/selenium-webdriver/lib/http.js:441:30)
at process.tickCallback (internal/process/next_tick.js:109:7)
From: Task: WebElement.sendKeys()
at Driver.schedule (/opt/runtimes/3.0.0/node_modules/selenium-webdriver/lib/webdriver.js:807:17)
at WebElementPromise.schedule
(/opt/runtimes/3.0.0/node_modules/selenium-webdriver/lib/webdriver.js:2015:25)
at WebElementPromise.sendKeys (/opt/runtimes/3.0.0/node_modules/selenium-webdriver/lib/webdriver.js:2178:19)
at eval (eval at (/opt/runtimes/3.0.0/modules/synthetics-runner/lib/job-resource/index.js:76:19), :23:63)
at ManagedPromise.invokeCallback_ (/opt/runtimes/3.0.0/node_modules/selenium-webdriver/lib/promise.js:1384:14)
at TaskQueue.execute_ (/opt/runtimes/3.0.0/node_modules/selenium-webdriver/lib/promise.js:3092:14)
at TaskQueue.executeNext_ (/opt/runtimes/3.0.0/node_modules/selenium-webdriver/lib/promise.js:3075:27)
at asyncRun (/opt/runtimes/3.0.0/node_modules/selenium-webdriver/lib/promise.js:2935:27)
at /opt/runtimes/3.0.0/node_modules/selenium-webdriver/lib/promise.js:676:7
at process._tickCallback (internal/process/next_tick.js:109:7)

Hi @ssirsikar - If you look at the browser screenshot on the result of the synthetic, you will see the viewable area of the page. The error usually occurs when the element is outside of the viewable area. The script below will ensure that the element is viewable and ready to click. If that doesn’t work then the element has not been loaded on the page at all.

  var currentElement;
  return $browser.findElement($driver.By.preferedMethod(), 1000)
    .then(function(el){
    currentElement = el;
    el.getLocation()
    .then(function(location) {
      $browser.manage().window().setPosition(0, location.y);
      currentElement.click();
    });
  });
3 Likes

Thanks for jumping in @stefan_garnham!

Did that proposed solution work for you, @ssirsikar? Let us know! :blush:

Hello,

preferedMethod

is not working in my script it says that it does not exist on type typeof By. is there another word that could be used here?

Yes, it will be one of these element locator methods

}).then(function(){

return $browser.waitForAndFindElement($driver.By.xpath("//*[contains(@aria-label,‘item-8’)]"), timeout);

return $browser.wait(function() {
return $browser.waitForAndFindElement($driver.By.xpath("//span[contains(@class,‘glyphicon glyphicon-actionbar glyphicon-ok-circle disabled-when-selected’)]")).then(function(element) {
//return element.isEnabled();
return element.elementIsVisible($driver.By.xpath("//span[contains(@class,‘glyphicon glyphicon-actionbar glyphicon-ok-circle disabled-when-selected’)]"));
});
}, timeout);
}).then(function (elloc) {
elloc.getLocation().then(function(location) {
$browser.manage().window().setPosition(0,location.y );
});

that’s my code The element is visible in the screen shot and i need to click on that button listed in the xpath

}).then(function(){

return $browser.waitForAndFindElement($driver.By.xpath("//*[contains(@aria-label,‘item-8’)]"), timeout);

return $browser.wait(function() {
return $browser.waitForAndFindElement($driver.By.xpath("//span[contains(@class,‘glyphicon glyphicon-actionbar glyphicon-ok-circle disabled-when-selected’)]")).then(function(element) {
//return element.isEnabled();
return element.elementIsVisible($driver.By.xpath("//span[contains(@class,‘glyphicon glyphicon-actionbar glyphicon-ok-circle disabled-when-selected’)]"));
});
}, timeout);
}).then(function (elloc) {
elloc.getLocation().then(function(location) {
$browser.manage().window().setPosition(0,location.y );
});

that’s my code The element is visible in the screen shot and i need to click on that button listed in the xpath
[/quote]

@stefan_garnham

image

Hi @james.cooper - I have found xpath selectors to be rather slow compared to the other methods so I am not up to speed on its usage. Have you tried $driver.By.className(‘glyphicon glyphicon-actionbar glyphicon-ok-circle disabled-when-selected’)?

1 Like

Let us know how it goes using a different locator method @James.cooper :smiley:

Hey Thank you. It didn’t work, i tried to mix it up with css, and id too.

I think you will need someone from New Relic to assist now. @RyanVeitch - can you arrange this please?

1 Like

return $browser.waitForAndFindElement($driver.By.xpath("//div[‘glyphicon-action-bar glyphicon-ok-circle’]"),timeout);
}).then(function(element){
return element.click(); is my new modification and it passes but nothing is clicked. Thank you! I will wait for Ryan’s response

Hey @James.cooper - Can I get a link to your monitor? I’d like to see exact behaviour when the script is validated.

(Note only New Relic, and users in your account will have access to that link)

2 Likes