Best JavaScript code snippet using appium-android-driver
find-e2e-specs.js
Source:find-e2e-specs.js
...73 ...FILES74 }, 180000, 180000);75 it('should find an element using the object detection strategy', async function () {76 this.timeout(180000);77 await t.driver.updateSettings({checkForImageElementStaleness: false});78 await t.driver.elementByAccessibilityId('More options');79 await t.driver.elementByCustom('ai:menu').click();80 await t.driver.elementByXPath('//android.widget.TextView[@text="SDCARD"]');81 });82});83describe('Finding by element - iOS', function () {84 const t = setup(PHOTOS, 120000, 20000);85 // this test assumes you've launched the app and hit 'continue' to the86 // 'what's new in photos' interstitial87 it('should find an element by its label', async function () {88 this.timeout(90000);89 await t.driver.elementByCustom('ai:search').click();90 await t.driver.elementByAccessibilityId('Cancel');91 });92});93describe('Finding by object detection - iOS', function () {94 const t = setup({95 testaiFindMode: 'object_detection',96 testaiObjDetectionDebug: true,97 testaiObjDetectionThreshold: 0.9,98 ...PHOTOS99 }, 120000, 20000);100 // this test assumes you've launched the app and hit 'continue' to the101 // 'what's new in photos' interstitial102 it('should find an element by its label', async function () {103 await t.driver.updateSettings({checkForImageElementStaleness: false});104 this.timeout(90000);105 await t.driver.elementByCustom('ai:search').click();106 await B.delay(5000);107 await t.driver.elementByAccessibilityId('October 2009');108 });109});110describe('Finding grouped icon - iOS', function () {111 const t = setup({112 testaiFindMode: 'object_detection',113 testaiObjDetectionDebug: true,114 testaiObjDetectionThreshold: 0.9,115 ...FILES_IOS116 }, 120000, 20000);117 it('should find an element by its label', async function () {118 this.timeout(90000);119 await t.driver.updateSettings({checkForImageElementStaleness: false});120 await t.driver.elementByAccessibilityId('Browse').click();121 await t.driver.elementByCustom('ai:clock').click();122 await t.driver.elementByAccessibilityId('No Recents');123 });...
by-image-e2e-specs.js
Source:by-image-e2e-specs.js
...16 ...APIDEMOS_CAPS,17 appActivity: '.view.ChronometerDemo'18 });19 // use the driver settings that cause the most code paths to be exercised20 await driver.updateSettings({21 fixImageTemplateSize: true,22 autoUpdateImageElementPosition: true,23 });24 });25 after(async function () {26 await driver.quit();27 });28 it('should find image elements', async function () {29 let els = await driver.elementsByImageFile(START_IMG);30 els.should.have.length(1);31 });32 it('should find an image element', async function () {33 let el = await driver.elementByImageFile(START_IMG);34 el.value.should.match(/appium-image-element/);35 });36 it('should not find an image element that is not matched', async function () {37 await driver.elementByImageFile(SQUARES_IMG)38 .should.eventually.be.rejectedWith(/Error response status: 7/);39 });40 it('should find anything with a threshold low enough', async function () {41 const {imageMatchThreshold} = await driver.settings();42 await driver.updateSettings({imageMatchThreshold: 0});43 try {44 await driver.elementByImageFile(SQUARES_IMG).should.eventually.exist;45 } finally {46 await driver.updateSettings({imageMatchThreshold});47 }48 });49 it('should be able to get basic element properties', async function () {50 let el = await driver.elementByImageFile(START_IMG);51 await el.isDisplayed().should.eventually.be.true;52 let size = await el.getSize();53 size.width.should.be.above(0);54 size.height.should.be.above(0);55 let loc = await el.getLocation();56 loc.x.should.be.at.least(0);57 loc.y.should.be.at.least(0);58 let locInView = await el.getLocationInView();59 locInView.x.should.eql(loc.x);60 locInView.y.should.eql(loc.y);...
jetpack-compose-e2e-specs.js
Source:jetpack-compose-e2e-specs.js
...22 it('should find element by tag and text and click it', async function () {23 let el = await driver.elementByXPath("//*[@text='Clickable Component']");24 await driver.moveTo(el);25 await el.click();26 await driver.updateSettings({ driver: 'compose' });27 let e = await driver.elementByTagName('lol');28 await e.isDisplayed().should.eventually.be.true;29 let elementWithDescription = await driver.elementByAccessibilityId('desc');30 await elementWithDescription.text().should.eventually.equal('Click to see dialog');31 await elementWithDescription.isDisplayed().should.eventually.be.true;32 let clickableText = await driver.elementByLinkText('Click to see dialog');33 await clickableText.click();34 await driver.elementByLinkText('Congratulations! You just clicked the text successfully');35 await driver.settings().should.eventually.eql({ driver: 'compose' });36 });37 it('should find element by xpath', async function () {38 await driver.updateSettings({ driver: 'espresso' });39 let el = await driver.elementByXPath("//*[@text='Clickable Component']");40 await driver.moveTo(el);41 await el.click();42 await driver.updateSettings({ driver: 'compose' });43 let e = await driver.elementByXPath("//*[@view-tag='lol']//*[@content-desc='desc']");44 await e.text().should.eventually.equal('Click to see dialog');45 });46 it('should find elements', async function () {47 await driver.updateSettings({ driver: 'espresso' });48 let el = await driver.elementByXPath("//*[@text='Horizontal Carousel']");49 await driver.moveTo(el);50 await el.click();51 await driver.updateSettings({ driver: 'compose' });52 let e = await driver.elementsByLinkText('Grace Hopper');53 e.length.should.be.eql(2);54 await e[0].text().should.eventually.equal('Grace Hopper');55 });...
source-specs.js
Source:source-specs.js
...30 .nodeify(done);31 });32 it('should get less source when compression is enabled', function (done) {33 var getSourceWithoutCompression = function () {34 return driver.updateSettings({"ignoreUnimportantViews": false}).source();35 };36 var getSourceWithCompression = function () {37 return driver.updateSettings({"ignoreUnimportantViews": true }).source();38 };39 var sourceWithoutCompression, sourceWithCompression;40 getSourceWithoutCompression()41 .then(function (els) {42 sourceWithoutCompression = els;43 return getSourceWithCompression();44 })45 .then(function (els) {46 sourceWithCompression = els;47 })48 .then(function () {49 return sourceWithoutCompression.length.should.be.greaterThan(sourceWithCompression.length);50 })51 .nodeify(done);...
source-e2e-specs.js
Source:source-e2e-specs.js
...25 assertSource(source);26 });27 it('should get less source when compression is enabled', async function () {28 let getSourceWithoutCompression = async () => {29 await driver.updateSettings({'ignoreUnimportantViews': false});30 return await driver.source();31 };32 let getSourceWithCompression = async () => {33 await driver.updateSettings({'ignoreUnimportantViews': true});34 return await driver.source();35 };36 let sourceWithoutCompression = await getSourceWithoutCompression();37 let sourceWithCompression = await getSourceWithCompression();38 sourceWithoutCompression.length.should.be.greaterThan(sourceWithCompression.length);39 await getSourceWithoutCompression().should.eventually.eql(sourceWithoutCompression);40 });...
find-system-ui-el-e2e-specs.js
Source:find-system-ui-el-e2e-specs.js
...25 });26 it('should not find statusBarBackground element via xpath', async function () {27 let statusBar = await driver.elementsByXPath(`//*[@resource-id='android:id/statusBarBackground']`); //check server (NPE) if allowInvisibleElements is unset on server side28 statusBar.length.should.be.equal(0);29 await driver.updateSettings({'allowInvisibleElements': false});30 let statusBarWithInvisibleEl = await driver.elementsByXPath(`//*[@resource-id='android:id/statusBarBackground']`);31 statusBarWithInvisibleEl.length.should.be.equal(0);32 });33 it('should find statusBarBackground element via xpath', async function () {34 await driver.updateSettings({'allowInvisibleElements': true});35 await driver.elementByXPath(`//*[@resource-id='android:id/statusBarBackground']`).should.eventually.exist;36 });...
settings-specs.js
Source:settings-specs.js
1"use strict";2var setup = require("./setup-base")3 , env = require('../../helpers/env')4 , getAppPath = require('../../helpers/app').getAppPath;5var app;6if (env.IOS) {7 app = 'testapp';8} else if (env.ANDROID || env.SELENDROID) {9 app = 'ApiDemos';10}11var desired = {12 app: getAppPath(app)13};14if (env.SELENDROID) {15 desired.automationName = 'selendroid';16}17describe('settings', function () {18 var driver;19 setup(this, desired, {'no-reset': true}).then(function (d) { driver = d; });20 it('should return a settings object even if none specified', function (done) {21 driver22 .settings().should.eventually.exist23 .nodeify(done);24 });25 it('should be able to store a setting', function (done) {26 driver27 .updateSettings({'settlers of': 'Catan'})28 .settings().should.eventually.have.property('settlers of')29 .nodeify(done);30 });31 it('should overwrite new settings', function (done) {32 driver33 .updateSettings({'settlers of': 'Catan'})34 .updateSettings({'settlers of': 'Europa'})35 .settings().then(function (settings) {36 return settings['settlers of'].should.equal('Europa');37 })38 .nodeify(done);39 });40 it('should leave non-specified settings unchanged', function (done) {41 driver42 .updateSettings({'thing one': 1})43 .updateSettings({'thing two': 2})44 .settings().should.eventually.have.property('thing one')45 .nodeify(done);46 });...
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = {3desiredCapabilities: {4}5};6.remote(options)7.init()8.getTitle().then(function(title) {9console.log('Title was: ' + title);10})11.end();12var webdriverio = require('webdriverio');13var options = {14desiredCapabilities: {15}16};17.remote(options)18.init()19.getTitle().then(function(title) {20console.log('Title was: ' + title);21})22.end();23var webdriverio = require('webdriverio');24var options = {25desiredCapabilities: {26}27};28.remote(options)29.init()30.getTitle().then(function(title) {31console.log('Title was: ' + title);32})33.end();34var webdriverio = require('webdriverio');35var options = {36desiredCapabilities: {37}38};39.remote(options)40.init()41.getTitle().then(function(title) {42console.log('Title was: ' + title);43})44.end();45var webdriverio = require('webdriverio');46var options = {47desiredCapabilities: {48}49};50.remote(options)51.init()52.getTitle().then(function(title) {53console.log('Title was: ' + title);54})55.end();56var webdriverio = require('webdriverio');57var options = {58desiredCapabilities: {59}60};61.remote(options)62.init()63.getTitle().then(function(title) {64console.log('Title was: ' + title);65})66.end();
Using AI Code Generation
1const wd = require('wd');2const assert = require('assert');3const {exec} = require('child_process');4const PORT = 4723;5const HOST = 'localhost';6const BROWSER_NAME = 'Chrome';7const PLATFORM_NAME = 'Android';8const PLATFORM_VERSION = '6.0';9const DEVICE_NAME = 'Android Emulator';10const IMPLICIT_WAIT = 30000;11const NO_RESET = true;12const FULL_RESET = false;13const appiumServer = exec('appium');14appiumServer.stdout.on('data', (data) => {15 console.log(data);16 if (data.includes('Appium REST http interface listener started on
Using AI Code Generation
1var wd = require('wd');2var assert = require('assert');3var caps = require('./caps');4var driver = wd.promiseChainRemote('localhost', 4723);5 .init(caps)6 .then(function() {7 return driver.updateSettings({8 'ignoreUnimportantViews': true9 });10 })11 .then(function() {12 return driver.quit();13 })14 .done();15var caps = {16};17module.exports = caps;
Using AI Code Generation
1const wdio = require('webdriverio');2const opts = {3 capabilities: {4 }5};6async function main() {7 const driver = await wdio.remote(opts);8 try {9 await driver.updateSettings({ "allowTestPackages": true });10 await driver.updateSettings({ "allowInsecure": true });11 await driver.updateSettings({ "skipUnlock": true });12 await driver.updateSettings({ "ignoreUnimportantViews": true });13 await driver.updateSettings({ "disableWindowAnimation": true });14 await driver.updateSettings({ "waitForIdleTimeout": 2000 });15 await driver.updateSettings({ "waitForSelectorTimeout": 2000 });16 await driver.updateSettings({ "mjpegServerScreenshotQuality": 50 });17 await driver.updateSettings({ "mjpegScalingFactor": 50 });18 await driver.updateSettings({ "mjpegServerFramerate": 50 });19 await driver.updateSettings({ "mjpegServerScreenshotQuality": 50 });20 await driver.updateSettings({ "shouldUseCompactResponses": true });21 await driver.updateSettings({ "elementResponseAttributes": "type,label" });22 await driver.updateSettings({ "enableNotificationListener": true });23 await driver.updateSettings({ "enableMultiWindows": true });24 await driver.updateSettings({ "enablePerformanceLogging": true });25 await driver.updateSettings({ "enableViewHierarchyXml": true });26 await driver.updateSettings({ "enableWebViewDetailsCollection": true });27 await driver.updateSettings({ "ignoreUnimportantViews": true });28 await driver.updateSettings({ "disableWindowAnimation": true });
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!!