w3c / w3c/webdriver

Sendkeys to focussed element should not reset carat position

Open
#1,430 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Element Send Keys
Dominant language
HTML
Stars
718
Forks
228
PR merge metrics
No merged PRs in 30d

Description

There was some discussion on the selenium repository https://github.com/SeleniumHQ/selenium/issues/7330 about the spec specifying

  1. Let current text length be the JavaScript string’s length of element’s API value.
  2. Set the text insertion caret using set selection range using current text length for both the start and end parameters.

This will stop a scenario where a use attempts to modify the carat position from working correctly such as

  • SendKeys "abc"
  • SendKeys left arrow 3 times
  • Sendkeys "123"

the carat repositioning would be removed.

Based on the selenium thread, it seems like Firefox already does not reset the caret position if the field is in focus.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Selenium discussion and the sendkeys sequence described in this issue, then locate the WebDriver specification section defining text insertion and caret placement. Update the specification so sending keys to an already focused element preserves its caret position, and verify that the described abc, left-arrow, 123 scenario matches the clarified behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
html
Domain
documentation
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.