question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Click invisible element

See original GitHub issue

Apologies, another one, we don’t seem to be able to click an ‘invisible item’… The item becomes visible via mouseover but is clickable when hidden nevertheless (verified).

We tried a couple of settings with the force option but without succes. ClickAsync("#button1", 0, MouseButton.Left, 1, null, null, null, true, null);

What are we doing wrong?

Thanks, -M

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
kblokcommented, Oct 12, 2020

@kababoom I was able to solve this using mouse emulation. What do you think?

await page.GoToAsync("https://www.w3schools.com/howto/howto_css_dropdown.asp");
var btn = await page.QuerySelectorAsync(".dropbtn");
var box = await btn.GetBoundingBoxAsync();
await page.Mouse.MoveAsync(box.X + (box.Width / 2), box.Y + (box.Height / 2));
var option = await page.QuerySelectorAsync("text=Link 1");
var optionBox = await option.GetBoundingBoxAsync();
await page.Mouse.MoveAsync(optionBox.X + (optionBox.Width / 2), optionBox.Y + (optionBox.Height / 2));
await option.ClickAsync();
2reactions
kblokcommented, Oct 13, 2020

@kababoom the idea of the ClickAsync function is to emulate a user action. If the element is not visible there’s no chance of a user action.

ClickAsync is not a map of the click function in javascript. If you want to use the click function you can use EvalOnSelectorAsync.

await page.EvalOnSelectorAsync("#button1", "el => el.click()");
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to click on hidden element in Selenium WebDriver?
First store that element in object, let's say element and then write following code to click on that hidden element:
Read more >
How do you click on an element which is hidden using ...
Mostly the hidden elements are defined by the CSS property style="display:none;". In case an element is a part of the form tag, it...
Read more >
How To Find Hidden Elements In Selenium WebDriver ...
Examples of hidden elements in the DOM · Check if the 'Click Me!' button is displayed. · Click on the 'Click Me!' button,...
Read more >
How to Click Invisible Element - Studio
In the event it is invisible, but only present when you hover to the top-right, you can leverage the Hover Activity, then Click...
Read more >
[Question] How to click hidden elements? · Issue #12267
await page.locator('#foobar:visible').click(). That will do nothing, because :visible selector finds only visible elements and hidden one ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found