Skip to content

Instantly share code, notes, and snippets.

@amitaibu
Last active August 29, 2015 14:16
Show Gist options
  • Save amitaibu/e4288b2939bcc155b152 to your computer and use it in GitHub Desktop.
Save amitaibu/e4288b2939bcc155b152 to your computer and use it in GitHub Desktop.
node_modules

Installation

npm install -g mocha
npm install

BrowserStack integration

Use the BrowserStack credentials by exoprting your variables:

export BROWSERSTACK_USERNAME=<YOUR USER NAME>
export BROWSERSTACK_KEY=<YOUR SECRET KEY>
{
"devDependencies": {
"webdrivercss": "^1.0.6",
"webdriverio": "^2.4.5"
}
}
var WebdriverIO = require('webdriverio');
var WebdriverCSS = require('webdrivercss');
describe('my webdriverio tests', function(){
this.timeout(99999999);
var client = {};
var caps;
caps = {
'browserName': 'chrome'
};
before(function(done){
if (process.env.BROWSERSTACK_USERNAME) {
caps['browserstack.user'] = process.env.BROWSERSTACK_USERNAME;
caps['browserstack.key'] = process.env.BROWSERSTACK_KEY;
caps['browserstack.debug'] = 'true';
client = WebdriverIO.remote({
desiredCapabilities: caps,
host: 'hub.browserstack.com',
port: 80
});
}
else {
client = WebdriverIO.remote({ desiredCapabilities: {browserName: 'phantomjs'} });
}
client
.init(done)
.setViewportSize({
width: 1024,
height: 768
});
WebdriverCSS.init(client);
});
it('Google test',function(done) {
client
.url('https://www.google.com/?gfe_rd=cr&ei=tMH8VONqy4fxB5rygZgD&gws_rd=ssl,cr&fg=1')
.webdrivercss('chrome', {name: 'google-homepage'})
.call(done);
});
it('GitHub test',function(done) {
client
.url('http://amitaibu.com')
.webdrivercss('chrome', {name: 'amitaibu-homepage'})
.call(done);
});
after(function(done) {
client.end(done);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment