File tree Expand file tree Collapse file tree
Tests/CSF.Screenplay.Selenium.Tests/Tasks Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ using System . Linq ;
12using CSF . Screenplay . Selenium . Elements ;
23using OpenQA . Selenium ;
34using static CSF . Screenplay . PerformanceStarter ;
@@ -30,4 +31,23 @@ public async Task GetShadowRootShouldResultInBeingAbleToReadTheShadowDomContent(
3031
3132 Assert . That ( text , Is . EqualTo ( "I am an element inside the Shadow DOM" ) ) ;
3233 }
34+
35+ [ Test , Screenplay ]
36+ public async Task GetShadowRootShouldResultInBeingAbleToReadACollectionOfShadowDomContent ( IStage stage )
37+ {
38+ var webster = stage . Spotlight < Webster > ( ) ;
39+ var browseTheWeb = webster . GetAbility < BrowseTheWeb > ( ) ;
40+
41+ if ( browseTheWeb . WebDriver . HasQuirk ( BrowserQuirks . CannotGetShadowRoot ) )
42+ Assert . Pass ( "This test cannot be run on the current web browser" ) ;
43+
44+ await Given ( webster ) . WasAbleTo ( OpenTheUrl ( testPage ) ) ;
45+ var shadowRoot = await When ( webster ) . AttemptsTo ( GetTheShadowRootFrom ( host ) ) ;
46+ var shadowContent = await Then ( webster ) . Should ( FindElementsWithin ( shadowRoot ) . WhichMatch ( content ) ) ;
47+ var text = await Then ( webster ) . Should ( ReadFromTheCollectionOfElements ( shadowContent ) . Text ( ) ) ;
48+
49+ using var scope = Assert . EnterMultipleScope ( ) ;
50+ Assert . That ( text , Has . Count . EqualTo ( 1 ) , "Count of elements found" ) ;
51+ Assert . That ( text . First ( ) , Is . EqualTo ( "I am an element inside the Shadow DOM" ) , "Correct text in found element" ) ;
52+ }
3353}
You can’t perform that action at this time.
0 commit comments