Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[🐛 Bug]: Improvement to Element Send Keys documentation #2446

Open
@kentr

Description

What happened?

I suggest that the documentation for Send Keys should say that the target element must be keyboard-interactable instead of editable.

The W3C WebDriver current draft implies that keyboard-interactable is the only restriction:

The Element Send Keys command scrolls into view the form control element and then sends the provided keys to the element. In case the element is not keyboard-interactable, an element not interactable error is returned.

To test this on non-editable elements, I used the JavaScript WebDriver element.sendKeys() on a vanilla button element. It appears to work.

This the test that I used:

describe('Element Interactions', function () {
 let driver;
 before(async function () {
 driver = new Builder()
 .forBrowser(Browser.CHROME)
 .usingServer('http://selenium-chrome:4444')
 .build();
 });
 after(async () => await driver.quit());
 [{
 keyName: 'Space',
 key: Key.SPACE,
 },
 {
 keyName: 'Enter',
 key: Key.ENTER,
 }]
 .forEach(({ keyName, key }) => {
 it(`can use sendKeys on button element with ${keyName}`, async function () {
 await driver.get('https://www.selenium.dev/selenium/web/javascriptPage.html');
 const button = await driver.findElement(By.id('switchFocus'));
 assert.strictEqual(
 await driver.switchTo().activeElement().getAttribute('id'),
 ''
 );
 await button.sendKeys(key);
 assert.strictEqual(
 await driver.switchTo().activeElement().getAttribute('id'),
 'theworks'
 );
 });
 });
});

What browsers and operating systems are you seeing the problem on?

  • MacOS 14.7.7 (Sonoma).
  • Brave Browser 1.81.136 (Chromium 139.0.7258.143).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /