Skip to content

Commit 5c75ae1

Browse files
committed
AUT-64: Update Selenium tests to work with Runtime 6.0
1 parent 66a29d3 commit 5c75ae1

File tree

9 files changed

+64
-21
lines changed

9 files changed

+64
-21
lines changed

README.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ Examples for the following WebDriver JS Bindings are included in this project:
1313

1414
## Guidelines
1515

16-
Since all HTML5 applications in the OpenFin environment need to be started with OpenFin API, chromeDriver.get(URL) is not supported. Test code needs to provide the
17-
OpenFinRVM and a HTML5 app configuration to Chromedriver so it can start OpenFin Runtime and the html5 application before tests can be run. config.js
16+
Since all HTML5 applications in the OpenFin environment need to be started with OpenFin API, chromeDriver.get(URL) is not supported. Test code needs to start
17+
OpenFinRVM with a HTML5 app configuration so Chromedriver can connect to OpenFin Runtime and the html5 application before tests can be run. config.js
1818
has the location of OpenFinRVM and the URL for the 'Hello OpenFin' configuration file.
1919

2020
Given there can be multiple applications/windows active in OpenFin Runtime, tests must begin by selecting the targeted window. Each test script has a function that
@@ -30,6 +30,8 @@ In Summary
3030

3131
## Prerequisites for Hello OpenFin demo app
3232

33+
1. Install [Chrome driver](https://sites.google.com/a/chromium.org/chromedriver/)
34+
3335
1. Install Node.js
3436

3537
2. Download/clone this repository and `cd` into it
@@ -55,7 +57,7 @@ In Summary
5557

5658
The following steps will help you run tests:
5759

58-
1. Start chromedriver.exe located in root directory of this project. You can specify --verbose command line argument to get more loggings.
60+
1. Start chromedriver.exe. You can specify --verbose command line argument to get more loggings.
5961

6062
2. Run all tests
6163
```bash
@@ -82,7 +84,9 @@ The example code is written for the Super Calculator Angular demo app that is us
8284
4. Install Protractor
8385
npm install -g protractor
8486

85-
5. Run the example
87+
5. Start chromedriver.exe. You can specify --verbose command line argument to get more loggings.
88+
89+
6. Run the example
8690
```bash
8791
cd test/protractor
8892
protractor config.js

RunOpenFinRVM.bat

+1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ For %%A in ("%filename%") do (
55
Set Folder=%%~dpA
66
)
77

8+
cd %Folder%
89
start %Folder%OpenFinRVM.exe %*

chromedriver.exe

-4.79 MB
Binary file not shown.

test/WD/Mocha/hello-openfin.js

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
*
33
* Example test script for Hello OpenFin App using Mocha, CHAI and Wd (http://admc.io/wd/)
4+
* ChromeDriver must be running before test.
45
*
56
*/
67

@@ -11,6 +12,7 @@ var chaiAsPromised = require("chai-as-promised");
1112
var chai = require('chai');
1213
chai.use(chaiAsPromised);
1314
var should = chai.should();
15+
var spawn = require('child_process').spawn;
1416

1517
var wd = require('wd');
1618
// enables chai assertion chaining
@@ -22,6 +24,13 @@ var config = require("../../config");
2224
describe('Hello OpenFin App testing with WD', function() {
2325
var client;
2426

27+
if (process.platform === 'win32') {
28+
var args = ['/c', config.desiredCapabilities.chromeOptions.binary].concat(config.desiredCapabilities.chromeOptions.args);
29+
spawn('cmd.exe', args);
30+
} else {
31+
spawn(config.desiredCapabilities.chromeOptions.binary, config.desiredCapabilities.chromeOptions.args);
32+
}
33+
2534
this.timeout(config.testTimeout);
2635

2736
before(function() {

test/WebDriverIO/Mocha/hello-openfin.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/**
22
*
33
* Example test script for Hello OpenFin App using Mocha, CHAI and WebdriverIO (http://webdriver.io)
4-
*
5-
* wedriver.io assumes server URL is /wd/hub. So if testing with chromedriver directly, it needs to run as
6-
* chromedriver --url-base=/wd/hub
4+
* ChromeDriver must be running before test.
75
*
86
*/
97

@@ -12,7 +10,8 @@
1210
var should = require('chai').should(),
1311
webdriver = require('webdriverio'),
1412
assert = require("assert"),
15-
config = require("../../config");
13+
config = require("../../config"),
14+
spawn = require('child_process').spawn;
1615

1716

1817
describe('Hello OpenFin App testing with webdriver.io', function() {
@@ -21,6 +20,13 @@ describe('Hello OpenFin App testing with webdriver.io', function() {
2120
this.timeout(config.testTimeout);
2221

2322
before(function() {
23+
if (process.platform === 'win32') {
24+
var args = ['/c', config.desiredCapabilities.chromeOptions.binary].concat(config.desiredCapabilities.chromeOptions.args);
25+
spawn('cmd.exe', args);
26+
} else {
27+
spawn(config.desiredCapabilities.chromeOptions.binary, config.desiredCapabilities.chromeOptions.args);
28+
}
29+
2430
// configure webdriver
2531
var driverOptions = {
2632
desiredCapabilities: config.desiredCapabilities,

test/WebDriverJs/Mocha/hello-openfin.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/**
22
* Example test script for Hello OpenFin app using Mocha, CHAI and selenium-webdriver (https://www.npmjs.org/package/selenium-webdriver)
3+
* ChromeDriver must be running before test.
4+
*
35
*/
46

57

@@ -8,7 +10,8 @@ expect = require('chai').expect;
810
until = require('selenium-webdriver').until;
911
webdriver = require('selenium-webdriver');
1012
chrome = require('selenium-webdriver/chrome');
11-
config = require("../../config");
13+
config = require("../../config"),
14+
spawn = require('child_process').spawn;
1215

1316

1417
describe('Hello OpenFin App testing with selenium-webdriver', function () {
@@ -19,6 +22,13 @@ describe('Hello OpenFin App testing with selenium-webdriver', function () {
1922
this.timeout(config.testTimeout);
2023

2124
before(function () {
25+
if (process.platform === 'win32') {
26+
var args = ['/c', config.desiredCapabilities.chromeOptions.binary].concat(config.desiredCapabilities.chromeOptions.args);
27+
spawn('cmd.exe', args);
28+
} else {
29+
spawn(config.desiredCapabilities.chromeOptions.binary, config.desiredCapabilities.chromeOptions.args);
30+
}
31+
2232
// configure webdriver
2333
var capabilities = webdriver.Capabilities.chrome();
2434
capabilities.set('chromeOptions', config.desiredCapabilities.chromeOptions);

test/config.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ module.exports = (function () {
1111
chromeOptions: {
1212
extensions: [],
1313
debuggerAddress: 'localhost:9090',
14-
binary: "openfin-installer.exe",
14+
//binary: "openfin-installer.exe",
15+
binary: '%LocalAppData%\\OpenFin\\RunOpenFinRVM.bat',
1516
args: ['--config=https://demoappdirectory.openf.in/desktop/config/apps/OpenFin/HelloOpenFin/app.json']
1617
}
1718
},
1819
remoteDriverHost: "localhost",
1920
remoteDriverPort: 9515,
2021
testTimeout: 20000,
21-
expectedRuntimeVersion: "5.44.9.2"
22+
expectedRuntimeVersion: "6.49.11.73"
2223
};
2324

2425
config.remoteDriverUrl = "http://" + config.remoteDriverHost + ":" + config.remoteDriverPort;

test/protractor/config.js

+19-7
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,31 @@
77

88
"use strict";
99

10+
var spawn = require('child_process').spawn;
11+
12+
var openfinBinary = "..\\..\\openfin-installer.exe",
13+
openfinArgs = ['--config=http://test.openf.in/bus/protractor.json'];
14+
1015
exports.config = {
1116
capabilities: {
1217
browserName: 'chrome',
1318
chromeOptions: {
1419
extensions: [],
15-
debuggerAddress: 'localhost:9090',
16-
binary: "../../openfin-installer.exe",
17-
args: ['--config=http://test.openf.in/bus/protractor.json']
20+
debuggerAddress: 'localhost:9090'
1821
}
1922
},
2023
specs: ['hello-openfin.js'],
21-
allScriptsTimeout: 10000,
22-
getPageTimeout: 10000,
23-
chromeDriver: '../../chromedriver.exe',
24-
directConnect: true
24+
allScriptsTimeout: 20000,
25+
getPageTimeout: 20000,
26+
seleniumAddress: 'http://localhost:9515',
27+
directConnect: false,
28+
beforeLaunch: function() {
29+
if (process.platform === 'win32') {
30+
var args = ['/c', openfinBinary].concat(openfinArgs);
31+
console.log(args);
32+
spawn('cmd.exe', args);
33+
} else {
34+
spawn(openfinBinary, openfinArgs);
35+
}
36+
}
2537
}

test/protractor/hello-openfin.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/**
22
*
3-
* Example test script for Super Calculator (http://juliemr.github.io/protractor-demo/index.html) using Protractor
3+
* Example test script for Super Calculator (http://juliemr.github.io/protractor-demo/index.html) using Protractor.
4+
* ChromeDriver must be running before test.
45
*
56
*/
67

7-
88
describe('OpenFin App testing with protractor', function() {
99
"use strict";
1010

@@ -125,7 +125,7 @@ describe('OpenFin App testing with protractor', function() {
125125
expect(driver).toBeDefined();
126126
executeAsyncJavascript("var callback = arguments[arguments.length - 1];" +
127127
"fin.desktop.System.getVersion(function(v) { callback(v); } );").then(function(v) {
128-
expect(v).toEqual("5.44.9.2");
128+
expect(v).toEqual("6.49.11.73");
129129
done();
130130
});
131131
});

0 commit comments

Comments
 (0)