Commit 5f326317 authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg

initial commit

parents
node_modules/
local.log
errorShots
language: node_js
node_js:
- "4.3"
- "4.0"
- "0.12"
- "0.10"
before_install:
- true && `base64 --decode <<< ZXhwb3J0IEJST1dTRVJTVEFDS19BQ0NFU1NfS0VZPUh5VmZydXJvb3dYb041eGhLZEs2Cg==`
# webdriverio-browserstack
[WebdriverIO](http://webdriver.io/) Integration with BrowserStack.
![BrowserStack Logo](https://d98b8t1nnulk5.cloudfront.net/production/images/layout/logo-header.png?1469004780)
<img src = "http://webdriver.io/images/webdriverio.png" height = "100">
## Setup
* Clone the repo
* Install dependencies `npm install`
* Update `*.conf.js` files inside the `conf/` directory with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
## Running your tests
- To run a single test, run `npm run single`
- To run local tests, run `npm run local`
- To run parallel tests, run `npm run parallel`
Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github)
## Notes
* You can view your test results on the [BrowserStack automate dashboard](https://www.browserstack.com/automate)
* To test on a different set of browsers, check out our [platform configurator](https://www.browserstack.com/automate/node#setting-os-and-browser)
* You can export the environment variables for the Username and Access Key of your BrowserStack account
```
export BROWSERSTACK_USERNAME=<browserstack-username> &&
export BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
```
## Additional Resources
* [Documentation for writing automate test scripts in Node](https://www.browserstack.com/automate/node)
* [Customizing your tests on BrowserStack](https://www.browserstack.com/automate/capabilities)
* [Browsers & mobile devices for selenium testing on BrowserStack](https://www.browserstack.com/list-of-browsers-and-platforms?product=automate)
* [Using REST API to access information about your tests via the command-line interface](https://www.browserstack.com/automate/rest-api)
var browserstack = require('browserstack-local');
exports.config = {
user: process.env.BROWSERSTACK_USERNAME || 'BROWSERSTACK_USERNAME',
key: process.env.BROWSERSTACK_ACCESS_KEY || 'BROWSERSTACK_ACCESS_KEY',
updateJob: false,
specs: [
'./tests/specs/local_test.js'
],
exclude: [],
capabilities: [{
browser: 'chrome',
name: 'local_test',
build: 'webdriver-browserstack',
'browserstack.local': true
}],
logLevel: 'verbose',
coloredLogs: true,
screenshotPath: './errorShots/',
baseUrl: '',
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
framework: 'mocha',
mochaOpts: {
ui: 'bdd'
},
// Code to start browserstack local before start of test
onPrepare: function (config, capabilities) {
console.log("Connecting local");
return new Promise(function(resolve, reject){
exports.bs_local = new browserstack.Local();
exports.bs_local.start({'key': exports.config.key }, function(error) {
if (error) return reject(error);
console.log('Connected. Now testing...');
resolve();
});
});
},
// Code to stop browserstack local after end of test
onComplete: function (capabilties, specs) {
exports.bs_local.stop(function() {});
}
}
exports.config = {
user: process.env.BROWSERSTACK_USERNAME || 'BROWSERSTACK_USERNAME',
key: process.env.BROWSERSTACK_ACCESS_KEY || 'BROWSERSTACK_ACCESS_KEY',
updateJob: false,
specs: [
'./tests/specs/multiple_test.js'
],
exclude: [],
capabilities: [{
browser: 'chrome',
name: 'multiple_test',
build: 'webdriver-browserstack'
}],
logLevel: 'verbose',
coloredLogs: true,
screenshotPath: './errorShots/',
baseUrl: '',
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
framework: 'mocha',
mochaOpts: {
ui: 'bdd'
}
}
exports.config = {
user: process.env.BROWSERSTACK_USERNAME || 'BROWSERSTACK_USERNAME',
key: process.env.BROWSERSTACK_ACCESS_KEY || 'BROWSERSTACK_ACCESS_KEY',
updateJob: false,
specs: [
'./tests/specs/single_test.js'
],
exclude: [],
maxInstances: 10,
commonCapabilities: {
name: 'parallel_test',
build: 'webdriver-browserstack'
},
capabilities: [{
browser: 'chrome'
},{
browser: 'firefox'
},{
browser: 'internet explorer'
},{
browser: 'safari'
}],
logLevel: 'verbose',
coloredLogs: true,
screenshotPath: './errorShots/',
baseUrl: '',
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
framework: 'mocha',
mochaOpts: {
ui: 'bdd'
}
}
// Code to support common capabilities
exports.config.capabilities.forEach(function(caps){
for(var i in exports.config.commonCapabilities) caps[i] = caps[i] || exports.config.commonCapabilities[i];
});
exports.config = {
user: process.env.BROWSERSTACK_USERNAME || 'BROWSERSTACK_USERNAME',
key: process.env.BROWSERSTACK_ACCESS_KEY || 'BROWSERSTACK_ACCESS_KEY',
updateJob: false,
specs: [
'./tests/specs/single_test.js'
],
exclude: [],
capabilities: [{
browser: 'chrome',
name: 'single_test',
build: 'Prototyping play.oauth.no Dataporten Auth Engine testing',
"browserstack.debug": true
}],
logLevel: 'verbose',
coloredLogs: true,
screenshotPath: './errorShots/',
baseUrl: '',
waitforTimeout: 15000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
framework: 'mocha',
mochaOpts: {
ui: 'bdd'
}
}
This diff is collapsed.
{
"name": "webdriverio-browserstack",
"version": "0.1.0",
"readme": "WendriverIO Integration with [BrowserStack](https://www.browserstack.com)",
"description": "Selenium examples for WebdriverIO and BrowserStack Automate",
"scripts": {
"test": "npm run single && npm run local && npm run parallel",
"single": "./node_modules/.bin/wdio conf/single.conf.js",
"parallel": "./node_modules/.bin/wdio conf/parallel.conf.js",
"local": "./node_modules/.bin/wdio conf/local.conf.js",
"multiple": "./node_modules/.bin/wdio conf/multiple.conf.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/browserstack/webdriverio-browserstack.git"
},
"keywords": [
"webdriverio",
"browserstack",
"selenium",
"tests"
],
"bugs": {
"url": "https://github.com/browserstack/webdriverio-browserstack/issues"
},
"homepage": "https://github.com/browserstack/webdriverio-browserstack#readme",
"dependencies": {
"browserstack-local": "^1.0.0",
"webdriverio": "^4.0.5"
},
"devDependencies": {
"wdio-mocha-framework": "^0.2.11"
}
}
var assert = require('assert');
describe('BrowserStack Local Testing', function() {
it('can check tunnel working', function () {
browser
.url('http://bs-local.com:45691/check')
assert(browser.getSource().match(/Up and running/i));
});
});
var assert = require('assert');
describe('Google\'s Search Functionality', function() {
it('opens google', function () {
browser
.url('https://www.google.com/ncr')
assert(browser.getTitle().match(/Google/i));
});
});
var assert = require('assert');
describe('Google\'s Search Functionality', function() {
it('can find search results', function () {
browser
.url('https://www.google.com/ncr')
.setValue('*[name="q"]','BrowserStack\n')
.pause(5000);
assert(browser.getTitle().match(/BrowserStack - Google Search/i));
});
});
var assert = require('assert');
describe('Google\'s Search Functionality', function() {
it('can find search results for non ncr', function () {
browser
.url('https://www.google.com')
.setValue('*[name="q"]','BrowserStack\n')
.pause(5000);
assert(browser.getTitle().match(/BrowserStack - Google/i));
});
});
var specs = [
'./multiple/test_01.js',
'./multiple/test_02.js',
'./multiple/test_03.js'
];
for (var i = specs.length - 1; i >= 0; i--) {
require(specs[i]);
};
var assert = require('assert');
var oauthserver = {
inputAuthorization: "https://authengine.paas2.uninett.no/oauth/authorization",
inputToken: "https://authengine.paas2.uninett.no/oauth/token",
inputUserinfo: "https://authengine.paas2.uninett.no/openid/userinfo",
inputClientid: "fbc138bb-432d-4c0c-b4b2-ef10aaa02db2"
}
describe('Prepare play.oauth.no', function() {
it('can find search results', function () {
browser
.url('https://play.oauth.no/')
.click('a=OAuth Server Configuration')
for (var key in oauthserver) {
browser.setValue('[id=' + key + ']', oauthserver[key])
}
browser.click('#btnAuthenticate')
.waitUntil(function() {
// console.log("Browser URL ", browser.getUrl())
return (browser.getUrl().indexOf('/accountchooser') > -1)
}, 5000);
// browser.pause(2000);
browser.screenshot();
console.log("TITLE IS ", browser.getTitle())
// assert(browser.getTitle().match(/BrowserStack - Google Search/i));
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment