Skip to content

Commit 112e1af

Browse files
Copilotcsharpfritz
andcommitted
Fix Playwright test - check parent element for ad link href
Co-authored-by: csharpfritz <78577+csharpfritz@users.noreply.github.com>
1 parent 5b38b91 commit 112e1af

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

samples/AfterBlazorServerSide.Tests/ControlSampleTests.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,8 @@ public async Task AdRotator_DisplaysAd_WithCorrectAttributes()
114114
Assert.NotNull(altText);
115115
Assert.NotEmpty(altText);
116116

117-
// Assert - Ad is wrapped in an anchor tag with href
118-
var adLinkElement = await page.QuerySelectorAsync("a[href]");
119-
Assert.NotNull(adLinkElement);
120-
121-
var href = await adLinkElement.GetAttributeAsync("href");
117+
// Assert - Ad image is wrapped in an anchor tag with href (check parent element)
118+
var href = await adImage.EvaluateAsync<string>("el => el.parentElement?.tagName === 'A' ? el.parentElement.getAttribute('href') : null");
122119
Assert.NotNull(href);
123120
Assert.NotEmpty(href);
124121
}

0 commit comments

Comments
 (0)