1
- describe ( 'no protractor at all' , function ( ) {
2
- it ( 'should still do normal tests' , function ( ) {
1
+ describe ( 'no protractor at all' , ( ) => {
2
+ it ( 'should still do normal tests' , ( ) => {
3
3
expect ( true ) . toBe ( true ) ;
4
4
} ) ;
5
5
} ) ;
6
6
7
- describe ( 'protractor library' , function ( ) {
8
- it ( 'should expose the correct global variables' , function ( ) {
7
+ describe ( 'protractor library' , ( ) => {
8
+ it ( 'should expose the correct global variables' , ( ) => {
9
9
expect ( protractor ) . toBeDefined ( ) ;
10
10
expect ( browser ) . toBeDefined ( ) ;
11
11
expect ( by ) . toBeDefined ( ) ;
12
12
expect ( By ) . toBeDefined ( ) ;
13
13
expect ( element ) . toBeDefined ( ) ;
14
14
expect ( $ ) . toBeDefined ( ) ;
15
15
expect ( DartObject ) . toBeDefined ( ) ;
16
- var obj = { } ;
17
- var dartProxy = new DartObject ( obj ) ;
16
+ const obj = { } ;
17
+ const dartProxy = new DartObject ( obj ) ;
18
18
expect ( dartProxy . o === obj ) . toBe ( true ) ;
19
19
} ) ;
20
20
21
21
it ( 'should export other webdriver classes onto the global protractor' ,
22
- function ( ) {
22
+ ( ) => {
23
23
expect ( protractor . ActionSequence ) . toBeDefined ( ) ;
24
24
expect ( protractor . Key . RETURN ) . toEqual ( '\uE006' ) ;
25
25
} ) ;
26
26
27
- it ( 'should export custom parameters to the protractor instance' , function ( ) {
27
+ it ( 'should export custom parameters to the protractor instance' , ( ) => {
28
28
expect ( browser . params . login ) . toBeDefined ( ) ;
29
29
expect ( browser . params . login . user ) . toEqual ( 'Jane' ) ;
30
30
expect ( browser . params . login . password ) . toEqual ( '1234' ) ;
31
31
} ) ;
32
32
33
33
it ( 'should allow a mix of using protractor and using the driver directly' ,
34
- function ( ) {
35
- browser . get ( 'index.html' ) ;
36
- expect ( browser . getCurrentUrl ( ) ) . toMatch ( '#/form' ) ;
34
+ async ( ) => {
35
+ await browser . get ( 'index.html' ) ;
36
+ expect ( await browser . getCurrentUrl ( ) ) . toMatch ( '#/form' ) ;
37
37
38
- browser . driver . findElement ( protractor . By . linkText ( 'repeater' ) ) . click ( ) ;
39
- expect ( browser . driver . getCurrentUrl ( ) ) . toMatch ( '#/repeater' ) ;
38
+ await browser . driver . findElement ( protractor . By . linkText ( 'repeater' ) ) . click ( ) ;
39
+ expect ( await browser . driver . getCurrentUrl ( ) ) . toMatch ( '#/repeater' ) ;
40
40
41
- browser . navigate ( ) . back ( ) ;
42
- expect ( browser . driver . getCurrentUrl ( ) ) . toMatch ( '#/form' ) ;
43
- } ) ;
41
+ await browser . navigate ( ) . back ( ) ;
42
+ expect ( await browser . driver . getCurrentUrl ( ) ) . toMatch ( '#/form' ) ;
43
+ } ) ;
44
44
45
- it ( 'should unwrap WebElements' , function ( ) {
46
- browser . get ( 'index.html' ) ;
47
- var ptorEl = element ( by . binding ( 'greet' ) ) ;
48
- browser . executeScript ( '' , ptorEl ) ; // Will crash if element isn't unwrapped
45
+ it ( 'should unwrap WebElements' , async ( ) => {
46
+ await browser . get ( 'index.html' ) ;
47
+ const ptorEl = element ( by . binding ( 'greet' ) ) ;
48
+ await browser . executeScript ( '' , ptorEl ) ; // Will crash if element isn't unwrapped
49
49
} ) ;
50
50
51
- it ( 'should have access to the processed config block' , function ( ) {
52
- function containsMatching ( arr , string ) {
53
- var contains = false ;
54
- for ( var i = 0 ; i < arr . length ; ++ i ) {
51
+ it ( 'should have access to the processed config block' , async ( ) => {
52
+ let containsMatching = ( arr , string ) => {
53
+ let contains = false ;
54
+ for ( let i = 0 ; i < arr . length ; ++ i ) {
55
55
if ( arr [ i ] . indexOf ( string ) !== - 1 ) {
56
56
contains = true ;
57
57
}
58
58
}
59
59
return contains ;
60
60
}
61
61
62
- browser . getProcessedConfig ( ) . then ( function ( config ) {
63
- expect ( config . params . login ) . toBeDefined ( ) ;
64
- expect ( config . params . login . user ) . toEqual ( 'Jane' ) ;
65
- expect ( config . params . login . password ) . toEqual ( '1234' ) ;
66
- expect ( containsMatching ( config . specs , 'lib_spec.js' ) ) . toBe ( true ) ;
67
- expect ( config . capabilities ) . toBeDefined ( ) ;
68
- } ) ;
62
+ const config = await browser . getProcessedConfig ( ) ;
63
+ expect ( config . params . login ) . toBeDefined ( ) ;
64
+ expect ( config . params . login . user ) . toEqual ( 'Jane' ) ;
65
+ expect ( config . params . login . password ) . toEqual ( '1234' ) ;
66
+ expect ( containsMatching ( config . specs , 'lib_spec.js' ) ) . toBe ( true ) ;
67
+ expect ( config . capabilities ) . toBeDefined ( ) ;
69
68
} ) ;
70
69
71
- it ( 'should allow adding custom locators' , function ( ) {
72
- var findMenuItem = function ( ) {
73
- var itemName = arguments [ 0 ] ;
74
- var menu = document . querySelectorAll ( '.menu li' ) ;
75
- for ( var i = 0 ; i < menu . length ; ++ i ) {
70
+ it ( 'should allow adding custom locators' , async ( ) => {
71
+ let findMenuItem = ( ) => {
72
+ const itemName = arguments [ 0 ] ;
73
+ const menu = document . querySelectorAll ( '.menu li' ) ;
74
+ for ( const i = 0 ; i < menu . length ; ++ i ) {
76
75
if ( menu [ i ] . textContent == itemName ) {
77
76
return [ menu [ i ] ] ;
78
77
}
@@ -83,17 +82,17 @@ describe('protractor library', function() {
83
82
84
83
expect ( by . menuItem ) . toBeDefined ( ) ;
85
84
86
- browser . get ( 'index.html' ) ;
87
- expect ( element ( by . menuItem ( 'repeater' ) ) . isPresent ( ) ) ;
88
- expect ( element ( by . menuItem ( 'repeater' ) ) . getText ( ) ) . toEqual ( 'repeater' ) ;
85
+ await browser . get ( 'index.html' ) ;
86
+ expect ( await element ( by . menuItem ( 'repeater' ) ) . isPresent ( ) ) ;
87
+ expect ( await element ( by . menuItem ( 'repeater' ) ) . getText ( ) ) . toEqual ( 'repeater' ) ;
89
88
} ) ;
90
89
91
- it ( 'should allow adding custom varargs locators' , function ( ) {
92
- var findMenuItemWithName = function ( ) {
93
- var css = arguments [ 0 ] ;
94
- var itemName = arguments [ 1 ] ;
95
- var menu = document . querySelectorAll ( css ) ;
96
- for ( var i = 0 ; i < menu . length ; ++ i ) {
90
+ it ( 'should allow adding custom varargs locators' , async ( ) => {
91
+ let findMenuItemWithName = function ( ) {
92
+ const css = arguments [ 0 ] ;
93
+ const itemName = arguments [ 1 ] ;
94
+ const menu = document . querySelectorAll ( css ) ;
95
+ for ( const i = 0 ; i < menu . length ; ++ i ) {
97
96
if ( menu [ i ] . textContent == itemName ) {
98
97
return [ menu [ i ] ] ;
99
98
}
@@ -104,30 +103,27 @@ describe('protractor library', function() {
104
103
105
104
expect ( by . menuItemWithName ) . toBeDefined ( ) ;
106
105
107
- browser . get ( 'index.html' ) ;
108
- expect ( element ( by . menuItemWithName ( '.menu li' , 'repeater' ) ) . isPresent ( ) ) ;
109
- expect ( element ( by . menuItemWithName ( '.menu li' , 'repeater' ) ) . getText ( ) ) .
110
- toEqual ( 'repeater' ) ;
106
+ await browser . get ( 'index.html' ) ;
107
+ expect ( await element ( by . menuItemWithName ( '.menu li' , 'repeater' ) ) . isPresent ( ) ) ;
108
+ expect ( await element ( by . menuItemWithName ( '.menu li' , 'repeater' ) ) . getText ( ) )
109
+ . toEqual ( 'repeater' ) ;
111
110
} ) ;
112
111
113
- describe ( 'helper functions' , function ( ) {
114
- it ( 'should get the absolute URL' , function ( ) {
115
- browser . get ( 'index.html' ) ;
116
- expect ( browser . getLocationAbsUrl ( ) ) .
117
- toMatch ( '/form' ) ;
112
+ describe ( 'helper functions' , ( ) => {
113
+ it ( 'should get the absolute URL' , async ( ) => {
114
+ await browser . get ( 'index.html' ) ;
115
+ expect ( await browser . getLocationAbsUrl ( ) ) . toMatch ( '/form' ) ;
118
116
119
- element ( by . linkText ( 'repeater' ) ) . click ( ) ;
120
- expect ( browser . getLocationAbsUrl ( ) ) .
121
- toMatch ( '/repeater' ) ;
117
+ await element ( by . linkText ( 'repeater' ) ) . click ( ) ;
118
+ expect ( await browser . getLocationAbsUrl ( ) ) . toMatch ( '/repeater' ) ;
122
119
} ) ;
123
120
124
- it ( 'should navigate to another url with setLocation' , function ( ) {
125
- browser . get ( 'index.html' ) ;
121
+ it ( 'should navigate to another url with setLocation' , async ( ) => {
122
+ await browser . get ( 'index.html' ) ;
126
123
127
- browser . setLocation ( '/repeater' ) ;
124
+ await browser . setLocation ( '/repeater' ) ;
128
125
129
- expect ( browser . getLocationAbsUrl ( ) ) .
130
- toMatch ( '/repeater' ) ;
126
+ expect ( await browser . getLocationAbsUrl ( ) ) . toMatch ( '/repeater' ) ;
131
127
} ) ;
132
128
} ) ;
133
129
} ) ;
0 commit comments