1
1
// Util from NodeJs
2
2
import * as net from 'net' ;
3
+ import { ActionSequence , promise as wdpromise , until , WebDriver , WebElement } from 'selenium-webdriver' ;
3
4
import * as url from 'url' ;
4
5
import * as util from 'util' ;
5
6
@@ -33,20 +34,18 @@ for (let foo in webdriver) {
33
34
34
35
// Explicitly define webdriver.WebDriver.
35
36
export class Webdriver {
36
- actions : ( ) => webdriver . ActionSequence = webdriver . WebDriver . actions ;
37
+ actions : ( ) => ActionSequence = webdriver . WebDriver . actions ;
37
38
wait :
38
- ( condition : webdriver . promise . Promise < any > | webdriver . util . Condition |
39
- Function ,
39
+ ( condition : wdpromise . Promise < any > | until . Condition < any > | Function ,
40
40
opt_timeout ?: number ,
41
41
opt_message ?:
42
- string ) => webdriver . promise . Promise < any > = webdriver . WebDriver . wait ;
43
- sleep : ( ms : number ) => webdriver . promise . Promise < any > =
44
- webdriver . WebDriver . sleep ;
42
+ string ) => wdpromise . Promise < any > = webdriver . WebDriver . wait ;
43
+ sleep : ( ms : number ) => wdpromise . Promise < any > = webdriver . WebDriver . sleep ;
45
44
getCurrentUrl :
46
- ( ) => webdriver . promise . Promise < any > = webdriver . WebDriver . getCurrentUrl ;
47
- getTitle : ( ) => webdriver . promise . Promise < any > = webdriver . WebDriver . getTitle ;
45
+ ( ) => wdpromise . Promise < any > = webdriver . WebDriver . getCurrentUrl ;
46
+ getTitle : ( ) => wdpromise . Promise < any > = webdriver . WebDriver . getTitle ;
48
47
takeScreenshot :
49
- ( ) => webdriver . promise . Promise < any > = webdriver . WebDriver . takeScreenshot ;
48
+ ( ) => wdpromise . Promise < any > = webdriver . WebDriver . takeScreenshot ;
50
49
}
51
50
52
51
/**
@@ -127,7 +126,7 @@ export class ProtractorBrowser extends Webdriver {
127
126
*
128
127
* @type {webdriver.WebDriver }
129
128
*/
130
- driver : webdriver . WebDriver ;
129
+ driver : WebDriver ;
131
130
132
131
/**
133
132
* Helper function for finding elements.
@@ -197,7 +196,7 @@ export class ProtractorBrowser extends Webdriver {
197
196
*
198
197
* @type {q.Promise } Done when the new browser is ready for use
199
198
*/
200
- ready : webdriver . promise . Promise < any > ;
199
+ ready : wdpromise . Promise < any > ;
201
200
202
201
/*
203
202
* Set by the runner.
@@ -257,7 +256,7 @@ export class ProtractorBrowser extends Webdriver {
257
256
[ key : string ] : any ;
258
257
259
258
constructor (
260
- webdriverInstance : webdriver . WebDriver , opt_baseUrl ?: string ,
259
+ webdriverInstance : WebDriver , opt_baseUrl ?: string ,
261
260
opt_rootElement ?: string , opt_untrackOutstandingTimeouts ?: boolean ) {
262
261
super ( ) ;
263
262
// These functions should delegate to the webdriver instance, but should
@@ -322,7 +321,7 @@ export class ProtractorBrowser extends Webdriver {
322
321
* @returns {webdriver.promise.Promise } A promise which resolves to the
323
322
* capabilities object.
324
323
*/
325
- getProcessedConfig ( ) : webdriver . promise . Promise < any > { return null ; }
324
+ getProcessedConfig ( ) : wdpromise . Promise < any > { return null ; }
326
325
327
326
/**
328
327
* Fork another instance of browser for use in interactive tests.
@@ -374,7 +373,7 @@ export class ProtractorBrowser extends Webdriver {
374
373
*/
375
374
private executeScript_ (
376
375
script : string | Function , description : string ,
377
- ...scriptArgs : any [ ] ) : webdriver . promise . Promise < any > {
376
+ ...scriptArgs : any [ ] ) : wdpromise . Promise < any > {
378
377
if ( typeof script === 'function' ) {
379
378
script = 'return (' + script + ').apply(null, arguments);' ;
380
379
}
@@ -401,7 +400,7 @@ export class ProtractorBrowser extends Webdriver {
401
400
*/
402
401
private executeAsyncScript_ (
403
402
script : string | Function , description : string ,
404
- ...scriptArgs : any [ ] ) : webdriver . promise . Promise < any > {
403
+ ...scriptArgs : any [ ] ) : wdpromise . Promise < any > {
405
404
if ( typeof script === 'function' ) {
406
405
script = 'return (' + script + ').apply(null, arguments);' ;
407
406
}
@@ -423,15 +422,15 @@ export class ProtractorBrowser extends Webdriver {
423
422
* @returns {!webdriver.promise.Promise } A promise that will resolve to the
424
423
* scripts return value.
425
424
*/
426
- waitForAngular ( opt_description ?: string ) : webdriver . promise . Promise < any > {
425
+ waitForAngular ( opt_description ?: string ) : wdpromise . Promise < any > {
427
426
let description = opt_description ? ' - ' + opt_description : '' ;
428
427
if ( this . ignoreSynchronization ) {
429
428
return this . driver . controlFlow ( ) . execute ( ( ) => {
430
429
return true ;
431
430
} , 'Ignore Synchronization Protractor.waitForAngular()' ) ;
432
431
}
433
432
434
- let runWaitForAngularScript : ( ) => webdriver . promise . Promise < any > = ( ) => {
433
+ let runWaitForAngularScript : ( ) => wdpromise . Promise < any > = ( ) => {
435
434
if ( this . plugins_ . skipAngularStability ( ) ) {
436
435
return webdriver . promise . fulfilled ( ) ;
437
436
} else if ( this . rootEl ) {
@@ -493,22 +492,22 @@ export class ProtractorBrowser extends Webdriver {
493
492
errMsg +=
494
493
'\nWhile waiting for element with locator' + description ;
495
494
}
496
- let pendingTimeoutsPromise : webdriver . promise . Promise < any > ;
495
+ let pendingTimeoutsPromise : wdpromise . Promise < any > ;
497
496
if ( this . trackOutstandingTimeouts_ ) {
498
497
pendingTimeoutsPromise = this . executeScript_ (
499
498
'return window.NG_PENDING_TIMEOUTS' ,
500
499
'Protractor.waitForAngular() - getting pending timeouts' +
501
500
description ) ;
502
501
} else {
503
- pendingTimeoutsPromise = webdriver . promise . fulfilled ( { } ) ;
502
+ pendingTimeoutsPromise = wdpromise . fulfilled ( { } ) ;
504
503
}
505
504
let pendingHttpsPromise = this . executeScript_ (
506
505
clientSideScripts . getPendingHttpRequests ,
507
506
'Protractor.waitForAngular() - getting pending https' +
508
507
description ,
509
508
this . rootEl ) ;
510
509
511
- return webdriver . promise
510
+ return wdpromise
512
511
. all ( [ pendingTimeoutsPromise , pendingHttpsPromise ] )
513
512
. then (
514
513
( arr : any [ ] ) => {
@@ -549,7 +548,7 @@ export class ProtractorBrowser extends Webdriver {
549
548
* @returns {!webdriver.promise.Promise } A promise that will be resolved to
550
549
* the located {@link webdriver.WebElement}.
551
550
*/
552
- findElement ( locator : Locator ) : webdriver . WebElement {
551
+ findElement ( locator : Locator ) : WebElement {
553
552
return this . element ( locator ) . getWebElement ( ) ;
554
553
}
555
554
0 commit comments