Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't click any element inside an iframe which itself is a part of shadow DOM #9589

Closed
OrestKavnyi opened this issue Jun 17, 2021 · 1 comment

Comments

@OrestKavnyi
Copy link

🐛 Bug Report

Cannot click an element that lies inside an iframe element which itself is a part of shadow DOM.
First I read the shadowRoot property of the shadowHost element using ExecuteScript() method from under driver:
var root = (IWebElement)(driver as IJavaScriptExecutor).ExecuteScript("return arguments[0].shadowRoot");

Then I am able to locate the iframe lying inside that shadowRoot element and switch to it like this:

var iframe = root.FindElement(By.TagName("iframe"));
driver.SwitchTo().Frame(iframe);

Now, I can easily access any element. There is no problem with that:
var btnElement = driver.FindElement(By.CcsSelector("button")); // btnElement contains a valid reference

Now trying to click that element like this btnElement.Click(); throws the WebDriverException saying "unknown error: no element reference returned by script".

An interesting fact is that I can simulate Click with SendKeys(Keys.Enter) invoked from under the element (btnElement in this case). Js click performed in the folowing way:
(driver as IJavaScriptExecutor).ExecuteScript("arguments[0].click();", btnElement);
also works fine.

I also tried switching to earlier versions of Selenium WebDriver (down to 2.39.0) but got nowhere, - I was still able to reproduce the issue.

So, if you have any thoughts/ideas about what might cause the issue, please let me know. I would really appreciate any help!

Environment

OS: Windows 10
Browser: Chrome
Browser version: 91.0.4472.106
Browser Driver version: 91.0.4472.101
Language Bindings version: C#, 3.141.0

@ghost ghost added the needs-triaging label Jun 17, 2021
@diemol
Copy link
Member

diemol commented Jun 17, 2021

There is no support yet for shadow DOM yet in Selenium, please follow #5869 for updates.

As for this issue, it looks more like a question than an issue (given that shadow DOM is not supported yet).

💡 A better way to address this is:

@diemol diemol closed this as completed Jun 17, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants