How to use driver.proxyCommand method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

language-specs.js

Source:language-specs.js Github

copy

Full Screen

1import sinon from 'sinon';2import chai from 'chai';3import XCUITestDriver from '../..';4chai.should();5describe('language and locale', function () {6 const LANGUAGE = 'en';7 const LOCALE = 'en_US';8 describe('send only language and locale', function () {9 it('should send translated POST /session request with valid desired caps to WDA', async function () {10 const expectedWDACapabilities = {11 desiredCapabilities: {12 bundleId: 'com.test.app',13 arguments: [14 '-AppleLanguages', `(${LANGUAGE})`,15 '-NSLanguages', `(${LANGUAGE})`,16 '-AppleLocale', LOCALE17 ],18 environment: {},19 shouldWaitForQuiescence: true,20 shouldUseTestManagerForVisibilityDetection: true,21 maxTypingFrequency: 60,22 shouldUseSingletonTestManager: true,23 }24 };25 let desiredCapabilities = {26 platformName: 'iOS',27 platformVersion: '9.3',28 deviceName: 'iPhone 6',29 app: 'testapp.app',30 language: LANGUAGE,31 locale: LOCALE,32 bundleId: expectedWDACapabilities.desiredCapabilities.bundleId,33 };34 let driver = new XCUITestDriver(desiredCapabilities);35 let proxySpy = sinon.stub(driver, 'proxyCommand');36 driver.validateDesiredCaps(desiredCapabilities);37 await driver.startWdaSession(desiredCapabilities.bundleId, desiredCapabilities.processArguments);38 proxySpy.calledOnce.should.be.true;39 proxySpy.firstCall.args[0].should.eql('/session');40 proxySpy.firstCall.args[1].should.eql('POST');41 proxySpy.firstCall.args[2].should.eql(expectedWDACapabilities);42 });43 });44 describe('send process args, language and locale json', function () {45 it('should send translated POST /session request with valid desired caps to WDA', async function () {46 const processArguments = {47 args: ['a', 'b', 'c'],48 env: { 'a': 'b', 'c': 'd' }49 };50 const augmentedProcessArgumentsWithLanguage = {51 args: [52 ...processArguments.args,53 '-AppleLanguages', `(${LANGUAGE})`,54 '-NSLanguages', `(${LANGUAGE})`,55 '-AppleLocale', LOCALE,56 ],57 env: processArguments.env58 };59 const expectedWDACapabilities = {60 desiredCapabilities: {61 bundleId: 'com.test.app',62 arguments: augmentedProcessArgumentsWithLanguage.args,63 environment: processArguments.env,64 shouldWaitForQuiescence: true,65 shouldUseTestManagerForVisibilityDetection: true,66 maxTypingFrequency: 60,67 shouldUseSingletonTestManager: true,68 }69 };70 const desiredCapabilities = {71 platformName: 'iOS',72 platformVersion: '9.3',73 deviceName: 'iPhone 6',74 app: 'testapp.app',75 language: LANGUAGE,76 locale: LOCALE,77 bundleId: expectedWDACapabilities.desiredCapabilities.bundleId,78 processArguments79 };80 let driver = new XCUITestDriver(desiredCapabilities);81 let proxySpy = sinon.stub(driver, 'proxyCommand');82 driver.validateDesiredCaps(desiredCapabilities);83 await driver.startWdaSession(desiredCapabilities.bundleId, desiredCapabilities.processArguments);84 proxySpy.calledOnce.should.be.true;85 proxySpy.firstCall.args[0].should.eql('/session');86 proxySpy.firstCall.args[1].should.eql('POST');87 proxySpy.firstCall.args[2].should.eql(expectedWDACapabilities);88 });89 });...

Full Screen

Full Screen

find-specs.js

Source:find-specs.js Github

copy

Full Screen

1import sinon from 'sinon';2import XCUITestDriver from '../../..';3describe('general commands', () => {4 let driver = new XCUITestDriver();5 let proxySpy = sinon.stub(driver, 'proxyCommand');6 afterEach(() => {7 proxySpy.reset();8 });9 describe('findNativeElementOrElements', () => {10 async function verifyFind (strategy, selector, modSelector) {11 try {12 await driver.findNativeElementOrElements(strategy, selector, false);13 } catch (ign) {}14 proxySpy.calledOnce.should.be.true;15 proxySpy.firstCall.args[0].should.eql('/element');16 proxySpy.firstCall.args[1].should.eql('POST');17 proxySpy.firstCall.args[2].should.eql({18 using: strategy,19 value: modSelector20 });21 proxySpy.reset();22 }23 it('should convert class names from UIA to XCUI', async () => {24 await verifyFind('class name', 'UIAButton', 'XCUIElementTypeButton');25 await verifyFind('class name', 'UIAMapView', 'XCUIElementTypeMap');26 await verifyFind('class name', 'UIAScrollView', 'XCUIElementTypeScrollView');27 await verifyFind('class name', 'UIACollectionView', 'XCUIElementTypeCollectionView');28 await verifyFind('class name', 'UIATextView', 'XCUIElementTypeTextView');29 await verifyFind('class name', 'UIAWebView', 'XCUIElementTypeWebView');30 });31 it('should convert xpaths from UIA to XCUI', async () => {32 await verifyFind('xpath', '//UIAButton', '//XCUIElementTypeButton');33 await verifyFind('xpath',34 '//UIAButton/UIATextField',35 '//XCUIElementTypeButton/XCUIElementTypeTextField');36 await verifyFind('xpath',37 'UIAButton//UIATextField',38 'XCUIElementTypeButton//XCUIElementTypeTextField');39 await verifyFind('xpath',40 '//UIAButton[@name="foo"]',41 '//XCUIElementTypeButton[@name="foo"]');42 await verifyFind('xpath',43 '//UIAButton/Weird',44 '//XCUIElementTypeButton/Weird');45 await verifyFind('xpath',46 '//UIAMapView/UIAScrollView',47 '//XCUIElementTypeMap/XCUIElementTypeScrollView');48 await verifyFind('xpath',49 '//UIAMapView/UIAScrollView[@name="UIADummyData"]',50 '//XCUIElementTypeMap/XCUIElementTypeScrollView[@name="UIADummyData"]');51 await verifyFind('xpath',52 '//XCUIElementTypeMap[@name="UIADummyData"]',53 '//XCUIElementTypeMap[@name="UIADummyData"]');54 });55 });...

Full Screen

Full Screen

driver-specs.js

Source:driver-specs.js Github

copy

Full Screen

1import sinon from 'sinon';2import { settings as iosSettings } from 'appium-ios-driver';3import XCUITestDriver from '../..';4import xcode from 'appium-xcode';5import _ from 'lodash';6import log from '../../lib/logger';7const caps = {platformName: "iOS", deviceName: "iPhone 6", app: "/foo.app"};8const anoop = async () => {};9describe('driver commands', () => {10 let driver = new XCUITestDriver();11 let proxySpy = sinon.stub(driver, 'proxyCommand');12 afterEach(() => {13 proxySpy.reset();14 });15 describe('status', () => {16 it('should send status request to WDA', async () => {17 await driver.getStatus();18 proxySpy.calledOnce.should.be.true;19 proxySpy.firstCall.args[0].should.eql('/status');20 proxySpy.firstCall.args[1].should.eql('GET');21 });22 });23 describe('createSession', () => {24 let d;25 let sandbox;26 beforeEach(() => {27 d = new XCUITestDriver();28 sandbox = sinon.sandbox.create();29 sandbox.stub(d, "determineDevice", async () => {30 return {device: null, udid: null, realDevice: null};31 });32 sandbox.stub(d, "configureApp", anoop);33 sandbox.stub(d, "checkAppPresent", anoop);34 sandbox.stub(d, "startLogCapture", anoop);35 sandbox.stub(d, "startSim", anoop);36 sandbox.stub(d, "startWdaSession", anoop);37 sandbox.stub(d, "startWda", anoop);38 sandbox.stub(d, "extractBundleId", anoop);39 sandbox.stub(d, "installApp", anoop);40 sandbox.stub(iosSettings, "setLocale", anoop);41 sandbox.stub(iosSettings, "setPreferences", anoop);42 sandbox.stub(xcode, "getMaxIOSSDK", async () => {43 return '10.0';44 });45 });46 afterEach(() => {47 sandbox.restore();48 });49 it('should include server capabilities', async () => {50 let resCaps = await d.createSession(caps);51 resCaps[1].javascriptEnabled.should.be.true;52 });53 it('should warn', async () => {54 let warnStub = sinon.stub(log, "warn", async () => {});55 await d.createSession(_.defaults({autoAcceptAlerts: true}, caps));56 warnStub.calledTwice.should.be.true;57 _.filter(warnStub.args, (arg) => arg[0].indexOf('autoAcceptAlerts') !== -1)58 .should.have.length(1);59 warnStub.restore();60 });61 });...

Full Screen

Full Screen

proxy-helper-specs.js

Source:proxy-helper-specs.js Github

copy

Full Screen

...17 });18 describe('proxyCommand', function () {19 it('should send command through WDA', async function () {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 function () {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 method is given', async function () {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 function () {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 function () {47 proxyStub.returns({value: 'WDA error occurred'});48 await driver.proxyCommand('/some/endpoint', 'POST', {some: 'stuff'});49 proxyStub.calledOnce.should.be.true;50 });51 });...

Full Screen

Full Screen

general-specs.js

Source:general-specs.js Github

copy

Full Screen

1import sinon from 'sinon';2import XCUITestDriver from '../../..';3describe('general commands', () => {4 let driver = new XCUITestDriver();5 let proxySpy = sinon.stub(driver, 'proxyCommand');6 afterEach(() => {7 proxySpy.reset();8 });9 describe('background', () => {10 it('should send translated POST request to WDA', async () => {11 await driver.background();12 proxySpy.calledOnce.should.be.true;13 proxySpy.firstCall.args[0].should.eql('/deactivateApp');14 proxySpy.firstCall.args[1].should.eql('POST');15 });16 });17 describe('touch id', () => {18 it('should send translated POST request to WDA', async () => {19 await driver.touchId();20 proxySpy.calledOnce.should.be.true;21 proxySpy.firstCall.args[0].should.eql('/simulator/touch_id');22 proxySpy.firstCall.args[1].should.eql('POST');23 proxySpy.firstCall.args[2].should.eql({match: true});24 });25 it('should send translated POST request to WDA with true', async () => {26 await driver.touchId(true);27 proxySpy.calledOnce.should.be.true;28 proxySpy.firstCall.args[0].should.eql('/simulator/touch_id');29 proxySpy.firstCall.args[1].should.eql('POST');30 proxySpy.firstCall.args[2].should.eql({match: true});31 });32 it('should send translated POST request to WDA with false', async () => {33 await driver.touchId(false);34 proxySpy.calledOnce.should.be.true;35 proxySpy.firstCall.args[0].should.eql('/simulator/touch_id');36 proxySpy.firstCall.args[1].should.eql('POST');37 proxySpy.firstCall.args[2].should.eql({match: false});38 });39 });...

Full Screen

Full Screen

alert-specs.js

Source:alert-specs.js Github

copy

Full Screen

1import sinon from 'sinon';2import XCUITestDriver from '../../..';3describe('alert commands', () => {4 let driver = new XCUITestDriver();5 let proxySpy = sinon.stub(driver, 'proxyCommand');6 afterEach(() => {7 proxySpy.reset();8 });9 describe('getAlertText', () => {10 it('should send translated GET request to WDA', async () => {11 await driver.getAlertText();12 proxySpy.calledOnce.should.be.true;13 proxySpy.firstCall.args[0].should.eql('/alert/text');14 proxySpy.firstCall.args[1].should.eql('GET');15 });16 });17 describe.skip('setAlertText', () => {18 it('should send translated POST request to WDA', async () => {19 await driver.setAlertText('some text');20 proxySpy.calledOnce.should.be.true;21 proxySpy.firstCall.args[0].should.eql('/alert/text');22 proxySpy.firstCall.args[1].should.eql('POST');23 proxySpy.firstCall.args[2].should.eql('some text');24 });25 });26 describe('postAcceptAlert', () => {27 it('should send translated POST request to WDA', async () => {28 await driver.postAcceptAlert();29 proxySpy.calledOnce.should.be.true;30 proxySpy.firstCall.args[0].should.eql('/alert/accept');31 proxySpy.firstCall.args[1].should.eql('POST');32 });33 });34 describe('postDismissAlert', () => {35 it('should send translated POST request to WDA', async () => {36 await driver.postDismissAlert();37 proxySpy.calledOnce.should.be.true;38 proxySpy.firstCall.args[0].should.eql('/alert/dismiss');39 proxySpy.firstCall.args[1].should.eql('POST');40 });41 });...

Full Screen

Full Screen

source-specs.js

Source:source-specs.js Github

copy

Full Screen

1import sinon from 'sinon';2import XCUITestDriver from '../../..';3const xmlHeader = '<?xml version="1.0" encoding="UTF-8"?>';4const xmlBody = '<some-xml/>';5const srcTree = `${xmlHeader}${xmlBody}`;6const appiumHeadTag = '<AppiumAUT>';7const appiumFootTag = '</AppiumAUT>';8describe('source commands', function () {9 let driver = new XCUITestDriver();10 let proxyStub = sinon.stub(driver, 'proxyCommand').callsFake(async () => srcTree); // eslint-disable-line require-await11 afterEach(function () {12 proxyStub.resetHistory();13 });14 describe('getPageSource', function () {15 it('should send translated GET request to WDA', async function () {16 await driver.getPageSource();17 proxyStub.calledOnce.should.be.true;18 proxyStub.firstCall.args[0].should.eql('/source');19 proxyStub.firstCall.args[1].should.eql('GET');20 });21 it('should insert received xml into AppiumAUT tags', async function () {22 let src = await driver.getPageSource();23 src.indexOf(xmlHeader).should.eql(0);24 src.indexOf(appiumHeadTag).should.eql(xmlHeader.length);25 src.indexOf(appiumFootTag).should.eql(srcTree.length + appiumHeadTag.length);26 });27 });...

Full Screen

Full Screen

session-specs.js

Source:session-specs.js Github

copy

Full Screen

1import sinon from 'sinon';2import XCUITestDriver from '../../..';3import chai from 'chai';4chai.should();5describe('session commands', () => {6 let driver = new XCUITestDriver();7 driver.opts.udid = "cecinestpasuneudid";8 let proxySpy = sinon.stub(driver, 'proxyCommand', async (endpoint, method) => {9 if (endpoint === "/" && method === "GET") {10 return {11 capabilities: {12 sillyCap: true,13 app: "LOL.app",14 }15 };16 }17 return {};18 });19 afterEach(() => {20 proxySpy.reset();21 });22 describe('getSession', () => {23 it('should merge caps with WDA response', async () => {24 driver.caps = {25 platformName: "iOS",26 javascript_enabled: true,27 app: "NOTLOL.app",28 };29 let res = await driver.getSession();30 proxySpy.calledOnce.should.be.true;31 res.should.eql({32 sillyCap: true,33 app: "LOL.app",34 platformName: "iOS",35 javascript_enabled: true,36 udid: "cecinestpasuneudid",37 });38 });39 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2driver.init({3}).then(() => {4}).then(() => {5 return driver.quit();6});

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder()3 .forBrowser('selenium')4 .build();5driver.getTitle().then(function(title) {6 console.log(title);7 driver.quit();8});9driver.proxyCommand('/wda/element/1/click', 'POST', {});10driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const chai = require('chai');3const chaiAsPromised = require('chai-as-promised');4chai.use(chaiAsPromised);5chai.should();6const caps = {7};8async function main() {9 await driver.init(caps);10 const command = 'mobile: scroll';11 const args = {12 };13 await driver.proxyCommand(command, 'POST', args);14}15main();16I have a question, I am using Appium 1.8.1, and I want to use the command “mobile: scroll”, but I am not sure how to use it. I have seen some examples, but I don’t know how to use it in my code. I am using Javascript. I have tried this code: const command = 'mobile: scroll'; const args = { direction: 'up', }; But I am getting an error: Error: Command 'mobile: scroll' not recognized. I am not sure what I am doing wrong. Can someone help me with this? Thanks17const command = 'mobile: scroll';18const args = { direction: 'up', };

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder()3 .withCapabilities({4 })5 .build();6driver.proxyCommand('/wda/activeAppInfo', 'GET')7 .then(function (res) {8 console.log(res);9 });10driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { remote } = require('webdriverio');2const assert = require('assert');3(async () => {4 const browser = await remote({5 capabilities: {6 }7 })8 const touchEvent = {9 "gesture": {10 }11 }12 await browser.proxyCommand('/wda/touch/perform', 'POST', touchEvent);13 await browser.deleteSession()14})().catch(async (e) => {15 console.error(e)16 await browser.deleteSession()17})18* Appium version (or git revision) that exhibits the issue: 1.20.219* Last Appium version that did not exhibit the issue (if applicable):20* Node.js version (unless using Appium.app|exe): v14.16.0

Full Screen

Using AI Code Generation

copy

Full Screen

1var driver = require('appium-xcuitest-driver');2var driverObj = new driver();3var realDeviceObj = driverObj.createRealDeviceDriver();4var proxyObj = driverObj.createProxyDriver();5var realDeviceObj = driverObj.createRealDeviceDriver();6var proxyObj = driverObj.createProxyDriver();7var realDeviceObj = driverObj.createRealDeviceDriver();8var proxyObj = driverObj.createProxyDriver();9var realDeviceObj = driverObj.createRealDeviceDriver();10var proxyObj = driverObj.createProxyDriver();11var realDeviceObj = driverObj.createRealDeviceDriver();12var proxyObj = driverObj.createProxyDriver();13var realDeviceObj = driverObj.createRealDeviceDriver();14var proxyObj = driverObj.createProxyDriver();15var realDeviceObj = driverObj.createRealDeviceDriver();16var proxyObj = driverObj.createProxyDriver();17var realDeviceObj = driverObj.createRealDeviceDriver();18var proxyObj = driverObj.createProxyDriver();19var realDeviceObj = driverObj.createRealDeviceDriver();20var proxyObj = driverObj.createProxyDriver();21var realDeviceObj = driverObj.createRealDeviceDriver();22var proxyObj = driverObj.createProxyDriver();23var realDeviceObj = driverObj.createRealDeviceDriver();

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium Xcuitest Driver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful