Best JavaScript code snippet using appium-base-driver
gesture.js
Source:gesture.js
...54 .filter((innerAction) => !(innerAction.type === 'pause' && innerAction.duration === 0));55 return modifiedAction;56 });57 log.debug(`Preprocessed actions: ${JSON.stringify(preprocessedActions, null, ' ')}`);58 return await this.proxyCommand('/actions', 'POST', {actions: preprocessedActions});59};60commands.performTouch = async function (gestures) {61 log.debug(`Received the following touch action: ${gesturesChainToString(gestures)}`);62 return await this.proxyCommand('/wda/touch/perform', 'POST', {actions: gestures});63};64commands.performMultiAction = async function (actions) {65 log.debug(`Received the following multi touch action:`);66 for (let i in actions) {67 log.debug(` ${parseInt(i, 10)+1}: ${_.map(actions[i], 'action').join('-')}`);68 }69 return await this.proxyCommand('/wda/touch/multi/perform', 'POST', {actions});70};71commands.nativeClick = async function (el) {72 el = util.unwrapElement(el);73 let endpoint = `/element/${el}/click`;74 return await this.proxyCommand(endpoint, 'POST', {});75};76/*77 * See https://github.com/facebook/WebDriverAgent/blob/master/WebDriverAgentLib/Commands/FBElementCommands.m78 * to get the info about available WDA gestures API79 *80 * See https://developer.apple.com/reference/xctest/xcuielement and81 * https://developer.apple.com/reference/xctest/xcuicoordinate to get the detailed description of82 * all XCTest gestures83*/84helpers.mobileScroll = async function (opts={}, swipe=false) {85 if (!opts.element) {86 opts.element = await this.findNativeElementOrElements(`class name`, `XCUIElementTypeApplication`, false);87 }88 // WDA supports four scrolling strategies: predication based on name, direction,89 // predicateString, and toVisible, in that order. Swiping requires direction.90 let params = {};91 if (opts.name && !swipe) {92 params.name = opts.name;93 } else if (opts.direction) {94 if (['up', 'down', 'left', 'right'].indexOf(opts.direction.toLowerCase()) < 0) {95 let msg = 'Direction must be up, down, left or right';96 log.errorAndThrow(msg);97 }98 params.direction = opts.direction;99 } else if (opts.predicateString && !swipe) {100 params.predicateString = opts.predicateString;101 } else if (opts.toVisible && !swipe) {102 params.toVisible = opts.toVisible;103 } else {104 let msg = swipe ? 'Mobile swipe requires direction' : 'Mobile scroll supports the following strategies: name, direction, predicateString, and toVisible. Specify one of these';105 log.errorAndThrow(msg);106 }107 // we can also optionally pass a distance which appears to be a ratio of108 // screen height, so 1.0 means a full screen's worth of scrolling109 if (!swipe && opts.distance) {110 params.distance = opts.distance;111 }112 let element = opts.element.ELEMENT || opts.element;113 let endpoint = `/wda/element/${element}/${swipe ? 'swipe' : 'scroll'}`;114 return await this.proxyCommand(endpoint, 'POST', params);115};116helpers.mobileSwipe = async function (opts={}) {117 return await this.mobileScroll(opts, true);118};119function parseFloatParameter (paramName, paramValue, methodName) {120 if (_.isUndefined(paramValue)) {121 log.errorAndThrow(`"${paramName}" parameter is mandatory for "${methodName}" call`);122 }123 const result = parseFloat(paramValue);124 if (isNaN(result)) {125 log.errorAndThrow(`"${paramName}" parameter should be a valid number. "${paramValue}" is given instead`);126 }127 return result;128}129helpers.mobilePinch = async function (opts={}) {130 if (!opts.element) {131 opts.element = await this.findNativeElementOrElements(`class name`, `XCUIElementTypeApplication`, false);132 }133 const params = {134 scale: parseFloatParameter('scale', opts.scale, 'pinch'),135 velocity: parseFloatParameter('velocity', opts.velocity, 'pinch')136 };137 const el = opts.element.ELEMENT || opts.element;138 return await this.proxyCommand(`/wda/element/${el}/pinch`, 'POST', params);139};140helpers.mobileDoubleTap = async function (opts={}) {141 if (opts.element) {142 // Double tap element143 const el = opts.element.ELEMENT || opts.element;144 return await this.proxyCommand(`/wda/element/${el}/doubleTap`, 'POST');145 }146 // Double tap coordinates147 const params = {148 x: parseFloatParameter('x', opts.x, 'doubleTap'),149 y: parseFloatParameter('y', opts.y, 'doubleTap')150 };151 return await this.proxyCommand('/wda/doubleTap', 'POST', params);152};153helpers.mobileTwoFingerTap = async function (opts={}) {154 if (!opts.element) {155 opts.element = await this.findNativeElementOrElements(`class name`, `XCUIElementTypeApplication`, false);156 }157 const el = opts.element.ELEMENT || opts.element;158 return await this.proxyCommand(`/wda/element/${el}/twoFingerTap`, 'POST');159};160helpers.mobileTouchAndHold = async function (opts={}) {161 let params = {162 duration: parseFloatParameter('duration', opts.duration, 'touchAndHold')163 };164 if (opts.element) {165 // Long tap element166 const el = opts.element.ELEMENT || opts.element;167 return await this.proxyCommand(`/wda/element/${el}/touchAndHold`, 'POST', params);168 }169 // Long tap coordinates170 params.x = parseFloatParameter('x', opts.x, 'touchAndHold');171 params.y = parseFloatParameter('y', opts.y, 'touchAndHold');172 return await this.proxyCommand('/wda/touchAndHold', 'POST', params);173};174helpers.mobileTap = async function (opts={}) {175 const params = {176 x: parseFloatParameter('x', opts.x, 'tap'),177 y: parseFloatParameter('y', opts.y, 'tap')178 };179 const el = opts.element ? (opts.element.ELEMENT || opts.element) : '0';180 return await this.proxyCommand(`/wda/tap/${el}`, 'POST', params);181};182helpers.mobileDragFromToForDuration = async function (opts={}) {183 const params = {184 duration: parseFloatParameter('duration', opts.duration, 'dragFromToForDuration'),185 fromX: parseFloatParameter('fromX', opts.fromX, 'dragFromToForDuration'),186 fromY: parseFloatParameter('fromY', opts.fromY, 'dragFromToForDuration'),187 toX: parseFloatParameter('toX', opts.toX, 'dragFromToForDuration'),188 toY: parseFloatParameter('toY', opts.toY, 'dragFromToForDuration')189 };190 if (opts.element) {191 // Drag element192 const el = opts.element.ELEMENT || opts.element;193 return await this.proxyCommand(`/wda/element/${el}/dragfromtoforduration`, 'POST', params);194 }195 // Drag coordinates196 return await this.proxyCommand('/wda/dragfromtoforduration', 'POST', params);197};198helpers.mobileSelectPickerWheelValue = async function (opts={}) {199 if (!opts.element) {200 log.errorAndThrow('Element id is expected to be set for selectPickerWheelValue method');201 }202 if (!_.isString(opts.order) || ['next', 'previous'].indexOf(opts.order.toLowerCase()) === -1) {203 log.errorAndThrow(`The mandatory "order" parameter is expected to be equal either to 'next' or 'previous'. ` +204 `'${opts.order}' is given instead`);205 }206 const el = opts.element.ELEMENT || opts.element;207 const params = {order: opts.order};208 if (opts.offset) {209 params.offset = parseFloatParameter('offset', opts.offset, 'selectPickerWheelValue');210 }211 return await this.proxyCommand(`/wda/pickerwheel/${el}/select`, 'POST', params);212};213helpers.getCoordinates = async function (gesture) {214 let el = gesture.options.element;215 // defaults216 let coordinates = {x: 0, y: 0, areOffsets: false};217 let optionX = null;218 if (gesture.options.x) {219 optionX = parseFloatParameter('x', gesture.options.x, 'getCoordinates');220 }221 let optionY = null;222 if (gesture.options.y) {223 optionY = parseFloatParameter('y', gesture.options.y, 'getCoordinates');224 }225 // figure out the element coordinates....
alert.js
Source:alert.js
...7 return text;8 }9 let method = 'GET';10 let endpoint = `/alert/text`;11 return await this.proxyCommand(endpoint, method);12};13// TODO: WDA does not currently support this natively14commands.setAlertText = async function (text) {15 if (!Array.isArray(text)) {16 text = text.split('');17 }18 if (this.isWebContext()) {19 let alert = await this.getAlert();20 await alert.setText(text);21 return;22 }23 let method = 'POST';24 let endpoint = `/alert/text`;25 return await this.proxyCommand(endpoint, method, text);26};27commands.postAcceptAlert = async function () {28 if (this.isWebContext()) {29 let alert = await this.getAlert();30 if (alert.close) {31 await alert.close();32 } else {33 await alert.ok();34 }35 return;36 }37 let method = 'POST';38 let endpoint = `/alert/accept`;39 return await this.proxyCommand(endpoint, method);40};41commands.postDismissAlert = async function () {42 if (this.isWebContext()) {43 let alert = await this.getAlert();44 if (alert.close) {45 await alert.close();46 } else {47 await alert.cancel();48 }49 return;50 }51 let method = 'POST';52 let endpoint = `/alert/dismiss`;53 return await this.proxyCommand(endpoint, method);54};55helpers.getAlert = async function () {56 let possibleAlert = await this.findNativeElementOrElements('class name', 'XCUIElementTypeScrollView', true);57 if (possibleAlert.length !== 1) throw new errors.NoAlertOpenError();58 let possibleAlertButtons = await this.findNativeElementOrElements('class name', 'XCUIElementTypeButton', true, possibleAlert[0].ELEMENT);59 if (possibleAlertButtons.length < 1 || possibleAlertButtons.length > 2) throw new errors.NoAlertOpenError();60 let assertButtonName = async (button, expectedName) => {61 button = button.ELEMENT ? button.ELEMENT : button;62 let name = await this.proxyCommand(`/element/${button}/attribute/name`, 'GET');63 if (name.toLowerCase() !== expectedName) throw new errors.NoAlertOpenError();64 };65 let alert = possibleAlert[0];66 if (possibleAlertButtons.length === 1) {67 // make sure the button is 'Close'68 let closeButton = possibleAlertButtons[0];69 await assertButtonName(closeButton, 'close');70 alert.close = async () => {71 await this.proxyCommand(`/element/${closeButton.ELEMENT}/click`, 'POST');72 };73 } else {74 // ensure the buttons are 'Cancel' and 'OK'75 let cancelButton = possibleAlertButtons[0];76 await assertButtonName(cancelButton, 'cancel');77 let okButton = possibleAlertButtons[1];78 await assertButtonName(okButton, 'ok');79 alert.cancel = async () => {80 await this.proxyCommand(`/element/${cancelButton.ELEMENT}/click`, 'POST');81 };82 alert.ok = async () => {83 await this.proxyCommand(`/element/${okButton.ELEMENT}/click`, 'POST');84 };85 }86 alert.getText = async () => {87 let textView = await this.findNativeElementOrElements('class name', 'XCUIElementTypeTextView', false, alert.ELEMENT);88 return await this.proxyCommand(`/element/${textView.ELEMENT}/attribute/value`, 'GET');89 };90 alert.setText = async (value) => {91 try {92 let textView = await this.findNativeElementOrElements('class name', 'XCUIElementTypeTextField', false, alert.ELEMENT);93 await this.proxyCommand(`/element/${textView.ELEMENT}/value `, 'POST', {value});94 } catch (err) {95 if (isErrorType(err, errors.NoSuchElementError)) {96 throw new Error('Tried to set text of an alert that was not a prompt');97 }98 throw err;99 }100 };101 return alert;102};103Object.assign(extensions, commands, helpers);104export { commands, helpers };...
proxy-test.js
Source:proxy-test.js
1const td = require('testdouble');2const Promise = require('rsvp').Promise;3const path = require('path');4const expect = require('../../helpers/expect');5const contains = td.matchers.contains;6const cordovaPath = path.join('appPath', 'corber', 'cordova');7describe('Proxy Command', () => {8 let proxyCommand;9 let logger;10 let spawn;11 let VerifyInstall;12 beforeEach(() => {13 let project = {14 root: 'appPath',15 isEmberCLIProject: td.function()16 };17 logger = td.object(['warn', 'error', 'success']);18 td.replace('../../../lib/utils/logger', logger);19 let getCordovaPath = td.replace('../../../lib/targets/cordova/utils/get-path');20 td.when(getCordovaPath(project)).thenReturn(cordovaPath);21 VerifyInstall = td.replace('../../../lib/targets/cordova/validators/is-installed');22 td.when(VerifyInstall.prototype.run()).thenReturn(Promise.resolve());23 spawn = td.replace('../../../lib/utils/spawn');24 td.when(spawn('cordova build', [], { shell: true }, contains({ cwd: cordovaPath })))25 .thenReturn(Promise.resolve());26 let ProxyCommand = require('../../../lib/commands/proxy');27 proxyCommand = new ProxyCommand({28 project,29 analytics: td.object(['track', 'trackTiming', 'trackError'])30 });31 });32 afterEach(() => {33 td.reset();34 });35 it('resolves when proxy spawn exits successfully', () => {36 let promise = proxyCommand.validateAndRun(['build']);37 return expect(promise).to.eventually.be.fulfilled;38 });39 it('rejects if install not verified', () => {40 td.when(VerifyInstall.prototype.run())41 .thenReturn(Promise.reject('install not verified'));42 return proxyCommand.validateAndRun(['build']).then(() => {43 td.verify(logger.error(contains('install not verified')));44 });45 });46 it('rejects with error code msg when proxy spawn exits in failure', () => {47 td.when(spawn('cordova build', [], { shell: true }, contains({ cwd: cordovaPath })))48 .thenReturn(Promise.resolve({ code: -1 }));49 return proxyCommand.validateAndRun(['build']).then(() => {50 td.verify(logger.error(contains('\'cordova build\' failed with error code -1')));51 });52 });53 it('warns if a supported corber command is used', () => {54 return proxyCommand.validateAndRun(['build']).then(() => {55 td.verify(logger.warn(contains('bypassed corber command')));56 });57 });58 it('warns if cordova command is unknown', () => {59 td.when(spawn('cordova foo', [], { shell: true }, contains({ cwd: cordovaPath })))60 .thenReturn(Promise.resolve());61 return proxyCommand.validateAndRun(['foo']).then(() => {62 td.verify(logger.warn(contains('unknown Cordova command')));63 });64 });65 it('does not warn if known non-supported corber command is used', () => {66 td.when(spawn('cordova emulate', [], { shell: true }, contains({ cwd: cordovaPath })))67 .thenReturn(Promise.resolve())68 return proxyCommand.validateAndRun(['emulate']).then(() => {69 td.verify(logger.warn(contains('bypassed corber command')), { times: 0 });70 td.verify(logger.warn(contains('unknown Cordova command')), { times: 0 });71 });72 });...
osx.js
Source:osx.js
1const { exec } = require("child_process");2let proxyNames = ["http_proxy", "HTTP_PROXY", "https_proxy", "HTTPS_PROXY"];3const networkServices = ["Wi-Fi"];4let desktopProxyNames = ["webproxy", "securewebproxy"];5const proxyCommands = {6 SET_DESKTOP: "SET_DESKTOP",7 UNSET_DESKTOP: "UNSET_DESKTOP",8 SET_TERMINAL: "SET_TERMINAL",9 UNSET_TERMINAL: "UNSET_TERMINAL",10};11const getExecutionCommand = (12 commandType,13 HOST,14 PORT,15 proxyName,16 serviceName17) => {18 const commandTemplates = {19 SET_DESKTOP: `networksetup -set${proxyName} ${serviceName} ${HOST} ${PORT};`,20 UNSET_DESKTOP: `networksetup -set${proxyName}state ${serviceName} off;`,21 SET_TERMINAL: `export ${proxyName}=${HOST}:${PORT};`,22 UNSET_TERMINAL: `unset ${proxyName};`,23 };24 return commandTemplates[commandType];25};26const getDesktopProxyCommand = (proxyCommand, HOST, PORT) => {27 const executionString = desktopProxyNames.reduce((acc, curr) => {28 let accCopy = acc;29 networkServices.forEach((serviceName) => {30 accCopy = accCopy.concat(31 getExecutionCommand(proxyCommand, HOST, PORT, curr, serviceName)32 );33 });34 return accCopy;35 }, "");36 return executionString;37};38const getTerminalProxyCommand = (proxyCommand, HOST, PORT) => {39 const executionString = proxyNames.reduce(40 (acc, curr) =>41 acc.concat(getExecutionCommand(proxyCommand, HOST, PORT, curr)),42 ""43 );44 return executionString;45};46const getProxyCommand = (proxyCommand, HOST, PORT) => {47 if (proxyCommand.indexOf("DESKTOP") >= 0)48 return getDesktopProxyCommand(proxyCommand, HOST, PORT);49 if (proxyCommand.indexOf("TERMINAL") >= 0)50 return getTerminalProxyCommand(proxyCommand, HOST, PORT);51};52const toggleProxy = (proxyCommand, HOST, PORT) => {53 const executionString = getProxyCommand(proxyCommand, HOST, PORT);54 execute_command(executionString);55};56const execute_command = (command) => {57 exec(command, (error) => {58 if (error) {59 console.log(error);60 return;61 }62 console.log(`Proxy Success: ${command}`);63 });64};65const applyProxyOsx = (HOST, PORT) => {66 proxyNames = ["http_proxy", "HTTP_PROXY", "https_proxy", "HTTPS_PROXY"];67 desktopProxyNames = ["webproxy", "securewebproxy"];68 toggleProxy(proxyCommands.SET_DESKTOP, HOST, PORT);69 toggleProxy(proxyCommands.SET_TERMINAL, HOST, PORT);70};71const applyHttpProxyOsx = (HOST, PORT) => {72 proxyNames = ["http_proxy", "HTTP_PROXY"];73 desktopProxyNames = ["webproxy"];74 toggleProxy(proxyCommands.SET_DESKTOP, HOST, PORT);75 toggleProxy(proxyCommands.SET_TERMINAL, HOST, PORT);76};77const applyHttpsProxyOsx = (HOST, PORT) => {78 proxyNames = ["https_proxy", "HTTPS_PROXY"];79 desktopProxyNames = ["securewebproxy"];80 toggleProxy(proxyCommands.SET_DESKTOP, HOST, PORT);81 toggleProxy(proxyCommands.SET_TERMINAL, HOST, PORT);82};83const removeProxyOsx = () => {84 proxyNames = ["http_proxy", "HTTP_PROXY", "https_proxy", "HTTPS_PROXY"];85 desktopProxyNames = ["webproxy", "securewebproxy"];86 toggleProxy(proxyCommands.UNSET_DESKTOP);87 toggleProxy(proxyCommands.UNSET_TERMINAL);88};...
proxy-helper-specs.js
Source:proxy-helper-specs.js
...17 });18 describe('proxyCommand', () => {19 it('should send command through WDA', async () => {20 proxyStub.returns({status: 0});21 await driver.proxyCommand('/some/endpoint', 'POST', {some: 'stuff'});22 proxyStub.calledOnce.should.be.true;23 proxyStub.firstCall.args[0].should.eql('/some/endpoint');24 proxyStub.firstCall.args[1].should.eql('POST');25 proxyStub.firstCall.args[2].some.should.eql('stuff');26 });27 it('should throw an error if no endpoint is given', async () => {28 await driver.proxyCommand(null, 'POST', {some: 'stuff'}).should.eventually.be.rejectedWith(/endpoint/);29 proxyStub.callCount.should.eql(0);30 });31 it('should throw an error if no endpoint is given', async () => {32 await driver.proxyCommand('/some/endpoint', null, {some: 'stuff'}).should.eventually.be.rejectedWith(/GET, POST/);33 proxyStub.callCount.should.eql(0);34 });35 it('should throw an error if wda returns an error (even if http status is 200)', async () => {36 proxyStub.returns({status: 13, value: 'WDA error occurred'});37 try {38 await driver.proxyCommand('/some/endpoint', 'POST', {some: 'stuff'});39 } catch (err) {40 err.jsonwpCode.should.eql(13);41 err.message.should.include('WDA error occurred');42 err.should.be.an.instanceof(errors.UnknownError);43 }44 proxyStub.calledOnce.should.be.true;45 });46 it('should not throw an error if no status is returned', async () => {47 proxyStub.returns({value: 'WDA error occurred'});48 await driver.proxyCommand('/some/endpoint', 'POST', {some: 'stuff'});49 proxyStub.calledOnce.should.be.true;50 });51 });...
index.js
Source:index.js
...34proxyCommandsRoot.forEach(function (command) {35 cli = cli.command(command,36 `Run ${command} in project folder`,37 {},38 proxyCommand(command)39 )40})41proxyCommandsTheme.forEach(function (command) {42 cli = cli.command(command,43 `Run ${command} in theme folder`,44 {},45 proxyCommand(command, 'theme')46 )47})48cli.option('skipReadConfig', {49 global: true,50 describe: 'Do not read config from file',51 type: 'boolean'52})53.option('skipWriteConfig', {54 global: true,55 describe: 'Do not write config to file',56 type: 'boolean'57})58.option('configPath', {59 global: true,...
keyword.js
Source:keyword.js
1const test = require('tape');2const { parseConfigLine } = require('../lib/parser');3test('test LocalForward', t => {4 t.plan(3);5 const line = 'LocalForward 80 localhost:80';6 const context = { result: {} };7 parseConfigLine(line, context);8 t.error(context.error);9 t.notEqual(context.result.LocalForward, undefined);10 t.equal(context.result.LocalForward.length, 3);11});12test('test ProxyCommand', t => {13 t.plan(3);14 const line = 'ProxyCommand ssh -W %h:%p host';15 const context = { result: {} };16 parseConfigLine(line, context);17 t.error(context.error);18 t.notEqual(context.result.ProxyCommand, undefined);19 t.equal(context.result.ProxyCommand.length, 4);20});21test('test RemoteForward', t => {22 t.plan(3);23 const line = 'RemoteForward 80 localhost:80';24 const context = { result: {} };25 parseConfigLine(line, context);26 t.error(context.error);27 t.notEqual(context.result.RemoteForward, undefined);28 t.equal(context.result.RemoteForward.length, 3);...
lock.js
Source:lock.js
1import B from 'bluebird';2let commands = {};3commands.lock = async function (seconds) {4 await this.proxyCommand('/wda/lock', 'POST');5 if (isNaN(seconds)) {6 return;7 }8 const floatSeconds = parseFloat(seconds);9 if (floatSeconds <= 0) {10 return;11 }12 await B.delay(floatSeconds * 1000);13 await this.proxyCommand('/wda/unlock', 'POST');14};15commands.unlock = async function () {16 await this.proxyCommand('/wda/unlock', 'POST');17};18commands.isLocked = async function () {19 return await this.proxyCommand('/wda/locked', 'GET');20};21export { commands };...
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 },5};6var client = webdriverio.remote(options);7 .init()8 .getTitle().then(function(title) {9 console.log('Title was: ' + title);10 })11 .end();12var commands = require('./commands');13var _ = require('lodash');14var DEFAULT_HOST = 'localhost';15var DEFAULT_PORT = 4723;16var DEFAULT_PATH = '/wd/hub';17var DEFAULT_PROTOCOL = 'http';18var DEFAULT_TIMEOUT = 5000;19var DEFAULT_RETRIES = 1;20var DEFAULT_HEADERS = {};21var DEFAULT_CONNECTION_RETRY_COUNT = 3;22var DEFAULT_CONNECTION_RETRY_TIMEOUT = 10000;23var DEFAULT_DESIRED_CAPABILITIES = {};24var DEFAULT_REQUESTED_CAPABILITIES = {};
Using AI Code Generation
1const BaseDriver = require('appium-base-driver');2const { exec } = require('teen_process');3const log = require('appium-logger').getLogger('ProxyCommand');4const { errors } = require('appium-base-driver');5class AppiumDriver extends BaseDriver {6 constructor (opts = {}, shouldValidateCaps = true) {7 super(opts, shouldValidateCaps);8 this.desiredCapConstraints = {9 proxyCommand: {10 },11 };12 }13 async createSession (caps) {14 let { proxyCommand } = caps;15 if (proxyCommand) {16 try {17 await exec(proxyCommand);18 } catch (err) {19 throw new errors.SessionNotCreatedError(`The proxyCommand: ${proxyCommand} failed to execute. Original error: ${err.message}`);20 }21 }22 }23}24module.exports = { AppiumDriver };
Using AI Code Generation
1var wd = require('wd');2var proxy = require('wd').promiseChainRemote;3var serverConfig = {4};5var desired = {6};7var driver = wd.promiseChainRemote(serverConfig);8 .init(desired)9 .then(function () {10 return driver.execute('mobile: proxyCommand', {11 });12 })13 .then(function (element) {14 return driver.elementIdClick(element.value.ELEMENT);15 })16 .then(function () {17 return driver.execute('mobile: proxyCommand', {18 });19 })20 .then(function (element) {21 return driver.elementIdClick(element.value.ELEMENT);22 })23 .then(function () {24 return driver.execute('mobile: proxyCommand', {25 });26 })27 .then(function (element) {28 return driver.elementIdClick(element.value.ELEMENT);29 })30 .then(function () {31 return driver.execute('mobile: proxyCommand', {32 });33 })34 .then(function (element) {35 return driver.elementIdClick(element.value.ELEMENT);36 })37 .then(function () {38 return driver.execute('mobile: proxyCommand', {
Using AI Code Generation
1this.proxyCommand('/element/' + elementId + '/click', 'POST', {});2this.executeCommand('click', {element: elementId});3this.execute('mobile: click', {element: elementId});4this.execute('mobile: click', {element: elementId});5this.execute('mobile: click', {element: elementId});6this.execute('mobile: click', {element: elementId});7this.execute('mobile: click', {element: elementId});8this.execute('mobile: click', {element: elementId});9this.execute('mobile: click', {element: elementId});10this.execute('mobile: click', {element: elementId});11this.execute('mobile: click', {element: elementId});12this.execute('mobile: click', {element: elementId});
Using AI Code Generation
1const wd = require('wd');2const { serverConfig, desiredCaps } = require('./config');3const proxyCommand = require('appium-base-driver').proxyCommand;4const { asyncify } = require('asyncbox');5const driver = wd.promiseChainRemote(serverConfig);6(async () => {7 await driver.init(desiredCaps);8 await driver.setImplicitWaitTimeout(5000);9 await driver.sleep(5000);10 const getDeviceTime = proxyCommand('/session/:sessionId/appium/device/system_time', 'GET');11 const deviceTime = await getDeviceTime(driver);12 console.log(deviceTime);13 await driver.quit();14})();
Using AI Code Generation
1const { BaseDriver } = require('appium-base-driver');2const adb = new BaseDriver();3const cmd = 'shell';4const args = ['dumpsys', 'window', 'windows'];5const opts = {6};7adb.proxyCommand(cmd, args, opts).then(console.log);8const { AndroidDriver } = require('appium-android-driver');9const adb = new AndroidDriver();10const cmd = 'shell';11const args = ['dumpsys', 'window', 'windows'];12const opts = {13};14adb.proxyCommand(cmd, args, opts).then(console.log);15const { AndroidDriver } = require('appium-android-driver');16const adb = new AndroidDriver();17const cmd = 'shell';18const args = ['dumpsys', 'window', 'windows'];19const opts = {20};21adb.proxyCommand(cmd, args, opts).then(console.log);22const { AndroidDriver } = require('appium-android-driver');23const adb = new AndroidDriver();24const cmd = 'shell';25const args = ['dumpsys', 'window', 'windows'];26const opts = {27};28adb.proxyCommand(cmd, args, opts).then(console.log);29const { AndroidDriver } = require('appium-android-driver');30const adb = new AndroidDriver();31const cmd = 'shell';32const args = ['dumpsys', 'window', 'windows'];33const opts = {34};35adb.proxyCommand(cmd, args, opts).then(console.log);36const { AndroidDriver } = require('appium-android-driver');37const adb = new AndroidDriver();38const cmd = 'shell';39const args = ['dumpsys', 'window', 'windows'];40const opts = {41};42adb.proxyCommand(cmd, args, opts).then(console.log);43const { AndroidDriver } = require('appium-android-driver');44const adb = new AndroidDriver();
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!