Skip to content

Instantly share code, notes, and snippets.

@mitsuruog
Last active December 31, 2015 20:19
Show Gist options
  • Save mitsuruog/8039638 to your computer and use it in GitHub Desktop.
Save mitsuruog/8039638 to your computer and use it in GitHub Desktop.
soda sample code that selenium node driver.
/**
* Module dependencies.
*/
var soda = require('soda'),
assert = require('assert');
var browser = soda.createClient({
host: 'localhost',
port: 4444,
url: 'https://www.google.co.jp/',
browser: 'firefox'
});
browser.on('command', function(cmd, args) {
console.log(' \x1b[33m%s\x1b[0m: %s', cmd, args.join(', '));
});
browser
.chain
.session()
.open('/')
.type('q', 'Hello World')
.click('btnK')
.waitForTextPresent('Hello World')
.getTitle(function(title) {
assert.ok(~title.indexOf('Hello World'), 'Title did not include the query: ' + title);
})
.end(function(err) {
browser.testComplete(function() {
console.log('done');
if (err) throw err;
});
});
mitsuruog:soda-sample mitsuruog$ node google.js
getNewBrowserSession: *firefox, https://www.google.co.jp/
http.createClient is deprecated. Use `http.request` instead.
open: /
type: q, Hello World
click: btnK
waitForTextPresent: Hello World
getTitle:
testComplete:
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment