Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b49835c

Browse filesBrowse files
Support BrowserStack in UI testing
1 parent ee6f6ae commit b49835c
Copy full SHA for b49835c

4 files changed

+101-23Lines changed: 101 additions & 23 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Gruntfile.js‎

Copy file name to clipboardExpand all lines: Gruntfile.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ module.exports = function(grunt) {
2626
nodemonArgs.push(flowFile);
2727
}
2828

29+
var browserstack = grunt.option('browserstack');
30+
if (browserstack) {
31+
process.env.BROWSERSTACK = true;
32+
}
2933
var nonHeadless = grunt.option('non-headless');
3034
if (nonHeadless) {
3135
process.env.NODE_RED_NON_HEADLESS = true;
Collapse file

‎scripts/install-ui-test-dependencies.sh‎

Copy file name to clipboardExpand all lines: scripts/install-ui-test-dependencies.sh
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ npm install --no-save \
33
wdio-chromedriver-service@^0.1.5 \
44
wdio-mocha-framework@^0.6.4 \
55
wdio-spec-reporter@^0.1.5 \
6-
webdriverio@^4.14.1 \
7-
chromedriver@^78.0.1
6+
webdriverio@^4.14.4 \
7+
chromedriver@^79.0.0 \
8+
wdio-browserstack-service@^0.1.19 \
9+
browserstack-local@^1.4.4
Collapse file

‎test/editor/pageobjects/util/key_page.js‎

Copy file name to clipboardExpand all lines: test/editor/pageobjects/util/key_page.js
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ var shortCutKeyMapForMac = {
2727
};
2828

2929
function getShortCutKey(type) {
30+
if (process.env.BROWSERSTACK) {
31+
if (browser.desiredCapabilities.os === 'OS X') {
32+
return shortCutKeyMapForMac[type];
33+
}
34+
return shortCutKeyMap[type];
35+
}
3036
if (os.type() === 'Darwin') {
3137
return shortCutKeyMapForMac[type];
3238
}
Collapse file

‎test/editor/wdio.conf.js‎

Copy file name to clipboardExpand all lines: test/editor/wdio.conf.js
+87-21Lines changed: 87 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
**/
1616

17+
var browserstack = require('browserstack-local');
1718
exports.config = {
1819

1920
//
@@ -48,27 +49,20 @@ exports.config = {
4849
// and 30 processes will get spawned. The property handles how many capabilities
4950
// from the same test should run tests.
5051
//
51-
maxInstances: 10,
52+
// maxInstances: 10,
5253
//
5354
// If you have trouble getting all important capabilities together, check out the
5455
// Sauce Labs platform configurator - a great tool to configure your capabilities:
5556
// https://docs.saucelabs.com/reference/platforms-configurator
5657
//
57-
capabilities: [{
58+
// capabilities: [{
5859
// maxInstances can get overwritten per capability. So if you have an in-house Selenium
5960
// grid with only 5 firefox instances available you can make sure that not more than
6061
// 5 instances get started at a time.
61-
maxInstances: 2,
62+
// maxInstances: 5,
6263
//
63-
browserName: 'chrome',
64-
'goog:chromeOptions': {
65-
args: process.env.NODE_RED_NON_HEADLESS
66-
// Runs tests with opening a browser.
67-
? ['--disable-gpu', '--no-sandbox']
68-
// Runs tests without opening a browser.
69-
: ['--headless', '--disable-gpu', 'window-size=1920,1080', '--no-sandbox']
70-
},
71-
}],
64+
// browserName: 'firefox'
65+
// }],
7266
//
7367
// ===================
7468
// Test Configurations
@@ -103,7 +97,7 @@ exports.config = {
10397
baseUrl: 'http://localhost',
10498
//
10599
// Default timeout for all waitFor* commands.
106-
waitforTimeout: 10000,
100+
waitforTimeout: 20000,
107101
//
108102
// Default timeout in milliseconds for request
109103
// if Selenium Grid doesn't send response
@@ -134,9 +128,7 @@ exports.config = {
134128
// Services take over a specific job you don't want to take care of. They enhance
135129
// your test setup with almost no effort. Unlike plugins, they don't add new
136130
// commands. Instead, they hook themselves up into the test process.
137-
port: 9515,
138-
path: '/',
139-
services: ['chromedriver'],
131+
//services: ['chromedriver'],
140132
//
141133
// Framework you want to run your specs with.
142134
// The following are supported: Mocha, Jasmine, and Cucumber
@@ -155,7 +147,7 @@ exports.config = {
155147
// Options to be passed to Mocha.
156148
// See the full list at http://mochajs.org/
157149
mochaOpts: {
158-
timeout: 100000,
150+
timeout: 1000000,
159151
ui: 'bdd'
160152
},
161153
//
@@ -171,8 +163,44 @@ exports.config = {
171163
* @param {Object} config wdio configuration object
172164
* @param {Array.<Object>} capabilities list of capabilities details
173165
*/
174-
// onPrepare: function (config, capabilities) {
175-
// },
166+
onPrepare: function (config, capabilities) {
167+
if (process.env.BROWSERSTACK) {
168+
return new Promise(function (resolve, reject) {
169+
var options = { key: exports.config.key };
170+
var proxy = process.env.http_proxy || process.env.HTTP_PROXY;
171+
if (proxy) {
172+
var proxyConfigs = proxy.match(/^(https?):\/\/(([^:@\/]+):([^:@\/]+)@)?([^:@\/]+)(:([^:@\/]+))?\/?$/);
173+
if (proxyConfigs) {
174+
var protocol = proxyConfigs[1];
175+
var user = proxyConfigs[3];
176+
var pass = proxyConfigs[4];
177+
var host = proxyConfigs[5];
178+
var port = proxyConfigs[7];
179+
if (!port) {
180+
if (protocol === 'http') {
181+
port = 80;
182+
} else if (protocol === 'https') {
183+
port = 443;
184+
}
185+
}
186+
if (host) { options.proxyHost = host; }
187+
if (port) { options.proxyPort = port; }
188+
if (user) { options.proxyUser = user; }
189+
if (pass) { options.proxyPass = pass; }
190+
} else {
191+
reject('error in parsing the environment variable, http_proxy');
192+
}
193+
}
194+
exports.bs_local = new browserstack.Local();
195+
exports.bs_local.start(options, function (error) {
196+
if (error) {
197+
return reject(error);
198+
}
199+
resolve();
200+
});
201+
});
202+
}
203+
},
176204
/**
177205
* Gets executed just before initialising the webdriver session and test framework. It allows you
178206
* to manipulate configurations depending on the capability or spec.
@@ -267,6 +295,44 @@ exports.config = {
267295
* @param {Object} config wdio configuration object
268296
* @param {Array.<Object>} capabilities list of capabilities details
269297
*/
270-
// onComplete: function(exitCode, config, capabilities) {
271-
// }
298+
onComplete: function(exitCode, config, capabilities) {
299+
if (process.env.BROWSERSTACK) {
300+
exports.bs_local.stop(function () {});
301+
}
302+
}
303+
};
304+
305+
if (process.env.BROWSERSTACK) {
306+
exports.config.maxInstances = 1;
307+
if (process.env.BROWSERSTACK_USERNAME && process.env.BROWSERSTACK_ACCESS_KEY) {
308+
exports.config.user = process.env.BROWSERSTACK_USERNAME;
309+
exports.config.key = process.env.BROWSERSTACK_ACCESS_KEY;
310+
} else {
311+
console.log('You need to set the following environment variables.');
312+
console.log('BROWSERSTACK_USERNAME=<BrowserStack user name>');
313+
console.log('BROWSERSTACK_ACCESS_KEY=<BrowserStack access key>');
314+
}
315+
exports.config.services = ['browserstack'];
316+
var capabilities = [];
317+
capabilities.push({ os: 'Windows', os_version: '10', browser: 'Chrome', resolution: '1920x1080', 'browserstack.local': true });
318+
capabilities.push({ os: 'Windows', os_version: '10', browser: 'Firefox', resolution: '1920x1080', 'browserstack.local': true });
319+
capabilities.push({ os: 'OS X', os_version: 'Catalina', browser: 'Chrome', resolution: '1920x1080', 'browserstack.local': true });
320+
capabilities.push({ os: 'OS X', os_version: 'Catalina', browser: 'Firefox', resolution: '1920x1080', 'browserstack.local': true });
321+
exports.config.capabilities = capabilities;
322+
} else {
323+
exports.config.maxInstances = 10;
324+
exports.config.port = 9515;
325+
exports.config.path = '/';
326+
exports.config.services = ['chromedriver'];
327+
exports.config.capabilities = [{
328+
maxInstances: 2,
329+
browserName: 'chrome',
330+
'goog:chromeOptions': {
331+
args: process.env.NODE_RED_NON_HEADLESS
332+
// Runs tests with opening a browser.
333+
? ['--disable-gpu', '--no-sandbox']
334+
// Runs tests without opening a browser.
335+
: ['--headless', '--disable-gpu', 'window-size=1920,1080', '--no-sandbox']
336+
}
337+
}];
272338
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.