Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium webdriver TypeError: element.isDisplayed is not a function

I have an error:

TypeError: element.isDisplayed is not a function

When executing the following code:

var webdriver = require('selenium-webdriver'),
  By = webdriver.By,
  until = webdriver.until;

var driver = new webdriver.Builder()
  .forBrowser('chrome')
  .usingServer('http://localhost:4444/wd/hub')
  .build();

driver.get('https://www.test.com');
driver.wait(until.elementIsVisible(By.id('someButton')), 5000);

This is on my local machine using https://www.npmjs.com/package/selenium-webdriver and kicking off a server with:

webdriver-manager start

My spec:

Mac oSX Sierra 10.12.6

Chrome v60

The site I'm developing on is using AJAX to load pages to this could make a difference?

like image 584
Christopher Grigg Avatar asked Dec 14 '22 21:12

Christopher Grigg


1 Answers

Problem

until.elementIsVisible(..) needs a WebElement an not a Locator as a Argument.

Solution

Writing

driver.wait(until.elementIsVisible(driver.findElement(By.id('someButton'))), 5000);

instead of

driver.wait(until.elementIsVisible(By.id('someButton')), 5000);

will solve the Problem.

More Infos

http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/until.html https://github.com/SeleniumHQ/selenium/issues/2935

like image 180
powerpete Avatar answered Dec 18 '22 10:12

powerpete