-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
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).