@@ -43,42 +43,10 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
43
43
appConfig : { } ;
44
44
ensureCurrentUrl : boolean ;
45
45
shouldLoginIfPrompted : boolean ;
46
- shouldAcceptAlert : boolean ;
47
46
useActualUrl : boolean ;
48
47
}
49
48
50
49
class CommonPage {
51
- /**
52
- * Navigates the browser window to provided URL
53
- * @param url URL
54
- * @param shouldAcceptAlert pass 'true' if browser alert should be accepted
55
- */
56
- private static async navigateToUrlAndHandleAlert ( url : string , shouldAcceptAlert : boolean ) {
57
- log . debug ( 'Navigate to: ' + url ) ;
58
- try {
59
- await browser . get ( url ) ;
60
- } catch ( navigationError ) {
61
- log . debug ( 'Error navigating to url' ) ;
62
- const alert = await browser . getAlert ( ) ;
63
- if ( alert && alert . accept ) {
64
- if ( shouldAcceptAlert ) {
65
- log . debug ( 'Should accept alert' ) ;
66
- try {
67
- await alert . accept ( ) ;
68
- } catch ( alertException ) {
69
- log . debug ( 'Error accepting alert' ) ;
70
- throw alertException ;
71
- }
72
- } else {
73
- log . debug ( 'Will not accept alert' ) ;
74
- throw navigationError ;
75
- }
76
- } else {
77
- throw navigationError ;
78
- }
79
- }
80
- }
81
-
82
50
/**
83
51
* Returns Kibana host URL
84
52
*/
@@ -127,21 +95,19 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
127
95
}
128
96
129
97
private async navigate ( navigateProps : NavigateProps ) {
130
- const {
131
- appConfig,
132
- ensureCurrentUrl,
133
- shouldLoginIfPrompted,
134
- shouldAcceptAlert,
135
- useActualUrl,
136
- } = navigateProps ;
98
+ const { appConfig, ensureCurrentUrl, shouldLoginIfPrompted, useActualUrl } = navigateProps ;
137
99
const appUrl = getUrl . noAuth ( config . get ( 'servers.kibana' ) , appConfig ) ;
138
100
139
101
await retry . try ( async ( ) => {
140
102
if ( useActualUrl ) {
141
103
log . debug ( `navigateToActualUrl ${ appUrl } ` ) ;
142
104
await browser . get ( appUrl ) ;
143
105
} else {
144
- await CommonPage . navigateToUrlAndHandleAlert ( appUrl , shouldAcceptAlert ) ;
106
+ log . debug ( `navigateToUrl ${ appUrl } ` ) ;
107
+ await browser . get ( appUrl ) ;
108
+ // accept alert if it pops up
109
+ const alert = await browser . getAlert ( ) ;
110
+ await alert ?. accept ( ) ;
145
111
}
146
112
147
113
const currentUrl = shouldLoginIfPrompted
@@ -167,7 +133,6 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
167
133
basePath = '' ,
168
134
ensureCurrentUrl = true ,
169
135
shouldLoginIfPrompted = true ,
170
- shouldAcceptAlert = true ,
171
136
useActualUrl = false ,
172
137
} = { }
173
138
) {
@@ -180,7 +145,6 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
180
145
appConfig,
181
146
ensureCurrentUrl,
182
147
shouldLoginIfPrompted,
183
- shouldAcceptAlert,
184
148
useActualUrl,
185
149
} ) ;
186
150
}
@@ -200,7 +164,6 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
200
164
basePath = '' ,
201
165
ensureCurrentUrl = true ,
202
166
shouldLoginIfPrompted = true ,
203
- shouldAcceptAlert = true ,
204
167
useActualUrl = true ,
205
168
} = { }
206
169
) {
@@ -214,7 +177,6 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
214
177
appConfig,
215
178
ensureCurrentUrl,
216
179
shouldLoginIfPrompted,
217
- shouldAcceptAlert,
218
180
useActualUrl,
219
181
} ) ;
220
182
}
@@ -228,18 +190,12 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
228
190
async navigateToActualUrl (
229
191
appName : string ,
230
192
hash ?: string ,
231
- {
232
- basePath = '' ,
233
- ensureCurrentUrl = true ,
234
- shouldLoginIfPrompted = true ,
235
- shouldAcceptAlert = true ,
236
- } = { }
193
+ { basePath = '' , ensureCurrentUrl = true , shouldLoginIfPrompted = true } = { }
237
194
) {
238
195
await this . navigateToUrl ( appName , hash , {
239
196
basePath,
240
197
ensureCurrentUrl,
241
198
shouldLoginIfPrompted,
242
- shouldAcceptAlert,
243
199
useActualUrl : true ,
244
200
} ) ;
245
201
}
@@ -252,7 +208,7 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
252
208
253
209
async navigateToApp (
254
210
appName : string ,
255
- { basePath = '' , shouldLoginIfPrompted = true , shouldAcceptAlert = true , hash = '' } = { }
211
+ { basePath = '' , shouldLoginIfPrompted = true , hash = '' } = { }
256
212
) {
257
213
let appUrl : string ;
258
214
if ( config . has ( [ 'apps' , appName ] ) ) {
@@ -274,7 +230,11 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
274
230
await retry . tryForTime ( defaultTryTimeout * 2 , async ( ) => {
275
231
let lastUrl = await retry . try ( async ( ) => {
276
232
// since we're using hash URLs, always reload first to force re-render
277
- await CommonPage . navigateToUrlAndHandleAlert ( appUrl , shouldAcceptAlert ) ;
233
+ log . debug ( 'navigate to: ' + appUrl ) ;
234
+ await browser . get ( appUrl ) ;
235
+ // accept alert if it pops up
236
+ const alert = await browser . getAlert ( ) ;
237
+ await alert ?. accept ( ) ;
278
238
await this . sleep ( 700 ) ;
279
239
log . debug ( 'returned from get, calling refresh' ) ;
280
240
await browser . refresh ( ) ;
0 commit comments