Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
commands.executeMobile = async function executeMobile (mobileCommand, opts = {}) {
// we only support mobile: scroll
if (mobileCommand === 'scroll') {
await this.mobileScroll(opts);
} else if (mobileCommand === 'viewportScreenshot') {
return await this.getViewportScreenshot();
} else {
throw new errors.UnknownCommandError('Unknown command, all the mobile commands except scroll have been removed.');
}
};
enrollBiometric: 'mobileEnrollBiometric',
sendBiometricMatch: 'mobileSendBiometricMatch',
isBiometricEnrolled: 'mobileIsBiometricEnrolled',
clearKeychains: 'mobileClearKeychains',
getPermission: 'mobileGetPermission',
siriCommand: 'mobileSiriCommand',
deleteFile: 'mobileDeleteFile',
deleteFolder: 'mobileDeleteFolder',
};
if (!_.has(commandMap, mobileCommand)) {
throw new errors.UnknownCommandError(`Unknown mobile command '${mobileCommand}'. Only ${_.keys(commandMap).join(', ')} commands are supported.`);
}
return await this[commandMap[mobileCommand]](opts);
};
if (this.isWebContext()) {
let atomsElement = this.getAtomsElement(el);
if (_.isNull(atomsElement)) {
throw new errors.UnknownError(`Error converting element ID for using in WD atoms: '${el}'`);
} else {
return await this.executeAtom('get_attribute_value', [atomsElement, attribute]);
}
} else {
if (attribute === 'contentSize') {
return await this.getElementContentSize(el);
}
if (_.includes(['label', 'name', 'value', 'values', 'hint'], attribute)) {
let command = `au.getElement('${el}').${attribute}()`;
return await this.uiAutoClient.sendCommand(command);
} else {
throw new errors.UnknownCommandError(`UIAElements don't have the attribute '${attribute}'`);
}
}
};
deviceInfo: 'mobileGetDeviceInfo',
changePermissions: 'mobileChangePermissions',
getPermissions: 'mobileGetPermissions',
performEditorAction: 'mobilePerformEditorAction',
startScreenStreaming: 'mobileStartScreenStreaming',
stopScreenStreaming: 'mobileStopScreenStreaming',
getNotifications: 'mobileGetNotifications',
};
if (!_.has(mobileCommandsMapping, mobileCommand)) {
throw new errors.UnknownCommandError(`Unknown mobile command "${mobileCommand}". ` +
`Only ${_.keys(mobileCommandsMapping)} commands are supported.`);
}
return await this[mobileCommandsMapping[mobileCommand]](opts);
};
changePermissions: 'mobileChangePermissions',
getPermissions: 'mobileGetPermissions',
performEditorAction: 'mobilePerformEditorAction',
sensorSet: 'sensorSet',
startScreenStreaming: 'mobileStartScreenStreaming',
stopScreenStreaming: 'mobileStopScreenStreaming',
getNotifications: 'mobileGetNotifications',
};
if (!_.has(mobileCommandsMapping, mobileCommand)) {
throw new errors.UnknownCommandError(`Unknown mobile command "${mobileCommand}". ` +
`Only ${_.keys(mobileCommandsMapping)} commands are supported.`);
}
return await this[mobileCommandsMapping[mobileCommand]](opts);
};