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
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
The text was updated successfully, but these errors were encountered:
🐛 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:
Now, I can easily access any element. There is no problem with that:
var btnElement = driver.FindElement(By.CcsSelector("button"));
// btnElement contains a valid referenceNow 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
The text was updated successfully, but these errors were encountered: