2
2
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3
3
4
4
using System ;
5
+ using System . Diagnostics ;
5
6
using System . IO ;
6
7
using System . Linq ;
7
8
using System . Net ;
@@ -193,8 +194,11 @@ private void ValidatePackageJson(string clientAppSubdirPath)
193
194
194
195
private static async Task WarmUpServer ( AspNetProcess aspNetProcess )
195
196
{
197
+ var intervalInSeconds = 5 ;
196
198
var attempt = 0 ;
197
- var maxAttempts = 3 ;
199
+ var maxAttempts = 5 ;
200
+ var stopwatch = new Stopwatch ( ) ;
201
+ stopwatch . Start ( ) ;
198
202
do
199
203
{
200
204
try
@@ -203,7 +207,7 @@ private static async Task WarmUpServer(AspNetProcess aspNetProcess)
203
207
var response = await aspNetProcess . SendRequest ( "/" ) ;
204
208
if ( response . StatusCode == HttpStatusCode . OK )
205
209
{
206
- break ;
210
+ return ;
207
211
}
208
212
}
209
213
catch ( OperationCanceledException )
@@ -212,8 +216,11 @@ private static async Task WarmUpServer(AspNetProcess aspNetProcess)
212
216
catch ( HttpRequestException ex ) when ( ex . Message . StartsWith ( "The SSL connection could not be established" ) )
213
217
{
214
218
}
215
- await Task . Delay ( TimeSpan . FromSeconds ( 5 * attempt ) ) ;
219
+ var currentDelay = intervalInSeconds * attempt ;
220
+ await Task . Delay ( TimeSpan . FromSeconds ( currentDelay ) ) ;
216
221
} while ( attempt < maxAttempts ) ;
222
+ stopwatch . Stop ( ) ;
223
+ throw new TimeoutException ( $ "Could not contact the server within { stopwatch . Elapsed . TotalSeconds } seconds") ;
217
224
}
218
225
219
226
private void UpdatePublishedSettings ( )
@@ -246,50 +253,50 @@ private void TestBasicNavigation(bool visitFetchData, bool usesAuth, IWebDriver
246
253
browser . Equal ( "Hello, world!" , ( ) => browser . FindElement ( By . TagName ( "h1" ) ) . Text ) ;
247
254
248
255
// Can navigate to the counter page
249
- browser . FindElement ( By . PartialLinkText ( "Counter" ) ) . Click ( ) ;
256
+ browser . Click ( By . PartialLinkText ( "Counter" ) ) ;
250
257
browser . Contains ( "counter" , ( ) => browser . Url ) ;
251
258
252
259
browser . Equal ( "Counter" , ( ) => browser . FindElement ( By . TagName ( "h1" ) ) . Text ) ;
253
260
254
261
// Clicking the counter button works
255
262
browser . Equal ( "0" , ( ) => browser . FindElement ( By . CssSelector ( "p>strong" ) ) . Text ) ;
256
- browser . FindElement ( By . CssSelector ( "p+button" ) ) . Click ( ) ;
263
+ browser . Click ( By . CssSelector ( "p+button" ) ) ;
257
264
browser . Equal ( "1" , ( ) => browser . FindElement ( By . CssSelector ( "p>strong" ) ) . Text ) ;
258
265
259
266
if ( visitFetchData )
260
267
{
261
- browser . FindElement ( By . PartialLinkText ( "Fetch data" ) ) . Click ( ) ;
268
+ browser . Click ( By . PartialLinkText ( "Fetch data" ) ) ;
262
269
263
270
if ( usesAuth )
264
271
{
265
272
// We will be redirected to the identity UI
266
273
browser . Contains ( "/Identity/Account/Login" , ( ) => browser . Url ) ;
267
- browser . FindElement ( By . PartialLinkText ( "Register as a new user" ) ) . Click ( ) ;
274
+ browser . Click ( By . PartialLinkText ( "Register as a new user" ) ) ;
268
275
269
276
var userName = $ "{ Guid . NewGuid ( ) } @example.com";
270
277
var password = $ "!Test.Password1$";
271
278
browser . Exists ( By . Name ( "Input.Email" ) ) ;
272
279
browser . FindElement ( By . Name ( "Input.Email" ) ) . SendKeys ( userName ) ;
273
280
browser . FindElement ( By . Name ( "Input.Password" ) ) . SendKeys ( password ) ;
274
281
browser . FindElement ( By . Name ( "Input.ConfirmPassword" ) ) . SendKeys ( password ) ;
275
- browser . FindElement ( By . Id ( "registerSubmit" ) ) . Click ( ) ;
282
+ browser . Click ( By . Id ( "registerSubmit" ) ) ;
276
283
277
284
// We will be redirected to the RegisterConfirmation
278
285
browser . Contains ( "/Identity/Account/RegisterConfirmation" , ( ) => browser . Url ) ;
279
- browser . FindElement ( By . PartialLinkText ( "Click here to confirm your account" ) ) . Click ( ) ;
286
+ browser . Click ( By . PartialLinkText ( "Click here to confirm your account" ) ) ;
280
287
281
288
// We will be redirected to the ConfirmEmail
282
289
browser . Contains ( "/Identity/Account/ConfirmEmail" , ( ) => browser . Url ) ;
283
290
284
291
// Now we can login
285
- browser . FindElement ( By . PartialLinkText ( "Login" ) ) . Click ( ) ;
292
+ browser . Click ( By . PartialLinkText ( "Login" ) ) ;
286
293
browser . Exists ( By . Name ( "Input.Email" ) ) ;
287
294
browser . FindElement ( By . Name ( "Input.Email" ) ) . SendKeys ( userName ) ;
288
295
browser . FindElement ( By . Name ( "Input.Password" ) ) . SendKeys ( password ) ;
289
- browser . FindElement ( By . Id ( "login-submit" ) ) . Click ( ) ;
296
+ browser . Click ( By . Id ( "login-submit" ) ) ;
290
297
291
298
// Need to navigate to fetch page
292
- browser . FindElement ( By . PartialLinkText ( "Fetch data" ) ) . Click ( ) ;
299
+ browser . Click ( By . PartialLinkText ( "Fetch data" ) ) ;
293
300
}
294
301
295
302
// Can navigate to the 'fetch data' page
0 commit comments