webdriver
webdriver copied to clipboard
[actions] Handling of "display:none" element as origin
This should probably return "move target out of bounds" or something, but at the moment the spec algorithm doesn't account for the possibility of an element without bounding client rects.
For https://bugzilla.mozilla.org/show_bug.cgi?id=1805146 I reviewed the behavior of various browsers when trying to trigger a click on an option element of a select (which has no bounding client rect). My test code was:
def test_click_select(session, url, inline, mouse_chain):
session.url = inline("""
<select>
<option value="foo">Foo</option>
<option value="bar">Bar</option>
</select>
""")
select = session.find.css("select", all=False)
mouse_chain.click(element=select).perform()
option = session.find.css("option[value='bar']", all=False)
mouse_chain.click(element=option).perform()
value = session.execute_script("return document.querySelector('select').value;")
assert value == "bar"
And testing on various browsers, I had the following results:
- Firefox fails with
webdriver.error.MoveTargetOutOfBoundsException: move target out of bounds (500): Origin element is not displayed - Chrome fails with
webdriver.error.WebDriverException: element not interactable (400): element not interactable: [object HTMLOptionElement] has no size and location - Safari completes the test without throwing any error but fails the assert, meaning it didn't actually click on the option
(see the bug for results with older Firefox versions, as I was trying to check if there had been a regression on that front)