我正在使用
npm’s Selenium Webdriver.
我无法使By.cssSelector工作.其他所有内容:By.tagName,By.id等.
码:
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('xxx@gmail.com') 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)
我收到此错误:
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
我究竟做错了什么?
解决方法
根据
this page,它应该是.css(选择器),而不是.cssSelector(选择器).