webdriver-js-extender
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -10,18 +10,1 @@ export declare class DeferredExecutor { | ||
} | ||
/** | ||
* Creates a command executor that uses WebDriver's JSON wire protocol. | ||
* | ||
* selenium-webdriver uses this internally, and we overwrite it to use our | ||
* implementation of DeferredExecutor | ||
* | ||
* Based off https://github.com/SeleniumHQ/selenium/blob/master/javascript/node/selenium-webdriver/executors.js#L43 | ||
* | ||
* @param {(string|!Promise<string>)} url The server's URL, or a promise that | ||
* will resolve to that URL. | ||
* @param {http.Agent=} opt_agent (optional) The Http.Agent for the client to | ||
* use. | ||
* @param {(string|null)=} opt_proxy (optional) The URL of the HTTP proxy for | ||
* the client to use. | ||
* @returns {!./lib/command.Executor} The new command executor. | ||
*/ | ||
export declare function createExecutor(url: any, opt_agent?: any, opt_proxy?: any): DeferredExecutor; |
"use strict"; | ||
var webdriver = require('selenium-webdriver'); | ||
var HttpClient = require('selenium-webdriver/http').HttpClient; | ||
var HttpExecutor = require('selenium-webdriver/http').HttpExecutor; | ||
/* | ||
@@ -37,26 +35,1 @@ * Wraps a promised {@link Executor}, ensuring no commands are executed until | ||
exports.DeferredExecutor = DeferredExecutor; | ||
/** | ||
* Creates a command executor that uses WebDriver's JSON wire protocol. | ||
* | ||
* selenium-webdriver uses this internally, and we overwrite it to use our | ||
* implementation of DeferredExecutor | ||
* | ||
* Based off https://github.com/SeleniumHQ/selenium/blob/master/javascript/node/selenium-webdriver/executors.js#L43 | ||
* | ||
* @param {(string|!Promise<string>)} url The server's URL, or a promise that | ||
* will resolve to that URL. | ||
* @param {http.Agent=} opt_agent (optional) The Http.Agent for the client to | ||
* use. | ||
* @param {(string|null)=} opt_proxy (optional) The URL of the HTTP proxy for | ||
* the client to use. | ||
* @returns {!./lib/command.Executor} The new command executor. | ||
*/ | ||
function createExecutor(url, opt_agent, opt_proxy) { | ||
url = Promise.resolve(url); | ||
return new DeferredExecutor(url.then(function (url) { | ||
var client = new HttpClient(url, opt_agent, opt_proxy); | ||
return new HttpExecutor(client); | ||
})); | ||
} | ||
exports.createExecutor = createExecutor; | ||
; |
@@ -11,7 +11,9 @@ export interface ExtendedWebDriver extends webdriver.WebDriver { | ||
* patch(require('selenium-webdriver/lib/command'), | ||
* require('selenium-webdriver/executors')); | ||
* require('selenium-webdriver/executors'), | ||
* require('selenium-webdriver/http')); | ||
* | ||
* @param {*} lib_command The object at 'selenium-webdriver/lib/command' | ||
* @param {*} executors The object at 'selenium-webdriver/executors' | ||
* @param {*} http The object at 'selenium-webdriver/http' | ||
*/ | ||
export declare function patch(lib_command: any, executors: any): void; | ||
export declare function patch(lib_command: any, executors: any, http: any): void; |
@@ -26,12 +26,21 @@ "use strict"; | ||
* patch(require('selenium-webdriver/lib/command'), | ||
* require('selenium-webdriver/executors')); | ||
* require('selenium-webdriver/executors'), | ||
* require('selenium-webdriver/http')); | ||
* | ||
* @param {*} lib_command The object at 'selenium-webdriver/lib/command' | ||
* @param {*} executors The object at 'selenium-webdriver/executors' | ||
* @param {*} http The object at 'selenium-webdriver/http' | ||
*/ | ||
function patch(lib_command, executors) { | ||
function patch(lib_command, executors, http) { | ||
lib_command.DeferredExecutor = deferredExecutor_1.DeferredExecutor; | ||
executors.DeferredExecutor = deferredExecutor_1.DeferredExecutor; | ||
executors.createExecutor = deferredExecutor_1.createExecutor; | ||
// Based off of https://github.com/SeleniumHQ/selenium/blob/master/javascript/node/selenium-webdriver/executors.js#L43 | ||
executors.createExecutor = function (url, opt_agent, opt_proxy) { | ||
url = Promise.resolve(url); | ||
return new deferredExecutor_1.DeferredExecutor(url.then(function (url) { | ||
var client = new http.HttpClient(url, opt_agent, opt_proxy); | ||
return new http.Executor(client); | ||
})); | ||
}; | ||
} | ||
exports.patch = patch; |
{ | ||
"name": "webdriver-js-extender", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "A plugin which adds additional commands to selenium's javascript implementation of the webdriver client side API", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -44,5 +44,2 @@ "use strict"; | ||
}); | ||
it('should create a DeferredExecutor via createExecutor', function () { | ||
expect(deferredExecutor_1.createExecutor('http://localhost')).toEqual(jasmine.any(deferredExecutor_1.DeferredExecutor)); | ||
}); | ||
}); |
"use strict"; | ||
var webdriver = require('selenium-webdriver'); | ||
var lib_1 = require('../lib'); | ||
var deferredExecutor_1 = require('../lib/deferredExecutor'); | ||
var mockdriver_1 = require('./mockdriver'); | ||
@@ -27,2 +28,6 @@ describe('extender', function () { | ||
}); | ||
it('should patch selenium-webdriver', function () { | ||
lib_1.patch(require('selenium-webdriver/lib/command'), require('selenium-webdriver/executors'), require('selenium-webdriver/http')); | ||
expect(require('selenium-webdriver/executors').createExecutor('http://localhost')).toEqual(jasmine.any(deferredExecutor_1.DeferredExecutor)); | ||
}); | ||
}); |
{ | ||
"name": "webdriver-js-extender", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "A plugin which adds additional commands to selenium's javascript implementation of the webdriver client side API", | ||
@@ -5,0 +5,0 @@ "scripts": { |
25088
24
480