Skip to content

Commit

Permalink
fix: add new kind of keyboard
Browse files Browse the repository at this point in the history
and make sure to wait a bit in between ecp key invocations too for stability
  • Loading branch information
jlipps committed Jan 22, 2024
1 parent 5320448 commit 7b3e21d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/commands/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,9 @@ function nodeIsFocused (n, strict = false) {
}

export async function setValue (text, elId) {
const oldCooldown = this.opts.keyCooldown;
let action = this.setValueByEcp.bind(this);
this.opts.keyCooldown = 500; // if it's 0, sometimes sending keys via ECP clobbers each other

let chars = text;
// if we got a string rather than an array of chars, split it up
Expand All @@ -337,11 +339,10 @@ export async function setValue (text, elId) {
}

if (this.opts.typeIndividualKeys) {
this.opts.keyCooldown = 0;
action = this.setValueByKeyboard.bind(this);
}

const oldCooldown = this.opts.keyCooldown;
this.opts.keyCooldown = 0;
try {
await this.performActionWithKeyboard(async () => await action(chars), elId);
} finally {
Expand All @@ -351,8 +352,9 @@ export async function setValue (text, elId) {

export async function performActionWithKeyboard (action, elId) {
const kbSelector = '//StdDlgKeyboardItem[@focused="true"] | ' +
'//Keyboard[@focused="true"] | ' +
'//CustomKeyboard';
'//Keyboard[@focused="true"] | ' +
'//CustomKeyboard | ' +
'//BetaCustomKeyboard';
try {
await this.findElOrEls('xpath', kbSelector, false);
} catch (ign) {
Expand Down
1 change: 1 addition & 0 deletions lib/commands/roku.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export async function executeRoku (rokuCommand, opts = /** @type {TOpts} */({}))
export async function roku_pressKey ({key}) {
await this.rokuEcp(`/keypress/${key}`);
if (this.opts.keyCooldown) {
this.log.debug(`Waiting ${this.opts.keyCooldown}ms`);
await B.delay(this.opts.keyCooldown);
}
this._cachedSourceDirty = true;
Expand Down

0 comments on commit 7b3e21d

Please sign in to comment.