You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`WaitForSelectorAsync` is not enough, you want to wait for a more complex javascript expression to be truthly.
7
+
8
+
## Solution
9
+
10
+
Use [Page.WaitForExpressionAsync](https://www.puppeteersharp.com/api/PuppeteerSharp.Page.html#PuppeteerSharp_Page_WaitForExpressionAsync_System_String_PuppeteerSharp_WaitForFunctionOptions_) or [Page.WaitForFunctionAsync](https://www.puppeteersharp.com/api/PuppeteerSharp.Page.html#PuppeteerSharp_Page_WaitForFunctionAsync_System_String_PuppeteerSharp_WaitForFunctionOptions_System_Object___) to delay execution until the result of a javascription expression is truthly.
11
+
12
+
If it's a simple expression you can use `WaitForFunctionAsync`:
13
+
14
+
```cs
15
+
using (varbrowser=awaitPuppeteer.LaunchAsync(options))
16
+
using (varpage=awaitbrowser.NewPageAsync())
17
+
{
18
+
awaitpage.GoToAsync("https://www.somepage.com");
19
+
awaitPage.WaitForExpressionAsync("document.queryselector('#status_info').innerText.match('^Showing ([1-9][0-9]*?) to ([1-9][0-9]*?)') of ([1-9][0-9]*?) entries') != null");
20
+
}
21
+
```
22
+
23
+
If the evaluation is more complex, you could wrap it inside a function and use `WaitForFunctionAsync`:
24
+
25
+
```cs
26
+
varwaitTask=Page.WaitForFunctionAsync(@"() =>
27
+
{
28
+
return document.queryselector('#status_info').innerText.match('^Showing ([1-9][0-9]*?) to ([1-9][0-9]*?)') of ([1-9][0-9]*?) entries') != null;
0 commit comments