Remote WebDriverElement seems more limited than it could be
According to the implementation of the remote web driver it will always use the splinter.driver.webdriver.remote.WebDriverElement as it's element class. This class, for instance, limits the possibility of certain actions, such as mouse over.
It turns out that it is actually possible to perform a mouse over using Chrome remote driver. I'm coding this solution in a current project, it merely replaces splinter.driver.webdriver.remote.WebDriverElement by splinter.driver.webdriver.WebDriverElement in the remote web driver class:
from splinter.driver.webdriver import WebDriverElement
from splinter.driver.webdriver.remote import WebDriver
class RemoteWebDriver(WebDriver):
"""A clone of the default remote web driver class, but using the non-remote
web driver element class."""
def __init__(self, *args, **kwargs):
super(RemoteWebDriver, self).__init__(*args, **kwargs)
self.element_class = WebDriverElement # overrides the element class
browser = RemoteWebDriver(browser='chrome', url=DRIVE_URL)
browser.find_by_css('#tooltip').mouse_over()
That said, my hunch is that maybe we might be too restrict with the limitations imposed by the remote WebDriverElement class. From this experiment it seems that at least remote Chrome can handle mouse overs⦠does that make sense?
If so, I suggest a roadmap to address this issue:
- [x] Test which of the limitations (
mouse_over,mouse_out,double_click,right_clickanddrag_and_drop) are still present in remote Chrome driver - [x] Test which of the limitations (
mouse_over,mouse_out,double_click,right_clickanddrag_and_drop) are still present in remote Firefox driver - [x] Refactor
splinter.driver.webdriver.WebDriverElementto allow users to perform actions supported in the tests from steps 1 and 2 (we might write two different classes, but details of the implementation are to be discussed latter IMHO)
~~We can edit~~ I just editted this table with the results of the tests:
| Action | Remote Chrome | Remote Firefox |
|---|---|---|
mouse_over |
β | β |
mouse_out |
π« | π« |
double_click |
β | β |
right_click |
β | β |
drag_and_drop |
β | β |
What do you think?
I'm +1 for this. We already does a little of it in the WebDriver subclasses, but not for WebDriverElement.
Great. I just ran some tests and can confirm that the 4 out of the 5 features listed in the table above work for Chrome and Firefox using the remote web driver. I used these 4 files to perform these tests, not sure if I tested it properly though:
index.htmla single page with JS to trigger something on the 5 features listed (mouse over and out, double click, right click and drag and drop)app.pya Pyhton app using Splinter to test these features in both browsers and print on the screen the result (if they succeeded or not)docker-compose.ymlto start up- a simple web server serving the
index.html - a standalone Chrome instance
- a standalone Firefox instance
- a Python container to run
app.py
- a simple web server serving the
- A
Dockerfilesetting upapp.pyto run
The output I got says mouse_out failed in both browsers:
[ x ] mouse_over chrome
[ ] mouse_out chrome
[ x ] double_click chrome
[ x ] right_click chrome
[ x ] drag_and_drop chrome
[ x ] mouse_over firefox
[ ] mouse_out firefox
[ x ] double_click firefox
[ x ] right_click firefox
What's next?
I would like to discuss how can we introduce tests for these new features. I mean, I see we can throw away my dirty jQuery impregnated HTML file and use the static/ ones already in the test suite. Yay! But my doubts concern the remote web driver setup:
- Should we add a tag to sip the test if the remote web driver is not running at
WebDriver.DEFAULT_URL? Or maybe ifos.environ.get('REMOTE_WEBDRIVER_URL')fails? - Should we really have a remote web driver or should we just mock it? The tests would basically be
mocked_method.assert_called_once_with(β¦)to make sure we're properly delegating the method call in this case. - Any other ideas for how to implement tests for these features?
As of #873, we're now testing Firefox and Chrome Remote as part of the unit tests, and all of these methods pass.