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

Commit

Permalink
refactor(browser): Remove protractor.wrapDriver() **breaking change** (
Browse files Browse the repository at this point in the history
…#3827)

Before:
Users could create their own selenium driver instance and enable Protractor on
it like so:
```js
let capabilities = webdriver.Capabilities.chrome();
let driver = new webdriver.Builder().usingServer(seleniumAddress)
    .withCapabilities(capabilities).build();
let browser = protractor.wrapDriver(driver);
```

Over the years, wrapDriver() has become increasingly broken as Protractor
needs extra configuration options that wrapDriver() doesn't set.

After:
This method is removed. If users need a new browser instance, they can
use `browser.forkNewDriverInstance()`.
  • Loading branch information
heathkit authored and juliemr committed Dec 29, 2016
1 parent d2d2a71 commit 681b54a
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 33 deletions.
17 changes: 0 additions & 17 deletions lib/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -977,21 +977,4 @@ export class ProtractorBrowser extends Webdriver {
};
this.debugHelper.init(debuggerClientPath, onStartFn, opt_debugPort);
}

/**
* Create a new instance of Browser by wrapping a webdriver instance.
*
* @param {webdriver.WebDriver} webdriver The configured webdriver instance.
* @param {string=} baseUrl A URL to prepend to relative gets.
* @param {string=} rootElement The css selector for the element which is the
* root of the Angular app.
* @param {boolean=} untrackOutstandingTimeouts Whether Browser should
* stop tracking outstanding $timeouts.
* @returns {Browser} a new Browser instance
*/
static wrapDriver(
webdriver: WebDriver, baseUrl?: string, rootElement?: string,
untrackOutstandingTimeouts?: boolean): ProtractorBrowser {
return new ProtractorBrowser(webdriver, baseUrl, rootElement, untrackOutstandingTimeouts);
}
}
2 changes: 0 additions & 2 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ export {ProtractorExpectedConditions} from './expectedConditions';
export {ProtractorBy} from './locators';
export {Ptor} from './ptor';

export let wrapDriver = ProtractorBrowser.wrapDriver;

export let utils = {
firefox: require('selenium-webdriver/firefox'),
http: require('selenium-webdriver/http'),
Expand Down
3 changes: 1 addition & 2 deletions lib/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ export class Runner extends EventEmitter {
protractor.$$ = browser_.$$;
protractor.element = browser_.element;
protractor.by = protractor.By = ProtractorBrowser.By;
protractor.wrapDriver = ProtractorBrowser.wrapDriver;
protractor.ExpectedConditions = browser_.ExpectedConditions;

if (!this.config_.noGlobals) {
Expand Down Expand Up @@ -187,7 +186,7 @@ export class Runner extends EventEmitter {
let config = this.config_;
let driver = this.driverprovider_.getNewDriver();

let browser_ = ProtractorBrowser.wrapDriver(
let browser_ = new ProtractorBrowser(
driver, config.baseUrl, config.rootElement, config.untrackOutstandingTimeouts);

browser_.params = config.params;
Expand Down
6 changes: 0 additions & 6 deletions spec/basic/lib_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,6 @@ describe('protractor library', function() {
toEqual('repeater');
});

it('should allow self-wrapped webdriver instances', function() {
var driver = protractor.wrapDriver(browser.driver);
var url = require('url').resolve(browser.baseUrl, 'index.html');
driver.get(url);
});

describe('helper functions', function() {
it('should get the absolute URL', function() {
browser.get('index.html');
Expand Down
5 changes: 0 additions & 5 deletions spec/dependencyTest/protractor_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ describe('require(\'protractor\')', () => {
});

describe('browser class', () => {
it('should have static method defined', () => {
var staticMethod = 'wrapDriver';
expect(typeof protractor.ProtractorBrowser['wrapDriver']).toEqual('function');
});

it('should have static variables defined', () => {
var staticVariables = ['By'];
for (var pos in staticVariables) {
Expand Down
1 change: 0 additions & 1 deletion spec/install/typescript_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ describe('typescript imports', () => {
expect(protractor.$ === $).toBeTruthy();
expect(protractor.$$ === $$).toBeTruthy();
expect(protractor.ExpectedConditions === ExpectedConditions).toBeTruthy();
expect(typeof protractor.wrapDriver).toEqual('function');
});
it('should have selenium-webdriver components for the protractor namespace', () => {
expect(typeof protractor.promise.all).toEqual('function');
Expand Down

0 comments on commit 681b54a

Please sign in to comment.