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
We are using EventFiringWebDriver, which returns EventFiringWebElements. In our source, we have an IWebElement wrapping class called WebElementWrapper, which implements IWebElement, IWrapsElement, ILocatable. When using our WebElementWrappers within an Action builder, we get the following exception: "Target element cannot be converted to IWebElementReference".
Our setup...
publicinterfaceIWebElementWrapper:IWebElement,IWrapsElement,ILocatable{// Excluded for brevity}publicclassWebElementWrapper:IWebElementWrapper{privateIWebElement_webElement;publicIWebElementWebElement{get{if(_webElement==null){_webElement= GetWebElement();}return_webElement;}}publicIWebElementWrappedElement=> WebElement;// Excluded irrelevant content for brevity}[TestClass]publicclassTests{[TestMethod]publicvoidTest(){// WebDriver is an EventFiringWebDrivernew Actions(WebDriver).MoveToElement(WebElementWrapperClassInstance).Click().Build().Perform();}}
It seems the cause of this is the implementation here (shown below with my comments)
// OpenQA.Selenium.Interactions.PointerInputDevice.PointerMoveInteractionprivateDictionary<string,object>ConvertElement(){// this.target is an IWebElement, which doesn't necessarily implement IWebDriverObjectReferenceIWebDriverObjectReferenceelementReference=this.target as IWebDriverObjectReference;if(elementReference==null){// We are falling to backup IWrapsElement, however IWrapsElement also does not necessarily implement IWebDriverObjectReferenceIWrapsElementelementWrapper=this.target as IWrapsElement;if(elementWrapper!=null){// In our scenario, since our IWebElement originated from EventFiringWebDriver, it is actually an EventFiringWebElement// which does not implement IWebDriverObectReference so it ends up being null here.elementReference= elementWrapper.WrappedElement as IWebDriverObjectReference;}}if(elementReference==null){thrownew ArgumentException("Target element cannot be converted to IWebElementReference");}Dictionary<string,object>elementDictionary= elementReference.ToDictionary();returnelementDictionary;}
In combination with the fact that EventFiringWebDriver issues EventFiringWebElements, which do not implement IWebDriverObjectReference like their WebElement cousins EventFiringWebElement
@ZachBergman, thank you for creating this issue. We will troubleshoot it as soon as we can.
Info for maintainers
Triage this issue by using labels.
If information is missing, add a helpful comment and then I-issue-template label.
If the issue is a question, add the I-question label.
If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable G-* label, and it will provide the correct link and auto-close the
issue.
After troubleshooting the issue, please add the R-awaiting answer label.
Thank you!
ZachBergman
changed the title
[🐛 Bug]: Unable to use wrapped IWebElements from EventFiringWebDriver within Actions
[🐛 Bug]: [dotnet] Unable to use wrapped IWebElements from EventFiringWebDriver within Actions
Sep 17, 2024
What happened?
We are using EventFiringWebDriver, which returns EventFiringWebElements. In our source, we have an IWebElement wrapping class called WebElementWrapper, which implements IWebElement, IWrapsElement, ILocatable. When using our WebElementWrappers within an Action builder, we get the following exception: "Target element cannot be converted to IWebElementReference".
Our setup...
It seems the cause of this is the implementation here (shown below with my comments)
In combination with the fact that EventFiringWebDriver issues EventFiringWebElements, which do not implement IWebDriverObjectReference like their WebElement cousins
EventFiringWebElement
WebElement
How can we reproduce the issue?
Relevant log output
System.ArgumentException "Target element cannot be converted to IWebElementReference"
Operating System
Windows 10
Selenium version
4.18.0
What are the browser(s) and version(s) where you see this issue?
Any
What are the browser driver(s) and version(s) where you see this issue?
Any
Are you using Selenium Grid?
No
The text was updated successfully, but these errors were encountered: