Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use OS-specific modifier key for 'select all text' command in toolbar_toolbar test #3115

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions test/tests/toolbar_toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const assertAttributeValues = require('../util/assertAttributeValues');
const assertRovingTabindex = require('../util/assertRovingTabindex');
const assertHasFocus = require('../util/assertHasFocus');
const assertAttributeCanBeToggled = require('../util/assertAttributeCanBeToggled');
const getOSPreferredModifierKey = require('../util/getOSPreferredModifierKey');

const exampleFile = 'content/patterns/toolbar/examples/toolbar.html';

Expand Down Expand Up @@ -1115,7 +1116,8 @@ ariaTest(
'toolbar-button-enter-or-space',
async (t) => {
let textarea = await t.context.session.findElement(By.css('textarea'));
await textarea.sendKeys(Key.chord(Key.CONTROL, 'a'));
let modifierKey = getOSPreferredModifierKey();
await textarea.sendKeys(Key.chord(modifierKey, 'a'));
let originalText = await textarea.getAttribute('value');

const buttons = await t.context.queryElements(
Expand Down Expand Up @@ -1206,7 +1208,8 @@ ariaTest(
'toolbar-button-enter-or-space',
async (t) => {
let textarea = await t.context.session.findElement(By.css('textarea'));
await textarea.sendKeys(Key.chord(Key.CONTROL, 'a'));
let modifierKey = getOSPreferredModifierKey();
await textarea.sendKeys(Key.chord(modifierKey, 'a'));
let originalText = await textarea.getAttribute('value');

const buttons = await t.context.queryElements(
Expand Down
6 changes: 6 additions & 0 deletions test/util/getOSPreferredModifierKey.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { Key } = require('selenium-webdriver');
const isMacOS = require('./isMacOS');

module.exports = function getOSPreferredModifierKey() {
return isMacOS() ? Key.META : Key.CONTROL;
};
3 changes: 3 additions & 0 deletions test/util/isMacOS.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function isMacOS() {
return process.platform === 'darwin';
};