Skip to content

Commit e0c8e8f

Browse files
committed
Add further test coverage to #326
1 parent 75811b5 commit e0c8e8f

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Tests/CSF.Screenplay.Selenium.Tests/Tasks/GetShadowRootTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Linq;
12
using CSF.Screenplay.Selenium.Elements;
23
using OpenQA.Selenium;
34
using 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
}

0 commit comments

Comments
 (0)