Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
fix(driverProviders): quit forked instances w/ local driver provider (#…
Browse files Browse the repository at this point in the history
…3787)

- fix driver provider quit session to not throw error and quit
- should fix sauce labs test, enabling expected conditions test with forked instance
- checked that chromedriver does not persist in the background
- add local driver test with forked instance to test suite
- organize attach session and local specs to driverProviders directory

closes #3780, closes #3779, closes #3772
  • Loading branch information
cnishina authored and sjelin committed Dec 3, 2016
1 parent 7d481d6 commit 742f264
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 13 deletions.
18 changes: 11 additions & 7 deletions lib/driverProviders/driverProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,19 @@ export class DriverProvider {
if (driver.getSession() === undefined) {
deferred.resolve();
} else {
driver.getSession().then((session_) => {
if (session_) {
driver.quit().then(function() {
driver.getSession()
.then((session_) => {
if (session_) {
driver.quit().then(function() {
deferred.resolve();
});
} else {
deferred.resolve();
}
})
.catch((err: Error) => {
deferred.resolve();
});
} else {
deferred.resolve();
}
});
}
return deferred.promise;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ var checkSession = function() {
res.on('end', function() {
if (state === 'success') {
var runProtractor = spawn('node',
['bin/protractor', 'spec/attachSession.js', '--seleniumSessionId=' + sessionId]);
['bin/protractor', 'spec/driverProviderAttachSessionConf.js',
'--seleniumSessionId=' + sessionId]);
console.log(runProtractor.stdout.toString());
if (runProtractor.status !== 0) {
throw new Error('Protractor did not run properly.');
Expand Down
3 changes: 2 additions & 1 deletion scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ var passingTests = [
'node built/cli.js spec/interactionConf.js',
'node built/cli.js spec/directConnectConf.js',
'node built/cli.js spec/restartBrowserBetweenTestsConf.js',
'node built/cli.js spec/driverProviderLocalConf.js',
'node built/cli.js spec/getCapabilitiesConf.js',
'node built/cli.js spec/controlLockConf.js',
'node built/cli.js spec/customFramework.js',
'node built/cli.js spec/noGlobalsConf.js',
'node built/cli.js spec/angular2Conf.js',
'node built/cli.js spec/hybridConf.js',
'node scripts/attachSession.js',
'node scripts/driverProviderAttachSession.js',
'node scripts/exitCodes.js',
'node scripts/interactive_tests/interactive_test.js',
'node scripts/interactive_tests/with_base_url.js',
Expand Down
4 changes: 1 addition & 3 deletions spec/basic/expected_conditions_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,7 @@ describe('expected conditions', function() {
expect(EC.or(EC.not(valid), EC.and(valid, invalid)).call()).toBe(false);
});

// TODO(cnishina): enable test when local / sauce labs errors
// are resolved.
xdescribe('for forked browsers', function() {
describe('for forked browsers', function() {
// ensure that we can run EC on forked browser instances
it('should have alertIsPresent', function() {
var browser2 = browser.forkNewDriverInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports.config = {
framework: 'jasmine',

specs: [
'attachSessionProvider/attachSession_spec.js'
'driverProviders/attachSession/*_spec.js'
],

capabilities: env.capabilities,
Expand Down
20 changes: 20 additions & 0 deletions spec/driverProviderLocalConf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var env = require('./environment');

exports.config = {

framework: 'jasmine',

specs: [
'driverProviders/local/*_spec.js'
],

capabilities: env.capabilities,

baseUrl: env.baseUrl,

// Special option for Angular2, to test against all Angular2 applications
// on the page. This means that Protractor will wait for every app to be
// stable before each action, and search within all apps when finding
// elements.
useAllAngular2AppRoots: true
};
17 changes: 17 additions & 0 deletions spec/driverProviders/local/local_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
describe('local driver provider', function() {
var URL = '/ng2/#/async';

it('should get a page and find an element', function() {
browser.get(URL);
var increment = $('#increment');
expect(increment).toBeDefined();
});

it('should get a forked instance, and find an element', function() {
browser.get(URL);
var browser2 = browser.forkNewDriverInstance();
browser2.get(URL);
var increment = browser2.$('#increment');
expect(increment).toBeDefined();
});
});

0 comments on commit 742f264

Please sign in to comment.