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

Commit a989baf

Browse files
committed
breaking(typings): Update typings and remove patch since we are now using selenium 3.x
1 parent 517ad1d commit a989baf

File tree

7 files changed

+7
-59
lines changed

7 files changed

+7
-59
lines changed

README.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,8 @@ You can view the full list of commands in [`lib/index.ts`](lib/index.ts#L8).
1111
Usage
1212
-----
1313

14-
If you are using a version of `selenium-webdriver` below `3.0.0-beta-1`, you
15-
must use the `patch()` function before you create your webdriver instance:
14+
Use WebDriver JS Extender's `extend` function on your webdriver instance:
1615

17-
```js
18-
require('webdriver-js-extender').patch(
19-
require('selenium-webdriver/lib/command'),
20-
require('selenium-webdriver/executors'),
21-
require('selenium-webdriver/http'));
22-
```
23-
24-
Once you've patched `selenium-webdriver` (or if you're using version `3.x`), all
25-
you need to do is run the `extend` function on your webdriver instance:
2616

2717
```js
2818
var extendedWebdriver = require('webdriver-js-extender').extend(webdriver);

lib/index.ts

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -155,34 +155,3 @@ export function extend(baseDriver: WebDriver, fallbackGracefully = false): Exten
155155

156156
return extendedDriver;
157157
}
158-
159-
/**
160-
* Patches webdriver so that the extender can define new commands.
161-
*
162-
* @example
163-
* patch(require('selenium-webdriver/lib/command'),
164-
* require('selenium-webdriver/executors'),
165-
* require('selenium-webdriver/http'));
166-
*
167-
* @param {*} lib_command The object at 'selenium-webdriver/lib/command'
168-
* @param {*} executors The object at 'selenium-webdriver/executors'
169-
* @param {*} http The object at 'selenium-webdriver/http'
170-
*/
171-
export function patch(lib_command: any, executors: any, http: any) {
172-
if (lib_command.DeferredExecutor === undefined) {
173-
throw new Error(
174-
'The version of `selenium-webdriver` you provided does ' +
175-
'not use Deferred Executors. Are you using version 3.x or above? If ' +
176-
'so, you do not need to call the `patch()` function.');
177-
}
178-
lib_command.DeferredExecutor = DeferredExecutor;
179-
executors.DeferredExecutor = DeferredExecutor;
180-
// Based off of
181-
// https://github.com/SeleniumHQ/selenium/blob/selenium-2.53.0/javascript/node/selenium-webdriver/executors.js#L45
182-
executors.createExecutor = (url: any, opt_agent?: any, opt_proxy?: any) => {
183-
return new DeferredExecutor(wdpromise.when(url, (url: any) => {
184-
var client = new http.HttpClient(url, opt_agent, opt_proxy);
185-
return new http.Executor(client);
186-
}));
187-
};
188-
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"license": "MIT",
2323
"typings": "built/lib/index.d.ts",
2424
"dependencies": {
25-
"@types/selenium-webdriver": "^2.53.35",
26-
"selenium-webdriver": "^2.53.2"
25+
"@types/selenium-webdriver": "^3.0.0",
26+
"selenium-webdriver": "^3.0.1"
2727
},
2828
"devDependencies": {
2929
"@types/jasmine": "^2.5.37",

spec/command_tests/helpers.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {MockAppium} from '../mock-server';
55
import {Session, CommandList} from '../mock-server/interfaces';
66
import {session as commandList} from '../mock-server/commands';
77
import {Command} from 'selenium-mock';
8-
import {extend, patch, ExtendedWebDriver} from '../../lib';
8+
import {extend, ExtendedWebDriver} from '../../lib';
99
let portfinder = require('portfinder');
1010

1111

@@ -28,9 +28,6 @@ export function initMockSeleniumStandaloneServerAndGetDriverFactory(annotateComm
2828
let server: MockAppium;
2929
let port: number;
3030
beforeAll((done) => {
31-
patch(require('selenium-webdriver/lib/command'),
32-
require('selenium-webdriver/executors'),
33-
require('selenium-webdriver/http'));
3431
portfinder.getPort((err: Error, p: number) => {
3532
if (err) {
3633
done.fail(err);

spec/command_tests/normal_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ describe('normal tests', () => {
106106
}).then((fileContents) => {
107107
expect(fileContents).toBe('bar');
108108
return driver.pullFolderFromDevice('/tmp/wd_js_ext/folder');
109-
}).then((folderContents) => {
109+
}).then((folderContents: any) => {
110110
expect(folderContents['a.txt']).toBe('x');
111111
expect(folderContents['b.txt']).toBe('y');
112112
expect(folderContents['c.txt']).toBe('z');

spec/index_spec.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as webdriver from 'selenium-webdriver';
2-
import {extend, patch} from '../lib';
2+
import {extend} from '../lib';
33
import {DeferredExecutor} from '../lib/deferred_executor';
44
import {buildMockDriver, Data} from './mockdriver';
55

@@ -28,12 +28,4 @@ describe('extender', () => {
2828
done();
2929
});
3030
});
31-
32-
it('should patch selenium-webdriver', () => {
33-
patch(require('selenium-webdriver/lib/command'),
34-
require('selenium-webdriver/executors'),
35-
require('selenium-webdriver/http'));
36-
expect(require('selenium-webdriver/executors').createExecutor(
37-
'http://localhost')).toEqual(jasmine.any(DeferredExecutor));
38-
});
3931
});

spec/mockdriver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as webdriver from 'selenium-webdriver';
2-
let buildPath = require('selenium-webdriver/http').buildPath;
2+
let buildPath = require('selenium-webdriver/lib/http').buildPath;
33

44
export interface Data {
55
sessionId: string;

0 commit comments

Comments
 (0)