Skip to content
This repository has been archived by the owner on Feb 9, 2020. It is now read-only.

Protractor tests with multiple chrome profiles #197

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ This document describes how to contribute to Batarang

## Running the tests

1. Install from Source
2. `webdriver-manager update`
3. Run test (using default profile) `npm test`
4. Run test with another profile `gulp profile2`

## Packaging a release

I (@btford) will do this periodically, but I'm adding these instructions here
Expand All @@ -33,4 +38,6 @@ The `panel` directory contains...

## Testing Batarang manually

Run `gulp profile1` in the source code root directory to use the default chrome profile. Edit `profiles/another.profile.js` to point to your own chrome data directory then run `gulp profile2`


23 changes: 23 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ var gulp = require('gulp');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var zip = require('gulp-zip');
var protractor = require("gulp-protractor").protractor;
var webdriver_standalone = require("gulp-protractor").webdriver_standalone;
var webdriver_update = require("gulp-protractor").webdriver_update;

var main = require('./package.json').main;
// TODO: make sure manifest version === package.json version === bower.json version
Expand Down Expand Up @@ -39,4 +42,24 @@ gulp.task('zip', ['package'], function () {
.pipe(gulp.dest('.'));
});

// protractor and selenium
gulp.task('webdriver_update', webdriver_update);
gulp.task('webdriver_standalone', webdriver_standalone);
gulp.task('profile1', ['webdriver_update'], function() {
return gulp.src(["./tests/*.js"])
.pipe(protractor({
configFile: "profiles/protractor.config.js",
args: ['--baseUrl', 'http://127.0.0.1:8000']
}))
.on('error', function(e) { throw e; })
});
gulp.task('profile2', ['webdriver_update'], function() {
return gulp.src(["./tests/*.js"])
.pipe(protractor({
configFile: "profiles/another.config.js",
args: ['--baseUrl', 'http://127.0.0.1:8000']
}))
.on('error', function(e) { throw e; })
});

gulp.task('default', ['browserify']);
9 changes: 9 additions & 0 deletions ignore.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: node_js
node_js:
- "0.10"
before_install:
- npm config set ca ""
#before_script:
# - npm run-script noop
after_success:
- npm run-script coverage
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
"main": "hint.js",
"devDependencies": {
"angular-mocks": "^1.3.6",
"gulp-protractor": "0.0.12",
"gulp-zip": "^2.0.2",
"karma-bro": "^0.6.0",
"karma-chrome-launcher": "^0.1.4",
"karma-jasmine": "^0.1.5",
"karma-sauce-launcher": "^0.2.9",
"karma-jasmine": "^0.1.5"
"protractor": "^1.5.0"
},
"dependencies": {
"angular": "^1.3.6",
Expand All @@ -19,8 +21,9 @@
"vinyl-source-stream": "^0.1.1"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "gulp"
"test": "gulp profile1",
"build": "gulp",
"coverage": "echo Coverage report not implemented && exit 0"
},
"repository": {
"type": "git",
Expand Down
24 changes: 24 additions & 0 deletions profiles/another.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// An example configuration file.
// https://raw.github.com/angular/protractor/master/example/conf.js
exports.config = {
// The address of a running selenium server.
// if you get a permissions error, you can try this (warning: unsecure)
// chmod -R nobody:<group> /usr/local/lib/node_modules/protractor/selenium
seleniumServerJar: '../node_modules/protractor/selenium/selenium-server-standalone-2.44.0.jar', // Make use you check the version in the folder
//seleniumAddress: 'http://localhost:4444/wd/hub',
// Capabilities to be passed to the webdriver instance.
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: [
'--user-data-dir=/home/jason/.config/chromium'
]
}
},

// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
},
};
19 changes: 19 additions & 0 deletions profiles/protractor.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// An example configuration file.
// https://raw.github.com/angular/protractor/master/example/conf.js
exports.config = {
// The address of a running selenium server.
// if you get a permissions error, you can try this (warning: unsecure)
// chmod -R nobody:<group> /usr/local/lib/node_modules/protractor/selenium
seleniumServerJar: '../node_modules/protractor/selenium/selenium-server-standalone-2.44.0.jar', // Make use you check the version in the folder
//seleniumAddress: 'http://localhost:4444/wd/hub',
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},

// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
},
};
38 changes: 38 additions & 0 deletions tests/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// example test
describe('angularjs homepage', function() {
it('should greet the named user', function() {
browser.get('http://www.angularjs.org');

element(by.model('yourName')).sendKeys('Julie');

var greeting = element(by.binding('yourName'));

expect(greeting.getText()).toEqual('Hello Julie!');
});

describe('todo list', function() {
var todoList;

beforeEach(function() {
browser.get('http://www.angularjs.org');

todoList = element.all(by.repeater('todo in todos'));
});

it('should list todos', function() {
expect(todoList.count()).toEqual(2);
expect(todoList.get(1).getText()).toEqual('build an angular app');
});

it('should add a todo', function() {
var addTodo = element(by.model('todoText'));
var addButton = element(by.css('[value="add"]'));

addTodo.sendKeys('write a protractor test');
addButton.click();

expect(todoList.count()).toEqual(3);
expect(todoList.get(2).getText()).toEqual('write a protractor test');
});
});
});