Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | 69x 69x 69x 69x 35x 47x 12x 35x 12x 35x 35x 35x 22x 35x 35x 35x 35x 8x 35x 69x 34x 34x 1x 33x 1x 32x 16x 33x 1x 15x 1x 69x 23x 12x 23x 23x 34x 19x | /** * Constants around commands */ const TOUCH_ACTIONS = ['press', 'longPress', 'tap', 'moveTo', 'wait', 'release'] const POS_ACTIONS = TOUCH_ACTIONS.slice(0, 4) const ACCEPTED_OPTIONS = ['x', 'y', 'element'] export const formatArgs = function (scope, actions) { return actions.map((action) => { if (Array.isArray(action)) { return formatArgs(scope, action) } if (typeof action === 'string') { action = { action } } const formattedAction = { action: action.action, options: {} } /** * don't propagate for actions that don't require element options */ const actionElement = action.element && typeof action.element.elementId === 'string' ? action.element.elementId : scope.elementId if (POS_ACTIONS.includes(action.action) && actionElement) { formattedAction.options.element = actionElement } if (isFinite(action.x)) formattedAction.options.x = action.x if (isFinite(action.y)) formattedAction.options.y = action.y if (action.ms) formattedAction.options.ms = action.ms /** * remove options property if empty */ if (Object.keys(formattedAction.options).length === 0) { delete formattedAction.options } return formattedAction }) } /** * Make sure action has proper options before sending command to Appium. * * @param {Object} params touchAction parameters * @return null */ export const validateParameters = (params) => { const options = Object.keys(params.options || {}) if (params.action === 'release' && options.length !== 0) { throw new Error( 'action "release" doesn\'t accept any options ' + `("${options.join('", "')}" found)` ) } if ( params.action === 'wait' && (options.includes('x') || options.includes('y')) ) { throw new Error('action "wait" doesn\'t accept x or y options') } if (POS_ACTIONS.includes(params.action)) { for (const option in params.options) { if (!ACCEPTED_OPTIONS.includes(option)) { throw new Error(`action "${params.action}" doesn't accept "${option}" as option`) } } if (options.length === 0) { throw new Error( `Touch actions like "${params.action}" need at least some kind of ` + 'position information like "element", "x" or "y" options, you\'ve none given.' ) } } } export const touchAction = function (actions) { if (!Array.isArray(actions)) { actions = [actions] } const formattedAction = formatArgs(this, actions) const protocolCommand = Array.isArray(actions[0]) ? ::this.multiTouchPerform : ::this.touchPerform formattedAction.forEach((params) => validateParameters(params)) return protocolCommand(formattedAction) } |