Skip to content

Commit e3ae546

Browse files
kblokMeir017
authored andcommitted
Improve waiting for selector to be hidden error message (#635)
* Improve waiting for selector to be hidden error message * cr
1 parent 0286563 commit e3ae546

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lib/PuppeteerSharp.Tests/FrameTests/WaitForSelectorTests.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,19 @@ public async Task ShouldRespectTimeout()
178178
var exception = await Assert.ThrowsAsync<WaitTaskTimeoutException>(async ()
179179
=> await Page.WaitForSelectorAsync("div", new WaitForSelectorOptions { Timeout = 10 }));
180180

181-
Assert.NotNull(exception);
182181
Assert.Contains("waiting for selector 'div' failed: timeout", exception.Message);
183182
}
184183

184+
[Fact]
185+
public async Task ShouldHaveAnErrorMessageSpecificallyForAwaitingAnElementToBeHidden()
186+
{
187+
await Page.SetContentAsync("<div></div>");
188+
var exception = await Assert.ThrowsAsync<WaitTaskTimeoutException>(async ()
189+
=> await Page.WaitForSelectorAsync("div", new WaitForSelectorOptions { Hidden = true, Timeout = 10 }));
190+
191+
Assert.Contains("waiting for selector 'div' to be hidden failed: timeout", exception.Message);
192+
}
193+
185194
[Fact]
186195
public async Task ShouldRespondToNodeAttributeMutation()
187196
{

lib/PuppeteerSharp/Frame.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ function hasVisibleBoundingBox() {
547547
this,
548548
predicate,
549549
false,
550-
$"{(isXPath ? "XPath" : "selector")} '{selectorOrXPath}'",
550+
$"{(isXPath ? "XPath" : "selector")} '{selectorOrXPath}'{(options.Hidden ? " to be hidden" : "")}",
551551
options.Polling,
552552
options.PollingInterval,
553553
options.Timeout,
@@ -557,7 +557,7 @@ function hasVisibleBoundingBox() {
557557
isXPath,
558558
options.Visible,
559559
options.Hidden
560-
}).Task.ConfigureAwait(false);
560+
}).Task.ConfigureAwait(false);
561561
return handle as ElementHandle;
562562
}
563563

0 commit comments

Comments
 (0)