Saswat Saswat - 5 months ago 14
Node.js Question

How to use PhantomJS for opening a sitelink using Selenium Webdriver?

I am trying to use headless Webkit of PhantomJS to open google.com through Selenium Webdriver but when I execute the following code system, some error occurs. Have I missed something?

var webdriver = require('selenium-webdriver');
var By = require('selenium-webdriver').By;
var driver = new webdriver.Builder()
.withCapabilities(webdriver.Capabilities.phantomjs())
.build();
var baseUrl = 'http://google.com/';
driver.get(baseUrl);
driver.findElement(By.name('q')).sendKeys('webdriver');
driver.findElement(By.name('btnG')).click();
driver.wait(until.titleIs('webdriver - Google Search'), 1000);
driver.quit();


But I am getting a new error:

enter image description here

Answer

Require until first:

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