Skip to content

Commit 13995b6

Browse files
committed
Updated setup-protractor script and e2e conf to work on linux and mac correctly
1 parent b83072e commit 13995b6

File tree

3 files changed

+38
-30
lines changed

3 files changed

+38
-30
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"email": "admin@cleverstack.io",
77
"web": "http://cleverstack.io"
88
},
9-
"version": "1.1.0",
9+
"version": "1.1.1",
1010
"collaborators": [
1111
"Richard Gustin <richard@clevertech.biz>",
1212
"Simon W. Jackson <simon@clevertech.biz>",

scripts/setup-protractor.js

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
var async_exec = require('child_process').exec
1+
var async_exec = require( 'child_process' ).exec
22

3-
async_exec('npm install shelljs', function (err, stdout, stderr) {
4-
require('shelljs/global');
3+
async_exec( 'npm install shelljs', function( err, stdout, stderr ) {
4+
require( 'shelljs/global' );
55

66
//detect OS
7-
var os = require('os')
8-
, isWin = /^win32/.test(os.platform())
9-
, isLinux = /^linux/.test(os.platform())
10-
, isMac = /^darwin/.test(os.platform()) || /^freebsd/.test(os.platform());
7+
var os = require( 'os' )
8+
, isWin = /^win32/.test( os.platform() )
9+
, isLinux = /^linux/.test( os.platform() )
10+
, isMac = /^darwin/.test( os.platform() ) || /^freebsd/.test( os.platform() );
1111

12-
echo('About to setup protractor and dependencies.');
13-
echo('It works if it finishes with OK');
12+
echo( 'About to setup protractor and dependencies.' );
13+
echo( 'It works if it finishes with OK' );
1414

1515
//Selenium Standalone Server - required for protractor e2e testing
1616
//Note: Protractor comes with a script to help download and install the standalone server. Run 'webdriver-manager-update': https://github.com/angular/protractor/blob/master/docs/getting-started.md
1717
//https://code.google.com/p/selenium/downloads/list
1818
//Size: ~33mb
19-
echo('Downloading specific Selenium Server jar...');
20-
exec('wget http://selenium.googlecode.com/files/selenium-server-standalone-2.39.0.jar');
21-
exec('mv selenium-server-standalone-2.39.0.jar scripts/selenium-server-standalone-2.39.0.jar');
19+
echo( 'Downloading specific Selenium Server jar...' );
20+
exec( 'wget http://selenium.googlecode.com/files/selenium-server-standalone-2.39.0.jar' );
21+
exec( 'mv selenium-server-standalone-2.39.0.jar scripts/selenium-server-standalone-2.39.0.jar' );
2222

2323
//Chrome driver required to run Chrome on Selenium Server
2424
//Note: download file is based on OS (CLI to handle which one to download)
@@ -32,37 +32,42 @@ async_exec('npm install shelljs', function (err, stdout, stderr) {
3232
} else if (isMac) {
3333
chromedriverLink = 'chromedriver_mac32.zip';
3434
}
35-
echo('Downloading OS specific Chromedriver...');
36-
exec('wget http://chromedriver.storage.googleapis.com/2.8/'+chromedriverLink);
37-
exec('unzip '+chromedriverLink);
38-
exec('mv Chromedriver.exe scripts/Chromedriver.exe');
39-
exec('rm '+chromedriverLink);
35+
echo( 'Downloading OS specific Chromedriver...' );
36+
exec( 'wget http://chromedriver.storage.googleapis.com/2.8/' + chromedriverLink);
37+
exec( 'unzip ' + chromedriverLink );
38+
39+
if ( isWin ) {
40+
exec( 'mv Chromedriver.exe scripts/Chromedriver.exe' );
41+
} else {
42+
exec( 'mv Chromedriver scripts/Chromedriver' );
43+
}
44+
exec( 'rm ' + chromedriverLink );
4045

4146
//PhantomJS driver required to run on Selenium Server
4247
//Note: download file is based on OS (CLI to handle which one to download)
4348
//http://phantomjs.org/download.html
4449
//Size: ~7mb
4550
var phantomjsLink, linkExt;
46-
if (isWin) {
51+
if ( isWin ) {
4752
phantomjsLink = 'phantomjs-1.9.2-windows';
4853
linkExt = '.zip';
49-
} else if (isLinux) {
54+
} else if ( isLinux ) {
5055
phantomjsLink = 'phantomjs-1.9.2-linux-i686';
5156
linkExt = '.tar.bz2';
52-
} else if (isMac) {
57+
} else if ( isMac ) {
5358
phantomjsLink = 'phantomjs-1.9.2-macosx';
5459
linkExt = '.zip';
5560
}
56-
echo('Downloading OS specific Phantomjs...');
57-
exec('wget http://phantomjs.googlecode.com/files/'+phantomjsLink+linkExt);
61+
echo( 'Downloading OS specific Phantomjs...' );
62+
exec( 'wget http://phantomjs.googlecode.com/files/' + phantomjsLink + linkExt );
5863
if (isLinux) {
59-
exec('tar -xjvf '+phantomjsLink+linkExt);
64+
exec( 'tar -xjvf ' + phantomjsLink + linkExt );
6065
} else {
61-
exec('unzip '+phantomjsLink+linkExt);
66+
exec( 'unzip ' + phantomjsLink + linkExt );
6267
}
63-
exec('mv '+phantomjsLink+'/phantomjs.exe scripts/phantomjs.exe');
64-
exec('rm '+phantomjsLink+linkExt);
65-
exec('rm -rf '+phantomjsLink);
68+
exec( 'mv ' + phantomjsLink + '/phantomjs.exe scripts/phantomjs.exe' );
69+
exec( 'rm ' + phantomjsLink + linkExt);
70+
exec( 'rm -rf ' + phantomjsLink );
6671

67-
echo('OK!');
72+
echo( 'OK!' );
6873
});

test-e2e.conf.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
var os = require( 'os' )
2+
, isWin = /^win32/.test( os.platform() );
3+
14
// A reference configuration file.
25
exports.config = {
36
// ----- How to setup Selenium -----
@@ -22,7 +25,7 @@ exports.config = {
2225
// find chromedriver. This will be passed to the selenium jar as
2326
// the system property webdriver.chrome.driver. If null, selenium will
2427
// attempt to find chromedriver using PATH.
25-
chromeDriver: './scripts/Chromedriver.exe',
28+
chromeDriver: isWin ? './scripts/Chromedriver.exe' : './scripts/Chromedriver',
2629
// Additional command line options to pass to selenium. For example,
2730
// if you need to change the browser timeout, use
2831
// seleniumArgs: ['-browserTimeout=60'],

0 commit comments

Comments
 (0)