hardkoded / puppeteer-sharp

Headless Chrome .NET API
https://www.puppeteersharp.com
MIT License
3.41k stars 442 forks source link

ClickablePointAsync throws error "Node is either not visible or not an HTMLElement" #2037

Closed MartinDlt closed 2 years ago

MartinDlt commented 2 years ago

Version 8.0.0

ClickablePointAsync fails at !quads.Any(), I debugged during the run and found out that the values of the BoxModelPoints are reset to 0 directly after ApplyOffsetsToQuad. Before it is called this was one of my BoxModelPoints: {X = 75.5, Y = 191.0}

offsetX = 0 offsetY = 0

after ApplyOffsetsToQuad, my point is: {X = 0, Y = 0}

kblok commented 2 years ago

Do we have any code example to test?

MartinDlt commented 2 years ago
var url = "http://127.0.0.1:9123";
using var browser = await Puppeteer.ConnectAsync( new ConnectOptions { BrowserURL = url, SlowMo = 0 });
var pages = await browser.PagesAsync();
var pageOne = pages[0];
await pageOne.GoToAsync("https://en.wikipedia.org/wiki/Main_Page");

...

var s = (await pageOne.XPathAsync("//span[text()=\"From today's featured article\"]")).First();
var point = await s.ClickablePointAsync();
pageOne.Mouse.ClickAsync(point.X, point.Y, new ClickOptions());

I connect to a CefSharp client inside a WPF application with the port 9123. The main problem I have is that this doesn't work consistently for me. It failed consistently yesterday, but doesn't fail today, despite no code being altered in between.

EDIT: We use net6.0

EDIT 2: We might have found the issue. Currently our browser starts twice, with duplicates of the same page. However one of these pages are invisible. So it finds the element, but it wont be visible.

Therefore I think this issue can probably be closed.