Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: By.cssSelector is not a function

I'm using npm's Selenium Webdriver.

I can't make the By.cssSelector work. Everything else does: By.tagName, By.id, etc.

Code:

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

var driver = new webdriver.Builder()
    .forBrowser('firefox')
    .build()

driver.get('http://www.facebook.com/')
driver.findElement(By.name('email')).sendKeys('[email protected]')
driver.findElement(By.name('pass')).sendKeys('xxx')
driver.findElement(By.id('pass')).submit()

driver.findElement(By.name('xhpc_message')).sendKeys('https://www.youtube.com/watch?v=UfvZvd-kjyo')

driver.wait(function () {
  return driver.isElementPresent(driver.findElement(By.cssSelector(".uiScaledImageContainer")))
}, 10000)

I get this error:

alex@alex-K43U:~/node/sapp$ node app.js /home/alex/node/sapp/node_modules/selenium-webdriver/lib/goog/async/nexttick.js:41 goog.global.setTimeout(function() { throw exception; }, 0); ^

TypeError: By.cssSelector is not a function

What am I doing wrong?

like image 923
alexchenco Avatar asked Dec 21 '15 13:12

alexchenco


1 Answers

According to this page it should be .css(selector), rather than .cssSelector(selector).

like image 127
Rho Avatar answered Sep 26 '22 21:09

Rho