1
1
import { BPClient } from 'blocking-proxy' ;
2
- import { By , Command as WdCommand , ICommandName , Navigation , promise as wdpromise , Session , WebDriver , WebElement , WebElementPromise } from 'selenium-webdriver' ;
2
+ import { By , Navigation , WebDriver , WebElement , WebElementPromise } from 'selenium-webdriver' ;
3
+ import { Command , ICommandName } from 'selenium-webdriver/lib/command' ;
3
4
import * as url from 'url' ;
4
- import { extend as extendWD , ExtendedWebDriver } from 'webdriver-js-extender' ;
5
+
6
+ const CommandName = require ( 'selenium-webdriver/lib/command' ) . Name as ICommandName ;
5
7
6
8
import { build$ , build$$ , ElementArrayFinder , ElementFinder } from './element' ;
7
9
import { IError } from './exitCodes' ;
@@ -11,9 +13,6 @@ import {Logger} from './logger';
11
13
import { Plugins } from './plugins' ;
12
14
13
15
const clientSideScripts = require ( './clientsidescripts' ) ;
14
- // TODO: fix the typings for selenium-webdriver/lib/command
15
- const Command = require ( 'selenium-webdriver/lib/command' ) . Command as typeof WdCommand ;
16
- const CommandName = require ( 'selenium-webdriver/lib/command' ) . Name as ICommandName ;
17
16
18
17
// jshint browser: true
19
18
@@ -33,15 +32,6 @@ for (let foo in require('selenium-webdriver')) {
33
32
exports [ foo ] = require ( 'selenium-webdriver' ) [ foo ] ;
34
33
}
35
34
36
-
37
- // Explicitly define types for webdriver.WebDriver and ExtendedWebDriver.
38
- // We do this because we use composition over inheritance to implement polymorphism, and therefore
39
- // we don't want to inherit WebDriver's constructor.
40
- export class AbstractWebDriver { }
41
- export interface AbstractWebDriver extends WebDriver { }
42
- export class AbstractExtendedWebDriver extends AbstractWebDriver { }
43
- export interface AbstractExtendedWebDriver extends ExtendedWebDriver { }
44
-
45
35
/**
46
36
* Mix a function from one object onto another. The function will still be
47
37
* called in the context of the original object. Any arguments of type
@@ -109,7 +99,7 @@ function buildElementHelper(browser: ProtractorBrowser): ElementHelper {
109
99
* @param {boolean= } opt_untrackOutstandingTimeouts Whether Protractor should
110
100
* stop tracking outstanding $timeouts.
111
101
*/
112
- export class ProtractorBrowser extends AbstractExtendedWebDriver {
102
+ export class ProtractorBrowser {
113
103
/**
114
104
* @type {ProtractorBy }
115
105
*/
@@ -121,12 +111,11 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
121
111
ExpectedConditions : ProtractorExpectedConditions ;
122
112
123
113
/**
124
- * The wrapped webdriver instance. Use this to interact with pages that do
125
- * not contain Angular (such as a log-in screen).
114
+ * The browser's WebDriver instance
126
115
*
127
- * @type {webdriver_extensions.ExtendedWebDriver }
116
+ * @type {webdriver.WebDriver }
128
117
*/
129
- driver : ExtendedWebDriver ;
118
+ driver : WebDriver ;
130
119
131
120
/**
132
121
* The client used to control the BlockingProxy. If unset, BlockingProxy is
@@ -278,8 +267,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
278
267
* Information about mock modules that will be installed during every
279
268
* get().
280
269
*
281
- * @type {Array<{name: string, script: function|string, args:
282
- * Array.<string>}> }
270
+ * @type {Array<{name: string, script: function|string, args: Array.<string>}> }
283
271
*/
284
272
mockModules_ : { name : string , script : string | Function , args : any [ ] } [ ] ;
285
273
@@ -304,32 +292,23 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
304
292
constructor (
305
293
webdriverInstance : WebDriver , opt_baseUrl ?: string , opt_rootElement ?: string | Promise < string > ,
306
294
opt_untrackOutstandingTimeouts ?: boolean , opt_blockingProxyUrl ?: string ) {
307
- super ( ) ;
308
295
// These functions should delegate to the webdriver instance, but should
309
296
// wait for Angular to sync up before performing the action. This does not
310
297
// include functions which are overridden by protractor below.
311
298
let methodsToSync = [ 'getCurrentUrl' , 'getPageSource' , 'getTitle' ] ;
312
- let extendWDInstance : ExtendedWebDriver ;
313
- try {
314
- extendWDInstance = extendWD ( webdriverInstance ) ;
315
- } catch ( e ) {
316
- // Probably not a driver that can be extended (e.g. gotten using
317
- // `directConnect: true` in the config)
318
- extendWDInstance = webdriverInstance as ExtendedWebDriver ;
319
- }
320
299
321
300
// Mix all other driver functionality into Protractor.
322
301
Object . getOwnPropertyNames ( WebDriver . prototype ) . forEach ( method => {
323
- if ( ! this [ method ] && typeof ( extendWDInstance as any ) [ method ] === 'function' ) {
302
+ if ( ! this [ method ] && typeof ( webdriverInstance as any ) [ method ] === 'function' ) {
324
303
if ( methodsToSync . indexOf ( method ) !== - 1 ) {
325
- ptorMixin ( this , extendWDInstance , method , this . waitForAngular . bind ( this ) ) ;
304
+ ptorMixin ( this , webdriverInstance , method , this . waitForAngular . bind ( this ) ) ;
326
305
} else {
327
- ptorMixin ( this , extendWDInstance , method ) ;
306
+ ptorMixin ( this , webdriverInstance , method ) ;
328
307
}
329
308
}
330
309
} ) ;
331
310
332
- this . driver = extendWDInstance ;
311
+ this . driver = webdriverInstance ;
333
312
if ( opt_blockingProxyUrl ) {
334
313
logger . info ( 'Starting BP client for ' + opt_blockingProxyUrl ) ;
335
314
this . bpClient = new BPClient ( opt_blockingProxyUrl ) ;
@@ -490,10 +469,9 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
490
469
}
491
470
492
471
// TODO(selenium4): schedule does not exist on driver. Should use execute instead.
493
- return ( this . driver as any )
494
- . execute ( new Command ( CommandName . EXECUTE_SCRIPT )
495
- . setParameter ( 'script' , script )
496
- . setParameter ( 'args' , scriptArgs ) ) ;
472
+ return this . driver . execute ( ( new Command ( CommandName . EXECUTE_SCRIPT ) as Command )
473
+ . setParameter ( 'script' , script )
474
+ . setParameter ( 'args' , scriptArgs ) ) ;
497
475
}
498
476
499
477
/**
@@ -620,7 +598,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
620
598
}
621
599
622
600
/**
623
- * Waits for Angular to finish rendering before searching for elements.
601
+ * Waits for Angular to finish renderActionSequenceing before searching for elements.
624
602
* @see webdriver.WebDriver.findElement
625
603
* @returns {!webdriver.WebElementPromise } A promise that will be resolved to
626
604
* the located {@link webdriver.WebElement}.
@@ -882,7 +860,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
882
860
* await browser.get('http://angular.github.io/protractor/#/tutorial');
883
861
* await browser.setLocation('api');
884
862
* expect(await browser.getCurrentUrl())
885
- * .toBe('http://angular.github .io/protractor/#/api');
863
+ * .toBe('http://angular.g../../ithub .io/protractor/#/api');
886
864
*
887
865
* @param {string } url In page URL using the same syntax as $location.url()
888
866
* @returns {!Promise } A promise that will resolve once
@@ -921,18 +899,4 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
921
899
return await this . executeScriptWithDescription (
922
900
clientSideScripts . getLocationAbsUrl , 'Protractor.getLocationAbsUrl()' , rootEl ) ;
923
901
}
924
-
925
- /**
926
- * Determine if the control flow is enabled.
927
- *
928
- * @returns true if the control flow is enabled, false otherwise.
929
- */
930
- controlFlowIsEnabled ( ) {
931
- if ( ( wdpromise as any ) . USE_PROMISE_MANAGER !== undefined ) {
932
- return ( wdpromise as any ) . USE_PROMISE_MANAGER ;
933
- } else {
934
- // True for old versions of `selenium-webdriver`, probably false in >=5.0.0
935
- return ! ! wdpromise . ControlFlow ;
936
- }
937
- }
938
902
}
0 commit comments