Skip to content

Instantly share code, notes, and snippets.

@bernii
Created February 26, 2013 23:03
Show Gist options
  • Save bernii/5043192 to your computer and use it in GitHub Desktop.
Save bernii/5043192 to your computer and use it in GitHub Desktop.
WD.js with OSX - keys fails - workaround
var wd = require('wd')
, Q = require('q')
, request = require('request')
, assert = require('assert')
, host = "ondemand.saucelabs.com"
, port = 80
, username = YOUR_USERNAME
, accessKey = YOUR_ACCESS_KEY
// using promisified version of webdriver
, browser = wd.promiseRemote(host, port, username, accessKey);
browser.on('status', function(info){
console.log('\x1b[36m%s\x1b[0m', info);
});
browser.on('command', function(meth, path, data){
console.log(' > \x1b[33m%s\x1b[0m: %s', meth, path, data || '');
});
// test case
browser.init({
browserName: 'safari',
platform: 'Mac 10.8',
version: '6',
tags: ["examples"],
name: "Helpdesk - Mac OSX",
build: "helpdesk-test"
}).then(function () {
// using our handly guinea pig
return browser.get("http://saucelabs.com/test/guinea-pig");
}).then(function () {
return browser.elementById('comments');
}).then(function (elem) {
// normally this should work...
// return elem.click();
// // or
// // return browser.clickElement(elem);
// }).then(function () {
// return browser.keys('hello');
// workaround here !!!
return browser.type(elem, 'hello');
}).then(function (body) {
return browser.eval("document.getElementById('comments').value");
}).then(function (value) {
// double checking ;-)
assert.equal(value, 'hello');
}).fin(function () {
browser.quit();
}).done();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment