1616using Microsoft . AspNetCore . Testing ;
1717using Microsoft . Extensions . CommandLineUtils ;
1818using Newtonsoft . Json . Linq ;
19- using PlaywrightSharp ;
19+ using Microsoft . Playwright ;
2020using Templates . Test . Helpers ;
2121using Xunit ;
2222using Xunit . Abstractions ;
@@ -64,7 +64,7 @@ public async Task BlazorWasmStandaloneTemplate_Works(BrowserKind browserKind)
6464 private async Task < IPage > NavigateToPage ( IBrowserContext browser , string listeningUri )
6565 {
6666 var page = await browser . NewPageAsync ( ) ;
67- await page . GoToAsync ( listeningUri , LifecycleEvent . Networkidle ) ;
67+ await page . GotoAsync ( listeningUri , new ( ) { WaitUntil = WaitUntilState . NetworkIdle } ) ;
6868 return page ;
6969 }
7070
@@ -141,9 +141,9 @@ public async Task BlazorWasmStandalonePwaTemplate_Works(BrowserKind browserKind)
141141
142142 // The PWA template supports offline use. By now, the browser should have cached everything it needs,
143143 // so we can continue working even without the server.
144- await page . GoToAsync ( "about:blank" ) ;
144+ await page . GotoAsync ( "about:blank" ) ;
145145 await browser . SetOfflineAsync ( true ) ;
146- await page . GoToAsync ( listeningUri ) ;
146+ await page . GotoAsync ( listeningUri ) ;
147147 await TestBasicNavigation ( project . ProjectName , page , skipFetchData : true ) ;
148148 await page . CloseAsync ( ) ;
149149 }
@@ -189,9 +189,9 @@ public async Task BlazorWasmHostedPwaTemplate_Works(BrowserKind browserKind)
189189 // The PWA template supports offline use. By now, the browser should have cached everything it needs,
190190 // so we can continue working even without the server.
191191 // Since this is the hosted project, backend APIs won't work offline, so we need to skip "fetchdata"
192- await page . GoToAsync ( "about:blank" ) ;
192+ await page . GotoAsync ( "about:blank" ) ;
193193 await browser . SetOfflineAsync ( true ) ;
194- await page . GoToAsync ( listeningUri ) ;
194+ await page . GotoAsync ( listeningUri ) ;
195195 await TestBasicNavigation ( project . ProjectName , page , skipFetchData : true ) ;
196196 await page . CloseAsync ( ) ;
197197 }
@@ -424,11 +424,11 @@ private async Task TestBasicNavigation(string appName, IPage page, bool usesAuth
424424 // Initially displays the home page
425425 await page . WaitForSelectorAsync ( "h1 >> text=Hello, world!" ) ;
426426
427- Assert . Equal ( "Index" , ( await page . GetTitleAsync ( ) ) . Trim ( ) ) ;
427+ Assert . Equal ( "Index" , ( await page . TitleAsync ( ) ) . Trim ( ) ) ;
428428
429429 // Can navigate to the counter page
430430 await Task . WhenAll (
431- page . WaitForNavigationAsync ( "**/counter" ) ,
431+ page . WaitForNavigationAsync ( new ( ) { UrlString = "**/counter" } ) ,
432432 page . WaitForSelectorAsync ( "h1 >> text=Counter" ) ,
433433 page . WaitForSelectorAsync ( "p >> text=Current count: 0" ) ,
434434 page . ClickAsync ( "a[href=counter]" ) ) ;
@@ -441,12 +441,12 @@ await Task.WhenAll(
441441 if ( usesAuth )
442442 {
443443 await Task . WhenAll (
444- page . WaitForNavigationAsync ( "**/Identity/Account/Login**" , LifecycleEvent . Networkidle ) ,
444+ page . WaitForNavigationAsync ( new ( ) { UrlString = "**/Identity/Account/Login**" , WaitUntil = LifecycleEvent . Networkidle } ) ,
445445 page . ClickAsync ( "text=Log in" ) ) ;
446446
447447 await Task . WhenAll (
448448 page . WaitForSelectorAsync ( "[name=\" Input.Email\" ]" ) ,
449- page . WaitForNavigationAsync ( "**/Identity/Account/Register**" , LifecycleEvent . Networkidle ) ,
449+ page . WaitForNavigationAsync ( new ( ) { UrlString = "**/Identity/Account/Register**" , WaitUntil = LifecycleEvent . Networkidle } ) ,
450450 page . ClickAsync ( "text=Register as a new user" ) ) ;
451451
452452 var userName = $ "{ Guid . NewGuid ( ) } @example.com";
@@ -458,12 +458,12 @@ await Task.WhenAll(
458458
459459 // We will be redirected to the RegisterConfirmation
460460 await Task . WhenAll (
461- page . WaitForNavigationAsync ( "**/Identity/Account/RegisterConfirmation**" , LifecycleEvent . Networkidle ) ,
461+ page . WaitForNavigationAsync ( new ( ) { UrlString = "**/Identity/Account/RegisterConfirmation**" , WaitUntil = LifecycleEvent . Networkidle } ) ,
462462 page . ClickAsync ( "#registerSubmit" ) ) ;
463463
464464 // We will be redirected to the ConfirmEmail
465465 await Task . WhenAll (
466- page . WaitForNavigationAsync ( "**/Identity/Account/ConfirmEmail**" , LifecycleEvent . Networkidle ) ,
466+ page . WaitForNavigationAsync ( new ( ) { UrlString = "**/Identity/Account/ConfirmEmail**" , WaitUntil = LifecycleEvent . Networkidle } ) ,
467467 page . ClickAsync ( "text=Click here to confirm your account" ) ) ;
468468
469469 // Now we can login
@@ -474,21 +474,21 @@ await Task.WhenAll(
474474 await page . ClickAsync ( "#login-submit" ) ;
475475
476476 // Need to navigate to fetch page
477- await page . GoToAsync ( new Uri ( page . Url ) . GetLeftPart ( UriPartial . Authority ) ) ;
478- Assert . Equal ( appName . Trim ( ) , ( await page . GetTitleAsync ( ) ) . Trim ( ) ) ;
477+ await page . GotoAsync ( new Uri ( page . Url ) . GetLeftPart ( UriPartial . Authority ) ) ;
478+ Assert . Equal ( appName . Trim ( ) , ( await page . TitleAsync ( ) ) . Trim ( ) ) ;
479479 }
480480
481481 if ( ! skipFetchData )
482482 {
483483 // Can navigate to the 'fetch data' page
484484 await Task . WhenAll (
485- page . WaitForNavigationAsync ( "**/fetchdata" ) ,
485+ page . WaitForNavigationAsync ( new ( ) { UrlString = "**/fetchdata" } ) ,
486486 page . WaitForSelectorAsync ( "h1 >> text=Weather forecast" ) ,
487487 page . ClickAsync ( "text=Fetch data" ) ) ;
488488
489489 // Asynchronously loads and displays the table of weather forecasts
490490 await page . WaitForSelectorAsync ( "table>tbody>tr" ) ;
491- Assert . Equal ( 5 , ( await page . QuerySelectorAllAsync ( "p+table>tbody>tr" ) ) . Count ( ) ) ;
491+ Assert . Equal ( 5 , await page . Locator ( "p+table>tbody>tr" ) . CountAsync ( ) ) ;
492492 }
493493 }
494494
0 commit comments