Skip to content

[πŸ› Bug]: Unable to send proper key event for \u2019 (keycode empty)Β #11638

@reece-white

Description

@reece-white

What happened?

Issue:
The keyboard shortcut on macOS to enable firefox picture-in-picture mode is command + Shift + option + ]. In JavaScript these are dispatched as 3 KeyboardEvents: 'Meta/Command', 'Alt', 'Shift', '’'. The ’ key is sent with a combination of option/alt + ]. It is impossible to send this combination using WebDriver.

Steps to reproduce:
await action.keyDown(Key.ALT).sendKeys(']').keyDown(Key.COMMAND).keyDown(Key.SHIFT).perform();

Expected result:
Picture in picture launched in Firefox
A trusted KeyboardEvent is dispatched that looks like:

isTrusted: true
altKey: false
bubbles: true
cancelBubble: false
cancelable: true
charCode: 0
code: "BracketRight"
composed: true
ctrlKey: false
currentTarget: null
defaultPrevented: false
detail: 0
eventPhase: 0
isComposing: false
key: "]"
keyCode: 221
location: 0
metaKey: false
repeat: false
returnValue: true
shiftKey: false
sourceCapabilities: InputDeviceCapabilities {firesTouchEvents: false}
srcElement: body
target: body
timeStamp: 61259.80000001192
type: "keyup"
view: Window {window: Window, self: Window, document: document, name: '', location: Location, …}
which: 221
[[Prototype]]: KeyboardEvent

Actual events:
action.sendKeys(Key.ALT).sendKeys('’').perform()

isTrusted: true
altKey: false
bubbles: true
cancelBubble: false
cancelable: true
charCode: 0
code: ""
composed: true
ctrlKey: false
currentTarget: null
defaultPrevented: false
detail: 0
eventPhase: 0
isComposing: false
key: "’"
keyCode: 0
location: 0
metaKey: false
repeat: false
returnValue: true
shiftKey: false
sourceCapabilities: InputDeviceCapabilities {firesTouchEvents: false}
srcElement: body
target: body
timeStamp: 4728.29999999702
type: "keydown"
view: Window {window: Window, self: Window, document: document, name: '', location: Location, …}
which: 0
[[Prototype]]: KeyboardEvent

action.sendKeys(Key.ALT).sendKeys(']').perform()

isTrusted: true
altKey: true
bubbles: true
cancelBubble: false
cancelable: true
charCode: 0
code: "BracketRight"
composed: true
ctrlKey: false
currentTarget: null
defaultPrevented: false
detail: 0
eventPhase: 0
isComposing: false
key: "]"
keyCode: 221
location: 0
metaKey: false
repeat: false
returnValue: true
shiftKey: false
sourceCapabilities: InputDeviceCapabilities {firesTouchEvents: false}
srcElement: body
target: body
timeStamp: 4046.5
type: "keydown"
view: Window {window: Window, self: Window, document: document, name: '', location: Location, …}
which: 221
[[Prototype]]: KeyboardEvent

How can we reproduce the issue?

const { Builder, Key, By, until } = require('selenium-webdriver');

(async function example() {
    let driver = await new Builder().forBrowser('firefox').build();
    try {
        await driver.get('http://developers.canal-plus.com/rx-player/');
        await driver.wait(until.elementLocated(By.className('choice-input-button')), 10000);
        // To see the event in the console
        await driver.executeScript(() => {
            window.addEventListener('keydown', (e) => {
                console.log(e);
            });
        });
        await driver.findElement(By.className('choice-input-button')).click()
        // Wait for video to start
        await driver.sleep(5000);
        await driver.actions().keyDown(Key.ALT).keyDown(Key.COMMAND).keyDown(Key.SHIFT).sendKeys('\u2019').perform()
        await driver.sleep(15000);
    } finally {
        await driver.quit();
    }
})();


### Relevant log output

```shell
No log

Operating System

macOS Monteret

Selenium version

^4.8.0

What are the browser(s) and version(s) where you see this issue?

Chrome 110, Firefox 109

What are the browser driver(s) and version(s) where you see this issue?

geckodriver 0.32.0, ChromeDriver 109.0.5414.74

Are you using Selenium Grid?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!G-geckodriverRequires fixes in GeckoDriverI-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions