forked from SeleniumHQ/selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
WebDriverJs
jleyba edited this page Mar 11, 2016
·
6 revisions
npm install selenium-webdriver
// google_search.js
var webdriver = require('selenium-webdriver'),
By = webdriver.By,
until = webdriver.until;
var driver = new webdriver.Builder()
.forBrowser('firefox')
.build();
driver.get('http://www.google.com/ncr');
driver.findElement(By.name('q')).sendKeys('webdriver');
driver.findElement(By.name('btnG')).click();
driver.wait(until.titleIs('webdriver - Google Search'), 1000);
driver.quit();
node google_search
The JavaScript API documentation is published with each release and available here. Please file bug reports for any missing or unclear information in the API docs.
- For general setup, see the main landing page
- For configuring and creating new WebDriver sessions, use the Builder class
- For browser-specific configuration, refer to the relevant browser sub-modules:
WebDriver's JavaScript API is entirely asynchronous and every command results in a promise. Promise-heavy APIs will be a lot easier to work with once Node supports ES2017's async functions, but in the meantime, WebDriverJS uses a custom promise library with a promise manager called the ControlFlow. The ControlFlow implicitly synchronizes asynchronous actions, making it so you only have to register a promise callback when you want to catch an error or access a return value. Detailed information on the ControlFlow and WebDriverJS's promise library is included with the API docs.