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

Commit 97e6703

Browse files
avddhankduan
authored andcommitted
feat(protractor): Add protractor.prototype.restart
1 parent 4aa5127 commit 97e6703

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

lib/protractor.js

+6
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,12 @@ Protractor.prototype.getProcessedConfig = null;
267267
*/
268268
Protractor.prototype.forkNewDriverInstance = null;
269269

270+
/**
271+
* Restart the browser instance.
272+
*
273+
* Set by the runner.
274+
*/
275+
Protractor.prototype.restart = null;
270276

271277
/**
272278
* Instead of using a single root element, search through all angular apps

lib/runner.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,16 @@ Runner.prototype.createBrowser = function(plugins) {
223223
}
224224
return newBrowser;
225225
};
226+
227+
browser_.restart = function() {
228+
// Note: because tests are not paused at this point, any async
229+
// calls here are not guaranteed to complete before the tests resume.
230+
self.driverprovider_.quitDriver(browser_.driver);
231+
// Copy mock modules, but do not navigate to previous URL.
232+
browser_ = browser_.forkNewDriverInstance(false, true);
233+
self.setupGlobals_(browser_);
234+
};
235+
226236
return browser_;
227237
};
228238

@@ -304,14 +314,8 @@ Runner.prototype.run = function() {
304314

305315
if (self.config_.restartBrowserBetweenTests) {
306316
var restartDriver = function() {
307-
// Note: because tests are not paused at this point, any async
308-
// calls here are not guaranteed to complete before the tests resume.
309-
self.driverprovider_.quitDriver(browser_.driver);
310-
// Copy mock modules, but do not navigate to previous URL.
311-
browser_ = browser_.forkNewDriverInstance(false, true);
312-
self.setupGlobals_(browser_);
317+
browser_.restart();
313318
};
314-
315319
self.on('testPass', restartDriver);
316320
self.on('testFail', restartDriver);
317321
}

0 commit comments

Comments
 (0)