Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
local.log
48 changes: 27 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,41 @@
nemo-browserstack
=========
# Nemo-browserstack

This repository provides information and helpful tweaks to run your Nemo tests on the BrowserStack selenium cloud infrastructure.
Run [Nemo](https://nemo.js.org) scripts on BrowserStack.

###Setup
Install npm
Install dependencies using `npm install`.
### Clone the repo

`git clone https://github.com/browserstack/nemo-browserstack.git`

###Configuration
Set browserstack environment variables as in the below shell example
### Install dependencies

```shell
$ export BSTK_USER=myusername1
$ export BSTK_KEY=aa4235ssdda
$ export BSTK_BROWSER=chrome
$ export BSTK_VERSION=22.0
```
Navigate to appropriate directory for testing and then install the dependencies by running

Run node command with NODE_ENV=browserstack to engage the `browserstack.json` override
`npm install`

```shell
$ NODE_ENV=browserstack node nemo.js
```
### BrowserStack Authentication

###Run tests
To run the tests, execute: `node nemo.js`
Export the environment variables for the username and access key of your BrowserStack account.
These can be found on the automate accounts page on [BrowserStack](https://www.browserstack.com/accounts/automate)

`export BROWSERSTACK_USERNAME=<browserstack-username>`

`export BROWSERSTACK_KEY=<browserstack-access-key>`

### Run the tests

- To start a single test run: `npm test`
- To start local tests run: `npm run test_local`


-----

#### Further Reading

###Further Reading
- [Nemo](https://nemo.js.org)
- [BrowserStack documentation for Automate](https://www.browserstack.com/automate/node)

#### How to specify the capabilities

The [Code Generator](https://www.browserstack.com/automate/node#setting-os-and-browser) can come in very handy when specifying the capabilities especially for mobile devices.

Happy Testing!
13 changes: 0 additions & 13 deletions config/browserstack.json

This file was deleted.

16 changes: 12 additions & 4 deletions config/config.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
{
"driver": {
"builders": {
"usingServer": [ "http://hub.browserstack.com/wd/hub" ],
"withCapabilities": [{
"browserName": "firefox"
"browserstack.user": "env:BROWSERSTACK_USERNAME",
"browserstack.key": "env:BROWSERSTACK_ACCESS_KEY",
"build": "Nemo Sample Tests",
"name": "Nemo sample test",
"os": "OS X",
"os_version": "El Capitan",
"browserName": "chrome",
"browser_version": "48"
}]
}
},
"plugins": {
"view": {
"module": "nemo-view",
"arguments": ["path:locator"]
"arguments": [ "path:locator" ]
}
},
"data": {
"baseUrl": "https://www.paypal.com"
"baseUrl": "https://www.google.com"
}
}
}
27 changes: 27 additions & 0 deletions config/local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"driver": {
"builders": {
"usingServer": [ "http://hub.browserstack.com/wd/hub" ],
"withCapabilities": [{
"browserstack.user": "env:BROWSERSTACK_USERNAME",
"browserstack.key": "env:BROWSERSTACK_ACCESS_KEY",
"browserstack.local": true,
"build": "Nemo Sample Tests",
"name": "Nemo local tests",
"os": "Windows",
"os_version": "10",
"browserName": "firefox",
"browser_version": "45"
}]
},
"plugins": {
"view": {
"module": "nemo-view",
"arguments": [ "path:locator" ]
}
},
"data": {
"baseUrl": "https://www.google.com"
}
}
}
16 changes: 8 additions & 8 deletions nemo.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
var Nemo = require('nemo');

var nemo = Nemo(__dirname, function (err) {
//always check for errors!
if (!!err) {
return console.error('Error during Nemo setup', err);
}
nemo.driver.getCapabilities().
then(function (caps) {
console.log("Nemo successfully launched", caps.caps_.browserName);
});

nemo.driver.get(nemo.data.baseUrl);
nemo.view._waitVisible('#header-buttons #ul-btn').click();
nemo.view._waitVisible('#createAccount').click();
nemo.view._waitVisible('#personalSignUpForm').click();
nemo.view._waitVisible('#email').then(function () {
console.log('loaded the signup form');
nemo.driver.manage().window().maximize();
nemo.view._waitVisible('name:q');
nemo.view._find('name:q').sendKeys('BrowserStack');
nemo.driver.getTitle().then(function (title) {
console.log('The page title is ' + title);
nemo.driver.quit();
}, function (err) {
console.log('a funny thing happened on the way to the signup form');
console.error(err);
nemo.driver.quit();
});
});
});
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
{
"name": "nemo-browserstack-example",
"version": "1.0.0",
"description": "Nemo and Browserstack integration example",
"main": "nemo.js",
"name": "nemo-browserstack",
"version": "0.1.0",
"description": "An example module to run protractor tests on browserstack",
"scripts": {
"test": "node nemo.js"
"test": "node nemo.js",
"test_local": "node scripts/test_local.js"
},
"keywords": [
"Nemo",
"selenium-webdriver",
"browserstack"
],
"author": "Matt Edelman <mattedelman@gmail.com>",
"author": "BrowserStack",
"dependencies": {
"browserstack-local": "^0.1.0",
"nemo": "^1.0.6",
"nemo-view": "^1.2.0"
}
Expand Down
30 changes: 30 additions & 0 deletions scripts/test_local.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
var child_process = require('child_process');
var browserstack = require('browserstack-local');

var bs_local = new browserstack.Local();
var bs_local_args = { 'key': process.env.BROWSERSTACK_ACCESS_KEY, 'forcelocal': true };

bs_local.start(bs_local_args, function(error) {
if (error) {
console.log(error);
} else {
console.log('Connected. Now testing...');

child_env = process.env;
child_env["NODE_ENV"] = "local";
child = child_process.execSync('node nemo.js', { stdio: [ 0, 0, 0 ], env: child_env });

if(child) {
child.on('exit', function() {
if(bs_local) {
bs_local.stop(function() {});
}

exit(0);
});
}
}
if(bs_local) {
bs_local.stop(function() {});
}
});