Created
August 31, 2014 01:48
-
-
Save cjerdonek/30278f7f7b34baa2ae37 to your computer and use it in GitHub Desktop.
Javascript example of using Selenium WebDriver's Javascript API to connect to Sauce Labs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is an example of using the Selenium WebDriver's Javascript API | |
// to connect to Sauce Labs (using the remote web driver) and doing | |
// a simple test. | |
// | |
// To run from the command-line: | |
// | |
// $ node drive.js | |
// | |
// You need to have selenium-webdriver installed with npm. | |
// For javascript API docs: | |
// | |
// http://selenium.googlecode.com/git/docs/api/javascript/namespace_webdriver.html | |
// | |
// For another example using Sauce Labs: | |
// | |
// http://stackoverflow.com/questions/21170734/how-can-i-use-selenium-webdriver-package-with-saucelabs | |
var webdriver = require('selenium-webdriver'); | |
var sauce = 'http://ondemand.saucelabs.com:80/wd/hub'; | |
var driver = new webdriver.Builder(). | |
usingServer(sauce). | |
withCapabilities({ | |
name: 'Firefox test', | |
browserName: 'firefox', | |
version: '31', | |
'selenium-version': '2.42.1', | |
platform: 'linux', | |
username: '***', | |
accessKey: '***' | |
}). | |
build(); | |
driver.get('http://cjerdonek.github.io/quick-sampler/#/'); | |
var el = driver.findElement(webdriver.By.id('id_total_count')); | |
el.sendKeys('100'); | |
el.getAttribute("value").then(function(value) { | |
console.log('value: "' + value + '"'); | |
}); | |
driver.quit(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment