WebDriver:ElementSendKeys should only set the caret if the element is not focused
Categories
(Remote Protocol :: Marionette, defect)
Tracking
(firefox107 fixed)
Tracking | Status | |
---|---|---|
firefox107 | --- | fixed |
People
(Reporter: jdescottes, Assigned: jgraham)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
(deleted),
text/x-phabricator-request
|
Details |
From https://github.com/mozilla/geckodriver/issues/2015
The spec at https://www.w3.org/TR/webdriver/#element-send-keys says
Otherwise
- If element does not currently have focus, let current text length be the length of element’s API value.
- Set the text insertion caret using set selection range using current text length for both the start and end parameters.
I think we can only run step 2 (updating the caret position) if the element does not have focus, otherwise current text length
is not set? Might need to clarify this first.
But if this is confirmed, marionette is currently unconditionally updating the selection range whenever sendKeys is used https://searchfox.org/mozilla-central/rev/b1e5f2c7c96be36974262551978d54f457db2cae/remote/marionette/interaction.js#634-635 and we should update it to only update the caret if the input is not focused.
Reporter | ||
Comment 1•2 years ago
|
||
James, what do you think about the WebDriver spec extract in the summary? Do you agree that step 2 should only be done if step 1 If element does not currently have focus
was true? Is that a bug in the spec that should be clarified?
Assignee | ||
Comment 2•2 years ago
|
||
OK, so I agree that the spec is wrong at the point you mentioned. But it's more fundamentally broken too: step 7 always focuses the element, so everything in step 8 that happens if the element doesn't have focus should never happen. So I think a strict reading of the current spec is that gecko's behaviour is correct and we should call focus()
on the element, but never change the cursor position. I'm almost certain that's not what's intended.
I think the expected behaviour is basically:
- Check if the element has focus
- If not, give element the focus and set the cursor position to the end
Assignee | ||
Updated•2 years ago
|
Assignee | ||
Comment 3•2 years ago
|
||
https://github.com/w3c/webdriver/pull/1686 for the spec
Assignee | ||
Comment 4•2 years ago
|
||
Only if the element isn't already focused. If it is already focused,
don't alter the focus.
Updated•2 years ago
|
Updated•2 years ago
|
Comment 7•2 years ago
|
||
bugherder |
Updated•2 years ago
|
Updated•2 years ago
|
Description
•