|
| 1 | +var username = process.env.BROWSERSTACK_USERNAME || "BROWSERSTACK_USERNAME"; |
| 2 | +var accessKey = process.env.BROWSERSTACK_ACCESS_KEY || "BROWSERSTACK_ACCESS_KEY"; |
| 3 | + |
| 4 | +require('colors'); |
| 5 | +var chai = require('chai'); |
| 6 | +var wd = require('wd'); |
| 7 | + |
| 8 | +chai.should(); |
| 9 | + |
| 10 | +var browser = wd.remote("hub.browserstack.com", 80, username, accessKey); |
| 11 | + |
| 12 | +// optional extra logging |
| 13 | +browser.on('status', function(info) { |
| 14 | + console.log(info.cyan); |
| 15 | +}); |
| 16 | +browser.on('command', function(eventType, command, response) { |
| 17 | + console.log(' > ' + eventType.cyan, command, (response || '').grey); |
| 18 | +}); |
| 19 | +browser.on('http', function(meth, path, data) { |
| 20 | + console.log(' > ' + meth.magenta, path, (data || '').grey); |
| 21 | +}); |
| 22 | + |
| 23 | +var desired = { |
| 24 | + os: 'OS X', |
| 25 | + os_version: 'El Capitan', |
| 26 | + browser: 'chrome', |
| 27 | + browser_version: '', |
| 28 | + project: "examples", |
| 29 | + name: "This is an example local test", |
| 30 | + build: "WD BrowserStack Sample Test", |
| 31 | + "browserstack.local": true |
| 32 | +}; |
| 33 | + |
| 34 | +browser.init(desired, function() { |
| 35 | + browser.get("http://admc.io/wd/test-pages/guinea-pig.html", function() { |
| 36 | + browser.title(function(err, title) { |
| 37 | + title.should.include('WD'); |
| 38 | + browser.elementById('i am a link', function(err, el) { |
| 39 | + browser.clickElement(el, function() { |
| 40 | + browser.eval("window.location.href", function(err, href) { |
| 41 | + href.should.include('guinea-pig2'); |
| 42 | + browser.quit(); |
| 43 | + }); |
| 44 | + }); |
| 45 | + }); |
| 46 | + }); |
| 47 | + }); |
| 48 | +}); |
0 commit comments