-
Notifications
You must be signed in to change notification settings - Fork 402
/
chrome.js
39 lines (35 loc) · 1.01 KB
/
chrome.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require('colors');
var chai = require('chai');
chai.should();
var wd;
try {
wd = require('wd');
} catch( err ) {
wd = require('../../lib/main');
}
var browser = wd.remote();
// optional extra logging
browser.on('status', function(info) {
console.log(info.cyan);
});
browser.on('command', function(eventType, command, response) {
console.log(' > ' + eventType.cyan, command, (response || '').grey);
});
browser.on('http', function(meth, path, data) {
console.log(' > ' + meth.magenta, path, (data || '').grey);
});
browser.init({browserName:'chrome'}, function() {
browser.get("http://admc.io/wd/test-pages/guinea-pig.html", function() {
browser.title(function(err, title) {
title.should.include('WD');
browser.elementById('i am a link', function(err, el) {
browser.clickElement(el, function() {
browser.eval("window.location.href", function(err, href) {
href.should.include('guinea-pig2');
browser.quit();
});
});
});
});
});
});