How to use driver.getPerformanceData method in Appium

Best JavaScript code snippet using appium

Appium JS commands.js

Source:Appium JS commands.js Github

copy

Full Screen

...239// wd example240await driver.toggleWiFi();241//PerformanceData242// webdriver.io example243driver.getPerformanceData('my.app.package', 'cpuinfo', 5);244// wd example245await driver.getPerformanceData('my.app.package', 'cpuinfo', 5);246// webdriver.io example247driver.getPerformanceDataTypes();248// wd example249await driver.getSupportedPerformanceDataTypes();250//ScreenRecording251// webdriver.io example252driver.startRecordingScreen();253//Elements254// webdriver.io example255$("~SomeAccessibilityId");256// wd example257let elementOne = await driver.elementByAccessibilityId("SomeAccessibilityID");258let elementTwo = await driver.element("id", "SomeID");259// webdriver.io example...

Full Screen

Full Screen

java.js

Source:java.js Github

copy

Full Screen

...198 codeFor_rotateDevice (varNameIgnore, varIndexIgnore, x, y, radius, rotation, touchCount, duration) {199 return `driver.rotate(new DeviceRotation(${x}, ${y}, ${radius}, ${rotation}, ${touchCount}, ${duration}));`;200 }201 codeFor_getPerformanceData (varNameIgnore, varIndexIgnore, packageName, dataType, dataReadTimeout) {202 return `List<List<Object>> performanceData = driver.getPerformanceData("${packageName}", "${dataType}", ${dataReadTimeout});`;203 }204 codeFor_getSupportedPerformanceDataTypes () {205 return `List<String> performanceTypes = driver.getSupportedPerformanceDataTypes();`;206 }207 codeFor_performTouchId (varNameIgnore, varIndexIgnore, match) {208 return `driver.performTouchID(${match});`;209 }210 codeFor_toggleTouchIdEnrollment (varNameIgnore, varIndexIgnore, enroll) {211 return `driver.toggleTouchIDEnrollment(${enroll});`;212 }213 codeFor_openNotifications () {214 return `driver.openNotifications();`;215 }216 codeFor_getDeviceTime () {...

Full Screen

Full Screen

js-oxygen.js

Source:js-oxygen.js Github

copy

Full Screen

1import Framework from './framework';2class JsOxygenFramework extends Framework {3 get language () {4 return 'js';5 }6 get type () {7 if (this.caps && this.caps.platformName) {8 const platformName = this.caps.platformName.toLowerCase();9 if (platformName === 'windows') {10 return 'win';11 }12 if (['android', 'androiddriver'].includes(platformName)) {13 return 'mob';14 }15 if (['ios', 'iosdriver'].includes(platformName)) {16 return 'mob';17 }18 }19 return 'mob';20 }21 wrapWithBoilerplate (code) {22 if (code && code.includes('mob.open')) {23 this.caps.browserName = '__chrome_or_safari__';24 } else {25 this.caps.app = '__application_path_or_name__';26 }27 let caps = JSON.stringify(this.caps, null, 2);28 let url = JSON.stringify(`${this.scheme}://${this.host}:${this.port}${this.path}`);29 return `// Requires the Oxygen HQ client library30// (npm install oxygen-cli -g)31// Then paste this into a .js file and run with:32// oxygen <file>.js33const capabilities = ${caps};34const appiumUrl = ${url};35${this.type}.init(capabilities, appiumUrl);36${code}37`;38 }39 codeFor_executeScript (varNameIgnore, varIndexIgnore, args) {40 return `${this.type}.execute(${args})`;41 }42 codeFor_findAndAssign (strategy, locator, localVar, isArray) {43 // wdio has its own way of indicating the strategy in the locator string44 switch (strategy) {45 case 'xpath': break; // xpath does not need to be updated46 case 'accessibility id': locator = `~${locator}`; break;47 case 'id': locator = `id=${locator}`; break;48 case 'name': locator = `name=${locator}`; break;49 case 'class name': locator = `css=${locator}`; break;50 case '-android uiautomator': locator = `android=${locator}`; break;51 case '-android datamatcher': locator = `android=${locator}`; break;52 case '-ios predicate string': locator = `ios=${locator}`; break;53 case '-ios class chain': locator = `ios=${locator}`; break; // TODO: Handle IOS class chain properly. Not all libs support it. Or take it out54 default: throw new Error(`Can't handle strategy ${strategy}`);55 }56 if (isArray) {57 return `let ${localVar} = mob.findElements(${JSON.stringify(locator)});`;58 } else {59 return `let ${localVar} = mob.findElement(${JSON.stringify(locator)});`;60 }61 }62 codeFor_click (varName, varIndex) {63 return `${this.type}.click(${this.getVarName(varName, varIndex)});`;64 }65 codeFor_clear (varName, varIndex) {66 return `${this.type}.clear(${this.getVarName(varName, varIndex)});`;67 }68 codeFor_sendKeys (varName, varIndex, text) {69 return `${this.type}.type(${this.getVarName(varName, varIndex)}, ${JSON.stringify(text)});`;70 }71 codeFor_back () {72 return `${this.type}.back();`;73 }74 codeFor_tap (varNameIgnore, varIndexIgnore, x, y) {75 return `${this.type}.tap(${x}, ${y});`;76 }77 codeFor_swipe (varNameIgnore, varIndexIgnore, x1, y1, x2, y2) {78 return `${this.type}.swipeScreen(${x1}, ${y1}, ${x2}, ${y2});`;79 }80 codeFor_getCurrentActivity () {81 return `let activityName = ${this.type}.getCurrentActivity();`;82 }83 codeFor_getCurrentPackage () {84 return `let packageName = ${this.type}.getCurrentPackage();`;85 }86 codeFor_installApp (varNameIgnore, varIndexIgnore, app) {87 return `${this.type}.installApp('${app}');`;88 }89 codeFor_isAppInstalled (varNameIgnore, varIndexIgnore, app) {90 return `let isAppInstalled = ${this.type}.isAppInstalled("${app}");`;91 }92 codeFor_launchApp () {93 return `${this.type}.launchApp();`;94 }95 codeFor_background (varNameIgnore, varIndexIgnore, timeout) {96 return `${this.type}.getDriver().background(${timeout});`;97 }98 codeFor_closeApp () {99 return `${this.type}.closeApp();`;100 }101 codeFor_reset () {102 return `${this.type}.resetApp();`;103 }104 codeFor_removeApp (varNameIgnore, varIndexIgnore, app) {105 return `${this.type}.removeApp('${app}')`;106 }107 codeFor_getStrings (varNameIgnore, varIndexIgnore, language, stringFile) {108 return `let appStrings = ${this.type}.getDriver().getStrings(${language ? `${language}, ` : ''}${stringFile ? `"${stringFile}` : ''});`;109 }110 codeFor_getClipboard () {111 return `let clipboardText = ${this.type}.getDriver().getClipboard();`;112 }113 codeFor_setClipboard (varNameIgnore, varIndexIgnore, clipboardText) {114 return `${this.type}.getDriver().setClipboard('${clipboardText}')`;115 }116 codeFor_pressKeyCode (varNameIgnore, varIndexIgnore, keyCode) {117 return `${this.type}.pressKeyCode(${keyCode});`;118 }119 codeFor_longPressKeyCode (varNameIgnore, varIndexIgnore, keyCode) {120 return `${this.type}.longPressKeyCode(${keyCode});`;121 }122 codeFor_hideKeyboard () {123 return `${this.type}.hideKeyboard();`;124 }125 codeFor_isKeyboardShown () {126 return `let isKeyboardShown = ${this.type}.getDriver().isKeyboardShown();`;127 }128 codeFor_pushFile (varNameIgnore, varIndexIgnore, pathToInstallTo, fileContentString) {129 return `${this.type}.getDriver().pushFile('${pathToInstallTo}', '${fileContentString}');`;130 }131 codeFor_pullFile (varNameIgnore, varIndexIgnore, pathToPullFrom) {132 return `let fileBase64 = ${this.type}.getDriver().pullFile('${pathToPullFrom}');`;133 }134 codeFor_pullFolder (varNameIgnore, varIndexIgnore, folderToPullFrom) {135 return `let fileBase64 = ${this.type}.getDriver().pullFolder('${folderToPullFrom}');`;136 }137 codeFor_toggleAirplaneMode () {138 return `${this.type}.getDriver().toggleAirplaneMode();`;139 }140 codeFor_toggleData () {141 return `${this.type}.getDriver().toggleData();`;142 }143 codeFor_toggleWiFi () {144 return `${this.type}.getDriver().toggleWiFi();`;145 }146 codeFor_toggleLocationServices () {147 return `${this.type}.getDriver().toggleLocationServices();`;148 }149 codeFor_sendSMS (varNameIgnore, varIndexIgnore, phoneNumber, text) {150 return `${this.type}.getDriver().sendSms('${phoneNumber}', '${text}');`;151 }152 codeFor_gsmCall (varNameIgnore, varIndexIgnore, phoneNumber, action) {153 return `${this.type}.getDriver().gsmCall('${phoneNumber}', '${action}');`;154 }155 codeFor_gsmSignal (varNameIgnore, varIndexIgnore, signalStrength) {156 return `${this.type}.getDriver().gsmSignal(${signalStrength});`;157 }158 codeFor_gsmVoice (varNameIgnore, varIndexIgnore, state) {159 return `${this.type}.getDriver().gsmVoice('${state}');`;160 }161 codeFor_shake () {162 return `${this.type}.shake();`;163 }164 codeFor_lock (varNameIgnore, varIndexIgnore, seconds) {165 return `${this.type}.getDriver().lock(${seconds});`;166 }167 codeFor_unlock () {168 return `${this.type}.getDriver().unlock();`;169 }170 codeFor_isLocked () {171 return `let isLocked = ${this.type}.getDriver().isLocked();`;172 }173 codeFor_rotateDevice (varNameIgnore, varIndexIgnore, x, y, radius, rotation, touchCount, duration) {174 return `${this.type}.getDriver().rotateDevice({x: ${x}, y: ${y}, duration: ${duration}, radius: ${radius}, rotation: ${rotation}, touchCount: ${touchCount}});`;175 }176 codeFor_getPerformanceData (varNameIgnore, varIndexIgnore, packageName, dataType, dataReadTimeout) {177 return `let performanceData = ${this.type}.getDriver().getPerformanceData('${packageName}', '${dataType}', ${dataReadTimeout});`;178 }179 codeFor_getPerformanceDataTypes () {180 return `let supportedPerformanceDataTypes = ${this.type}.getDriver().getPerformanceDataTypes();`;181 }182 codeFor_touchId (varNameIgnore, varIndexIgnore, match) {183 return `${this.type}.getDriver().touchId(${match});`;184 }185 codeFor_toggleEnrollTouchId (varNameIgnore, varIndexIgnore, enroll) {186 return `${this.type}.getDriver().toggleEnrollTouchId(${enroll});`;187 }188 codeFor_openNotifications () {189 return `${this.type}.getDriver().openNotifications();`;190 }191 codeFor_getDeviceTime () {192 return `let time = ${this.type}.getDeviceTime();`;193 }194 codeFor_fingerprint (varNameIgnore, varIndexIgnore, fingerprintId) {195 return `${this.type}.getDriver().fingerPrint(${fingerprintId});`;196 }197 codeFor_getSession () {198 return `let caps = ${this.type}.getDriver().capabilities;`;199 }200 codeFor_setTimeouts (/*varNameIgnore, varIndexIgnore, timeoutsJson*/) {201 return '/* TODO implement setTimeouts */';202 }203 codeFor_setCommandTimeout () {204 return `// Not supported: setCommandTimeout`;205 }206 codeFor_getOrientation () {207 return `let orientation = ${this.type}.getDriver().getOrientation();`;208 }209 codeFor_setOrientation (varNameIgnore, varIndexIgnore, orientation) {210 return `${this.type}.getDriver().setOrientation("${orientation}");`;211 }212 codeFor_getGeoLocation () {213 return `let location = ${this.type}.getDriver().getGeoLocation();`;214 }215 codeFor_setGeoLocation (varNameIgnore, varIndexIgnore, latitude, longitude, altitude) {216 return `${this.type}.getDriver().setGeoLocation({latitude: ${latitude}, longitude: ${longitude}, altitude: ${altitude}});`;217 }218 codeFor_getLogTypes () {219 return `let getLogTypes = ${this.type}.getDriver().getLogTypes();`;220 }221 codeFor_getLogs (varNameIgnore, varIndexIgnore, logType) {222 return `let logs = ${this.type}.getDriver().getLogs('${logType}');`;223 }224 codeFor_updateSettings (varNameIgnore, varIndexIgnore, settingsJson) {225 return `${this.type}.getDriver().updateSettings(${settingsJson});`;226 }227 codeFor_getSettings () {228 return `let settings = ${this.type}.getDriver().getSettings();`;229 }230}231JsOxygenFramework.readableName = 'JS - Oxygen HQ';...

Full Screen

Full Screen

performance-specs.js

Source:performance-specs.js Github

copy

Full Screen

...36 });37 describe('getPerformanceData', function () {38 it('should return battery info', async function () {39 sandbox.stub(driver, 'getBatteryInfo').returns('data');40 await driver.getPerformanceData(null, 'batteryinfo').should.become('data');41 });42 it('should return cpu info', async function () {43 sandbox.stub(driver, 'getCPUInfo').withArgs('pkg').returns('data');44 await driver.getPerformanceData('pkg', 'cpuinfo').should.become('data');45 });46 it('should return memory info', async function () {47 sandbox.stub(driver, 'getMemoryInfo').withArgs('pkg').returns('data');48 await driver.getPerformanceData('pkg', 'memoryinfo').should.become('data');49 });50 it('should return network info', async function () {51 sandbox.stub(driver, 'getNetworkTrafficInfo').returns('data');52 await driver.getPerformanceData(null, 'networkinfo').should.become('data');53 });54 it('should throw error if data type is not valid', async function () {55 await driver.getPerformanceData(null, 'invalid')56 .should.be.rejectedWith(/No performance data of type 'invalid' found./);57 });58 });59 describe('getCPUInfo', function () {60 it('should return cpu data', async function () {61 adb.shell.withArgs(['dumpsys', 'cpuinfo', '|', 'grep', `'${PACKAGE_NAME}'`])62 .returns(' +0% 2209/io.appium.android.apis: 14% user + 23% kernel');63 (await driver.getCPUInfo(PACKAGE_NAME)).should.be.deep64 .equal([CPU_KEYS, ['14', '23']]);65 asyncbox.retryInterval.calledWith(RETRY_COUNT, RETRY_PAUSE).should.be.true;66 });67 it('should throw error if no data', async function () {68 adb.shell.returns(null);69 await driver.getCPUInfo(PACKAGE_NAME, 1).should.be...

Full Screen

Full Screen

js-wd.js

Source:js-wd.js Github

copy

Full Screen

...163 codeFor_rotateDevice (varNameIgnore, varIndexIgnore, x, y, radius, rotation, touchCount, duration) {164 return `driver.rotateDevice({x: ${x}, y: ${y}, duration: ${duration}, radius: ${radius}, rotation: ${rotation}, touchCount: ${touchCount}});`;165 }166 codeFor_getPerformanceData (varNameIgnore, varIndexIgnore, packageName, dataType, dataReadTimeout) {167 return `let performanceData = await driver.getPerformanceData('${packageName}', '${dataType}', ${dataReadTimeout});`;168 }169 codeFor_getSupportedPerformanceDataTypes () {170 return `let supportedPerformanceDataTypes = await driver.getSupportedPerformanceDataTypes();`;171 }172 codeFor_performTouchId (varNameIgnore, varIndexIgnore, match) {173 return `await driver.touchId(${match});`;174 }175 codeFor_toggleTouchIdEnrollment (varNameIgnore, varIndexIgnore, enroll) {176 return `await driver.toggleTouchIdEnrollment(${enroll});`;177 }178 codeFor_openNotifications () {179 return `await driver.openNotifications();`;180 }181 codeFor_getDeviceTime () {...

Full Screen

Full Screen

performance-e2e-specs.js

Source:performance-e2e-specs.js Github

copy

Full Screen

...24 let capability = await driver.getPerformanceDataTypes();25 capability.should.eql(_.keys(SUPPORTED_PERFORMANCE_DATA_TYPES));26 });27 it('should throw an Error for unsupported capability data type ', async function () {28 await driver.getPerformanceData(caps.appPackage, 'randominfo', 2).should.be.rejected;29 });30 it('should get the amount of cpu by user and kernel process', async function () {31 // TODO: why does this fail?32 let apiLevel = await driver.adb.getApiLevel();33 if ([21, 24, 25].indexOf(apiLevel) >= 0) {34 return this.skip();35 }36 let cpu = await driver.getPerformanceData(caps.appPackage, 'cpuinfo', 50);37 Array.isArray(cpu).should.be.true;38 cpu.length.should.be.above(1);39 cpu[0].should.eql(CPU_KEYS);40 if (cpu.length > 1) {41 for (let i = 1; i < cpu.length; i++) {42 cpu[0].length.should.equal(cpu[i].length);43 }44 }45 });46 it('should get the amount of memory used by the process', async function () {47 let memory = await driver.getPerformanceData(caps.appPackage, 'memoryinfo', 2);48 Array.isArray(memory).should.be.true;49 memory.length.should.be.above(1);50 memory[0].should.eql(MEMORY_KEYS);51 if (memory.length > 1) {52 for (let i = 1; i < memory.length; i++) {53 memory[0].length.should.equal(memory[i].length);54 }55 }56 });57 it('should get the remaining battery power', async function () {58 let battery = await driver.getPerformanceData(caps.appPackage, 'batteryinfo', 2);59 Array.isArray(battery).should.be.true;60 battery.length.should.be.above(1);61 battery[0].should.eql(BATTERY_KEYS);62 if (battery.length > 1) {63 for (let i = 1; i < battery.length; i++) {64 battery[0].length.should.equal(battery[i].length);65 }66 }67 });68 it('should get the network statistics', async function () {69 // TODO: why does adb fail with a null pointer exception on 5.170 if (await driver.adb.getApiLevel() === 22) {71 return this.skip();72 }73 let network = await driver.getPerformanceData(caps.appPackage, 'networkinfo', 2);74 Array.isArray(network).should.be.true;75 network.length.should.be.above(1);76 let compare = false;77 for (let j = 0; j < NETWORK_KEYS.length; ++j) {78 if (_.isEqual(NETWORK_KEYS[j], network[0])) {79 compare = true;80 }81 }82 compare.should.equal(true);83 if (network.length > 1) {84 for (let i = 1; i < network.length; ++i) {85 network[0].length.should.equal(network[i].length);86 }87 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver'),2 until = webdriver.until;3var driver = new webdriver.Builder()4 .forBrowser('chrome')5 .build();6driver.findElement(By.name('q')).sendKeys('webdriver');7driver.findElement(By.name('btnG')).click();8driver.wait(until.titleIs('webdriver - Google Search'), 1000);9driver.getPerformanceData('com.android.chrome', 'cpuinfo', 1000).then(function (data) {10 console.log(data);11});12driver.quit();

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.getPerformanceData("com.example.android.contactmanager", "memoryinfo", 1)7 .then(function (data) {8 console.log(data.value);9 });10driver.quit();11[ { memoryType: 'nativePrivateDirty',12 memoryPrivateDirty: '0' },13 { memoryType: 'dalvikPrivateDirty',14 memoryPrivateDirty: '0' },15 { memoryType: 'totalPrivateDirty',16 memoryPrivateDirty: '0' } ]

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require("wd"),2 Q = require('q');3var desired = {4};5var driver = wd.promiseChainRemote("localhost", 4723);6 .init(desired)7 .then(function() {8 return driver.getPerformanceData("com.apple.mobilesafari", "cpuinfo", 10);9 })10 .then(function(data) {11 console.log(data);12 })13 .fin(function() { return driver.quit(); })14 .done();15[ { value: '0.000000', name: 'cpuinfo-0', label: 'cpuinfo-0' },16 { value: '0.000000', name: 'cpuinfo-1', label: 'cpuinfo-1' },17 { value: '0.000000', name: 'cpuinfo-2', label: 'cpuinfo-2' },18 { value: '0.000000', name: 'cpuinfo-3', label: 'cpuinfo-3' },19 { value: '0.000000', name: 'cpuinfo-4', label: 'cpuinfo-4' },20 { value: '0.000000', name: 'cpuinfo-5', label: 'cpuinfo-5' },21 { value: '0.000000', name: 'cpuinfo-6', label: 'cpuinfo-6' },22 { value: '0.000000', name: 'cpuinfo-7', label: 'cpuinfo-7' },23 { value: '0.000000', name: 'cpuinfo-8', label: 'cpuinfo-8' },24 { value: '0.000000', name: 'cpuinfo-9', label: 'cpuinfo-9' },25 { value:

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.getPerformanceData('com.android.chrome', 'cpuinfo', 5000)7 .then(function (data) {8 console.log(data);9 });10driver.quit();11To use this method, we need to import the ‘perf_hooks’ module. This module is available in NodeJS 8.5.0 and above. To use this method, the following code can be used:12var perf_hooks = require('perf_hooks');13var startTime = perf_hooks.performance.now();14driver.getPerformanceDataTypes('com.android.chrome')15 .then(function (data) {16 console.log(data);17 });18var endTime = perf_hooks.performance.now();19console.log(endTime - startTime);20To use this method, we need to import the ‘perf_hooks’ module. This module is available in NodeJS 8

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 automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful