Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// However ' DELETE /wd/hub/session/*/actions' is not implmeneted at the very least in uiatomator2
// and `keys` crashes.
// thus, do same thing as WDIO except releaseActions
/**
* replace key with corresponding unicode character
*/
if (typeof value === 'string') {
keySequence = checkUnicode(value);
} else if (Array.isArray(value)) {
// `instanceof Array` behaves strange when executed through vm.runInNewContext,
// it returns false for arrays and `driver.keys()` tests for arrays using `instaceof Array`
// thus we test using Array.isArray instead
// https://github.com/felixge/node-sandboxed-module/issues/13#issuecomment-299585213
for (const charSet of value) {
keySequence = keySequence.concat(checkUnicode(charSet));
}
} else {
throw new Error('"keys" command requires a string or array of strings as parameter');
}
/**
* JsonWireProtocol action
*/
if (!this.driver.isW3C) {
this.driver.sendKeys(keySequence);
return;
}
/**
* W3C way of handle it key actions
*/
module.exports = function(value) {
this.helpers.assertArgument(value);
let keySequence = [];
// WDIO implmentation of keys command invokes 'releaseActions' for W3C.
// However ' DELETE /wd/hub/session/*/actions' is not implmeneted at the very least in uiatomator2
// and `keys` crashes.
// thus, do same thing as WDIO except releaseActions
/**
* replace key with corresponding unicode character
*/
if (typeof value === 'string') {
keySequence = checkUnicode(value);
} else if (Array.isArray(value)) {
// `instanceof Array` behaves strange when executed through vm.runInNewContext,
// it returns false for arrays and `driver.keys()` tests for arrays using `instaceof Array`
// thus we test using Array.isArray instead
// https://github.com/felixge/node-sandboxed-module/issues/13#issuecomment-299585213
for (const charSet of value) {
keySequence = keySequence.concat(checkUnicode(charSet));
}
} else {
throw new Error('"keys" command requires a string or array of strings as parameter');
}
/**
* JsonWireProtocol action
*/
if (!this.driver.isW3C) {