Context is provided in case anyone knows of an alternative way to solve the larger issue.
Problem Context
I am spearheading the development of a test automation framework for a web application which uses Web Components. This has presented a problem when testing in Internet Explorer, because Internet Explorer does not support Web Components natively; instead, a polyfill is used to provide this functionality.
A primary repercussion of this is that much of Selenium will not work as expected. It cannot 'see' the Shadow DOM in Internet Explorer the way it can in Firefox and Chrome.
The alternative is to write a test framework which provides an alternate mechanism for accessing elements via JavaScript - this allows elements to be located through the polyfill.
Our current implementation checks the WebDriver
being used, and either uses the original Selenium implementation of a method (in the case of Chrome or Firefox), or our own alternative implementation (in the case of Internet Explorer).
This means that we want our implementation to be as close as possible to Selenium's implementation, at its core, browser-interacty, level.
Problem
I am trying to replicate the functionality of Actions.click(WebElement onElement)
(source), in a simplified form (without following the Builder design pattern of the Actions
class, and making assumptions that the click is with the left mouse button and no other keys (Ctrl, Shift, Alt) are being held down).
I want to find the core code which handles the click does (specifically in Chrome, Firefox, and Internet Explorer), so I can replicate it as closely as possible, however I've found myself lost in a deep pit of classes and interfaces...
A new ClickAction
(source) is created (to later be performed). Performing this includes a 'click()' call on an instance of the Mouse
interface (source) ... aaaaand I'm lost. I see from generated JavaDoc that this is implemented by either EventFiringMouse (source) or HtmlUnitMouse (source), but I'm not sure which one will be implemented. I made an assumption (with little basis) that HtmlUnitMouse
would be used, which has led me further down the rabbit hole looking at HTMLUnit code from Gargoyle Software...
In short, I am totally lost.
Any guidance would be much appreciated :)
Research
- I have found that I was incorrect in my assumption that HTMLUnit is used by Chrome, Firefox, and Internet Explorer. Documentation shows that
RemoteWebDriver
(source) is subclassed byChromeDriver
,FirefoxDriver
, andInternetExplorerDriver
.
ChromeDriver
,FirefoxDriver
,InternetExplorerDriver
,HtmlUnitDriver
, others.. Each one behaves differently, according to the underlying browser. So the first step is to decide one of them and dig deeper. – FibrinolysisEventFiringMouse
andHtmlUnitMouse
in some depth however I was unable to make much progress with either. – BizHtmlUnitDriver
, or with HtmlUnit? – FibrinolysisActions.click(WebElement element)
is executed. I am not looking at a specific case. I am looking at how this is done in Chrome, Firefox, and Internet Explorer (I am not sure if I was mistaken in my assumption that they useHtmlUnit...
) – BizRemoteDriver
, which means the actual code is on the server side of your call. None uses HtmlUnit which is a browser simulator, and it doesn't use the RemoteDriver. I suggest that you use a browser that handles WebComponents, and if it doesn't correctly handleclick
, open a bug to the relevant team. – FibrinolysisRemoteDriver
, but "just raise a bug with someone else and stop working on the problem" is not a helpful solution for us. – BizWebElement.click
works? – Ethno