Page.Evaluate returns undefined for a specific site
reginaldl opened this issue · 4 comments
Hi,
I'm calling Page.Evaluate while browsing a specific site and it consistently returns nil (no error though).
Here's the debug traces:
SEND>
{"guid":"frame@77e4062f9cb0cdcd0f9aeb454d7a1983","id":45,"metadata":{"apiName":"SerializeCallStack","isInternal":false,"location":{"file":"connection.go","line":162},"wallTime":78307000},"method":"evaluateExpression","params":{"arg":{"handles":[],"value":{"n":42}},"expression":"l =\u003e String(l)"}}
RECV>
{"id":45,"guid":"","result":{"value":{"v":"undefined"}}}
Any JS would return undefined
. The site is starpets.gg.
It reproduces with all browsers.
Is there any reason why evaluate would not fail but yet return undefined?
If this is a playwright bug, what's the best way to report it coming from playwright-go?
Thanks!
can't reproduce via:
canstand@4b2c84c
can't reproduce via: canstand@4b2c84c
Oh interesting, so it turns out that it returns nil exclusively when using playwright.WaitUntilStateNetworkidle
.
Updating the following line should repro:
_, err = page.Goto("https://starpets.gg", playwright.PageGotoOptions{WaitUntil: playwright.WaitUntilStateNetworkidle})
networkidle DISCOURAGED
Thanks for your detailed answer.
Networkidle is discouraged, for tests, because it relies on sleeps (500ms).
Most time based expectations are an anti-pattern in testing, hence the "DISCOURAGED".
However it doesn't explain why page.evaluate would have an unexpected behavior.
I ended up filing a bug upstream as I could repro with node: microsoft/playwright#29440