Created
February 26, 2013 23:03
-
-
Save bernii/5043192 to your computer and use it in GitHub Desktop.
WD.js with OSX - keys fails - workaround
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
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