How to use driver.activateApp method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

Appium JS commands.js

Source:Appium JS commands.js Github

copy

Full Screen

...161driver.removeApp('com.example.AppName')162// wd example163await driver.removeAppFromDevice('com.example.AppName');164// webdriver.io example165driver.activateApp(null, 'com.apple.Preferences')166driver.activateApp('io.appium.android.apis')167// wd example168// Supports only `mobile: queryAppState` for iOS, XCUITest169//Get Clipboard170//Get the content of the system clipboard171self.driver.get_clipboard()172self.driver.get_clipboard_text()173// webdriver.io example174driver.setClipboard('happy testing', 'plaintext')175// wd example176await driver.setClipboard('happy testing', 'plaintext')177//Emulate power state178// webdriver.io example179driver.powerAC('on')180// webdriver.io example...

Full Screen

Full Screen

general-specs.js

Source:general-specs.js Github

copy

Full Screen

1import chai from 'chai';2import chaiAsPromised from 'chai-as-promised';3import sinon from 'sinon';4import AndroidDriver from '../../../lib/driver';5import helpers from '../../../lib/android-helpers';6import { withMocks } from '@appium/test-support';7import { fs } from '@appium/support';8import Bootstrap from '../../../lib/bootstrap';9import B from 'bluebird';10import ADB from 'appium-adb';11chai.should();12chai.use(chaiAsPromised);13let driver;14let sandbox = sinon.createSandbox();15let expect = chai.expect;16describe('General', function () {17  beforeEach(function () {18    driver = new AndroidDriver();19    driver.bootstrap = new Bootstrap();20    driver.adb = new ADB();21    driver.caps = {};22    driver.opts = {};23  });24  afterEach(function () {25    sandbox.restore();26  });27  describe('keys', function () {28    it('should send keys via setText bootstrap command', async function () {29      sandbox.stub(driver.bootstrap, 'sendAction');30      driver.opts.unicodeKeyboard = true;31      await driver.keys('keys');32      driver.bootstrap.sendAction33        .calledWithExactly('setText',34          {text: 'keys', replace: false, unicodeKeyboard: true})35        .should.be.true;36    });37    it('should join keys if keys is array', async function () {38      sandbox.stub(driver.bootstrap, 'sendAction');39      driver.opts.unicodeKeyboard = false;40      await driver.keys(['k', 'e', 'y', 's']);41      driver.bootstrap.sendAction42        .calledWithExactly('setText', {text: 'keys', replace: false})43        .should.be.true;44    });45  });46  describe('getDeviceTime', function () {47    it('should return device time', async function () {48      sandbox.stub(driver.adb, 'shell');49      driver.adb.shell.returns(' 2018-06-09T16:21:54+0900 ');50      await driver.getDeviceTime().should.become('2018-06-09T16:21:54+09:00');51      driver.adb.shell.calledWithExactly(['date', '+%Y-%m-%dT%T%z']).should.be.true;52    });53    it('should return device time with custom format', async function () {54      sandbox.stub(driver.adb, 'shell');55      driver.adb.shell.returns(' 2018-06-09T16:21:54+0900 ');56      await driver.getDeviceTime('YYYY-MM-DD').should.become('2018-06-09');57      driver.adb.shell.calledWithExactly(['date', '+%Y-%m-%dT%T%z']).should.be.true;58    });59    it('should throw error if shell command failed', async function () {60      sandbox.stub(driver.adb, 'shell').throws();61      await driver.getDeviceTime().should.be.rejected;62    });63  });64  describe('getPageSource', function () {65    it('should return page source', async function () {66      sandbox.stub(driver.bootstrap, 'sendAction').withArgs('source').returns('sources');67      (await driver.getPageSource()).should.be.equal('sources');68    });69  });70  describe('back', function () {71    it('should press back', async function () {72      sandbox.stub(driver.bootstrap, 'sendAction');73      await driver.back();74      driver.bootstrap.sendAction.calledWithExactly('pressBack').should.be.true;75    });76  });77  describe('isKeyboardShown', function () {78    it('should return true if the keyboard is shown', async function () {79      driver.adb.isSoftKeyboardPresent = function isSoftKeyboardPresent () {80        return {isKeyboardShown: true, canCloseKeyboard: true};81      };82      (await driver.isKeyboardShown()).should.equal(true);83    });84    it('should return false if the keyboard is not shown', async function () {85      driver.adb.isSoftKeyboardPresent = function isSoftKeyboardPresent () {86        return {isKeyboardShown: false, canCloseKeyboard: true};87      };88      (await driver.isKeyboardShown()).should.equal(false);89    });90  });91  describe('hideKeyboard', function () {92    it('should hide keyboard with ESC command', async function () {93      sandbox.stub(driver.adb, 'keyevent');94      let callIdx = 0;95      driver.adb.isSoftKeyboardPresent = function isSoftKeyboardPresent () {96        callIdx++;97        return {98          isKeyboardShown: callIdx <= 1,99          canCloseKeyboard: callIdx <= 1,100        };101      };102      await driver.hideKeyboard().should.eventually.be.fulfilled;103      driver.adb.keyevent.calledWithExactly(111).should.be.true;104    });105    it('should throw if cannot close keyboard', async function () {106      this.timeout(10000);107      sandbox.stub(driver.adb, 'keyevent');108      driver.adb.isSoftKeyboardPresent = function isSoftKeyboardPresent () {109        return {110          isKeyboardShown: true,111          canCloseKeyboard: false,112        };113      };114      await driver.hideKeyboard().should.eventually.be.rejected;115      driver.adb.keyevent.notCalled.should.be.true;116    });117    it('should not throw if no keyboard is present', async function () {118      driver.adb.isSoftKeyboardPresent = function isSoftKeyboardPresent () {119        return {120          isKeyboardShown: false,121          canCloseKeyboard: false,122        };123      };124      await driver.hideKeyboard().should.eventually.be.fulfilled;125    });126  });127  describe('openSettingsActivity', function () {128    it('should open settings activity', async function () {129      sandbox.stub(driver.adb, 'getFocusedPackageAndActivity')130        .returns({appPackage: 'pkg', appActivity: 'act'});131      sandbox.stub(driver.adb, 'shell');132      sandbox.stub(driver.adb, 'waitForNotActivity');133      await driver.openSettingsActivity('set1');134      driver.adb.shell.calledWithExactly(['am', 'start', '-a', 'android.settings.set1'])135        .should.be.true;136      driver.adb.waitForNotActivity.calledWithExactly('pkg', 'act', 5000)137        .should.be.true;138    });139  });140  describe('getWindowSize', function () {141    it('should get window size', async function () {142      sandbox.stub(driver.bootstrap, 'sendAction')143        .withArgs('getDeviceSize').returns('size');144      (await driver.getWindowSize()).should.be.equal('size');145    });146  });147  describe('getWindowRect', function () {148    it('should get window size', async function () {149      sandbox.stub(driver.bootstrap, 'sendAction')150        .withArgs('getDeviceSize').returns({width: 300, height: 400});151      const rect = await driver.getWindowRect();152      rect.width.should.be.equal(300);153      rect.height.should.be.equal(400);154      rect.x.should.be.equal(0);155      rect.y.should.be.equal(0);156    });157  });158  describe('getCurrentActivity', function () {159    it('should get current activity', async function () {160      sandbox.stub(driver.adb, 'getFocusedPackageAndActivity')161        .returns({appActivity: 'act'});162      await driver.getCurrentActivity().should.eventually.be.equal('act');163    });164  });165  describe('getCurrentPackage', function () {166    it('should get current activity', async function () {167      sandbox.stub(driver.adb, 'getFocusedPackageAndActivity')168        .returns({appPackage: 'pkg'});169      await driver.getCurrentPackage().should.eventually.equal('pkg');170    });171  });172  describe('isAppInstalled', function () {173    it('should return true if app is installed', async function () {174      sandbox.stub(driver.adb, 'isAppInstalled').withArgs('pkg').returns(true);175      (await driver.isAppInstalled('pkg')).should.be.true;176    });177  });178  describe('removeApp', function () {179    it('should remove app', async function () {180      sandbox.stub(driver.adb, 'uninstallApk').withArgs('pkg').returns(true);181      (await driver.removeApp('pkg')).should.be.true;182    });183  });184  describe('installApp', function () {185    it('should install app', async function () {186      let app = 'app.apk';187      sandbox.stub(driver.helpers, 'configureApp').withArgs(app, '.apk')188        .returns(app);189      sandbox.stub(fs, 'rimraf').returns();190      sandbox.stub(driver.adb, 'install').returns(true);191      await driver.installApp(app);192      driver.helpers.configureApp.calledOnce.should.be.true;193      fs.rimraf.notCalled.should.be.true;194      driver.adb.install.calledOnce.should.be.true;195    });196    it('should throw an error if APK does not exist', async function () {197      await driver.installApp('non/existent/app.apk').should.be198        .rejectedWith(/does not exist or is not accessible/);199    });200  });201  describe('background', function () {202    it('should bring app to background and back', async function () {203      const appPackage = 'wpkg';204      const appActivity = 'wacv';205      driver.opts = {appPackage, appActivity, intentAction: 'act',206                     intentCategory: 'cat', intentFlags: 'flgs',207                     optionalIntentArguments: 'opt'};208      sandbox.stub(driver.adb, 'goToHome');209      sandbox.stub(driver.adb, 'getFocusedPackageAndActivity')210        .returns({appPackage, appActivity});211      sandbox.stub(B, 'delay');212      sandbox.stub(driver.adb, 'startApp');213      sandbox.stub(driver, 'activateApp');214      await driver.background(10);215      driver.adb.getFocusedPackageAndActivity.calledOnce.should.be.true;216      driver.adb.goToHome.calledOnce.should.be.true;217      B.delay.calledWithExactly(10000).should.be.true;218      driver.activateApp.calledWithExactly(appPackage).should.be.true;219      driver.adb.startApp.notCalled.should.be.true;220    });221    it('should bring app to background and back if started after session init', async function () {222      const appPackage = 'newpkg';223      const appActivity = 'newacv';224      driver.opts = {appPackage: 'pkg', appActivity: 'acv', intentAction: 'act',225                     intentCategory: 'cat', intentFlags: 'flgs',226                     optionalIntentArguments: 'opt'};227      let params = {pkg: appPackage, activity: appActivity, action: 'act', category: 'cat',228                    flags: 'flgs', waitPkg: 'wpkg', waitActivity: 'wacv',229                    optionalIntentArguments: 'opt', stopApp: false};230      driver._cachedActivityArgs = {[`${appPackage}/${appActivity}`]: params};231      sandbox.stub(driver.adb, 'goToHome');232      sandbox.stub(driver.adb, 'getFocusedPackageAndActivity')233        .returns({appPackage, appActivity});234      sandbox.stub(B, 'delay');235      sandbox.stub(driver.adb, 'startApp');236      sandbox.stub(driver, 'activateApp');237      await driver.background(10);238      driver.adb.getFocusedPackageAndActivity.calledOnce.should.be.true;239      driver.adb.goToHome.calledOnce.should.be.true;240      B.delay.calledWithExactly(10000).should.be.true;241      driver.adb.startApp.calledWithExactly(params).should.be.true;242      driver.activateApp.notCalled.should.be.true;243    });244    it('should bring app to background and back if waiting for other pkg / activity', async function () { //eslint-disable-line245      const appPackage = 'somepkg';246      const appActivity = 'someacv';247      const appWaitPackage = 'somewaitpkg';248      const appWaitActivity = 'somewaitacv';249      driver.opts = {appPackage, appActivity, appWaitPackage, appWaitActivity,250                     intentAction: 'act', intentCategory: 'cat',251                     intentFlags: 'flgs', optionalIntentArguments: 'opt',252                     stopApp: false};253      sandbox.stub(driver.adb, 'goToHome');254      sandbox.stub(driver.adb, 'getFocusedPackageAndActivity')255        .returns({appPackage: appWaitPackage, appActivity: appWaitActivity});256      sandbox.stub(B, 'delay');257      sandbox.stub(driver.adb, 'startApp');258      sandbox.stub(driver, 'activateApp');259      await driver.background(10);260      driver.adb.getFocusedPackageAndActivity.calledOnce.should.be.true;261      driver.adb.goToHome.calledOnce.should.be.true;262      B.delay.calledWithExactly(10000).should.be.true;263      driver.activateApp.calledWithExactly(appWaitPackage).should.be.true;264      driver.adb.startApp.notCalled.should.be.true;265    });266    it('should not bring app back if seconds are negative', async function () {267      sandbox.stub(driver.adb, 'goToHome');268      sandbox.stub(driver.adb, 'startApp');269      await driver.background(-1);270      driver.adb.goToHome.calledOnce.should.be.true;271      driver.adb.startApp.notCalled.should.be.true;272    });273  });274  describe('getStrings', withMocks({helpers}, (mocks) => {275    it('should return app strings', async function () {276      driver.bootstrap.sendAction = () => '';277      mocks.helpers.expects('pushStrings')278          .returns({test: 'en_value'});279      let strings = await driver.getStrings('en');280      strings.test.should.equal('en_value');281      mocks.helpers.verify();282    });283    it('should return cached app strings for the specified language', async function () {284      driver.adb.getDeviceLanguage = () => 'en';285      driver.apkStrings.en = {test: 'en_value'};286      driver.apkStrings.fr = {test: 'fr_value'};287      let strings = await driver.getStrings('fr');288      strings.test.should.equal('fr_value');289    });290    it('should return cached app strings for the device language', async function () {291      driver.adb.getDeviceLanguage = () => 'en';292      driver.apkStrings.en = {test: 'en_value'};293      driver.apkStrings.fr = {test: 'fr_value'};294      let strings = await driver.getStrings();295      strings.test.should.equal('en_value');296    });297  }));298  describe('launchApp', function () {299    it('should init and start app', async function () {300      sandbox.stub(driver, 'initAUT');301      sandbox.stub(driver, 'startAUT');302      await driver.launchApp();303      driver.initAUT.calledOnce.should.be.true;304      driver.startAUT.calledOnce.should.be.true;305    });306  });307  describe('startActivity', function () {308    let params;309    beforeEach(function () {310      params = {pkg: 'pkg', activity: 'act', waitPkg: 'wpkg', waitActivity: 'wact',311                action: 'act', category: 'cat', flags: 'flgs', optionalIntentArguments: 'opt'};312      sandbox.stub(driver.adb, 'startApp');313    });314    it('should start activity', async function () {315      params.optionalIntentArguments = 'opt';316      params.stopApp = false;317      await driver.startActivity('pkg', 'act', 'wpkg', 'wact', 'act',318        'cat', 'flgs', 'opt', true);319      driver.adb.startApp.calledWithExactly(params).should.be.true;320    });321    it('should use dontStopAppOnReset from opts if it is not passed as param', async function () {322      driver.opts.dontStopAppOnReset = true;323      params.stopApp = false;324      await driver.startActivity('pkg', 'act', 'wpkg', 'wact', 'act', 'cat', 'flgs', 'opt');325      driver.adb.startApp.calledWithExactly(params).should.be.true;326    });327    it('should use appPackage and appActivity if appWaitPackage and appWaitActivity are undefined', async function () {328      params.waitPkg = 'pkg';329      params.waitActivity = 'act';330      params.stopApp = true;331      await driver.startActivity('pkg', 'act', null, null, 'act', 'cat', 'flgs', 'opt', false);332      driver.adb.startApp.calledWithExactly(params).should.be.true;333    });334  });335  describe('reset', function () {336    it('should reset app via reinstall if fullReset is true', async function () {337      driver.opts.fullReset = true;338      driver.opts.appPackage = 'pkg';339      sandbox.stub(driver, 'startAUT').returns('aut');340      sandbox.stub(helpers, 'resetApp').returns(undefined);341      await driver.reset().should.eventually.be.equal('aut');342      helpers.resetApp.calledWith(driver.adb).should.be.true;343      driver.startAUT.calledOnce.should.be.true;344    });345    it('should do fast reset if fullReset is false', async function () {346      driver.opts.fullReset = false;347      driver.opts.appPackage = 'pkg';348      sandbox.stub(helpers, 'resetApp').returns(undefined);349      sandbox.stub(driver, 'startAUT').returns('aut');350      await driver.reset().should.eventually.be.equal('aut');351      helpers.resetApp.calledWith(driver.adb).should.be.true;352      driver.startAUT.calledOnce.should.be.true;353      expect(driver.curContext).to.eql('NATIVE_APP');354    });355  });356  describe('startAUT', function () {357    it('should start AUT', async function () {358      driver.opts = {359        appPackage: 'pkg',360        appActivity: 'act',361        intentAction: 'actn',362        intentCategory: 'cat',363        intentFlags: 'flgs',364        appWaitPackage: 'wpkg',365        appWaitActivity: 'wact',366        appWaitForLaunch: true,367        appWaitDuration: 'wdur',368        optionalIntentArguments: 'opt',369        userProfile: 1370      };371      let params = {372        pkg: 'pkg',373        activity: 'act',374        action: 'actn',375        category: 'cat',376        flags: 'flgs',377        waitPkg: 'wpkg',378        waitActivity: 'wact',379        waitForLaunch: true,380        waitDuration: 'wdur',381        optionalIntentArguments: 'opt',382        stopApp: false,383        user: 1384      };385      driver.opts.dontStopAppOnReset = true;386      params.stopApp = false;387      sandbox.stub(driver.adb, 'startApp');388      await driver.startAUT();389      driver.adb.startApp.calledWithExactly(params).should.be.true;390    });391  });392  describe('setUrl', function () {393    it('should set url', async function () {394      driver.opts = {appPackage: 'pkg'};395      sandbox.stub(driver.adb, 'startUri');396      await driver.setUrl('url');397      driver.adb.startUri.calledWithExactly('url', 'pkg').should.be.true;398    });399  });400  describe('closeApp', function () {401    it('should close app', async function () {402      driver.opts = {appPackage: 'pkg'};403      sandbox.stub(driver.adb, 'forceStop');404      await driver.closeApp();405      driver.adb.forceStop.calledWithExactly('pkg').should.be.true;406    });407  });408  describe('getDisplayDensity', function () {409    it('should return the display density of a device', async function () {410      driver.adb.shell = () => '123';411      (await driver.getDisplayDensity()).should.equal(123);412    });413    it('should return the display density of an emulator', async function () {414      driver.adb.shell = (cmd) => {415        let joinedCmd = cmd.join(' ');416        if (joinedCmd.indexOf('ro.sf') !== -1) {417          // device property look up418          return '';419        } else if (joinedCmd.indexOf('qemu.sf') !== -1) {420          // emulator property look up421          return '456';422        }423        return '';424      };425      (await driver.getDisplayDensity()).should.equal(456);426    });427    it('should throw an error if the display density property can\'t be found', async function () {428      driver.adb.shell = () => '';429      await driver.getDisplayDensity().should.be.rejectedWith(/Failed to get display density property/);430    });431    it('should throw and error if the display density is not a number', async function () {432      driver.adb.shell = () => 'abc';433      await driver.getDisplayDensity().should.be.rejectedWith(/Failed to get display density property/);434    });435  });...

Full Screen

Full Screen

certificate.js

Source:certificate.js Github

copy

Full Screen

...191  });192  // Wait for the second alert193  await B.delay(2000);194  await driver.postAcceptAlert();195  await driver.activateApp('com.apple.Preferences');196  await clickElement(driver, Settings.General);197  await clickElement(driver, Settings.Profile);198  // Select the target cert199  let isCertFound = false;200  for (let swipeNum = 0; swipeNum < 5; ++swipeNum) {201    if (await clickElement(driver, {202      type: '-ios class chain',203      value: `**/XCUIElementTypeCell[\`label == '${name}'\`]`,204    }, {205      timeout: 500,206      skipIfInvisible: true,207    })) {208      isCertFound = true;209      break;...

Full Screen

Full Screen

driver-e2e-specs.js

Source:driver-e2e-specs.js Github

copy

Full Screen

...43  async function activateByName (appName) {44    const apps = await driver.executeScript('roku: getApps', []);45    const appId = apps.filter((a) => a.name === appName)[0].id;46    // TODO replace with activateApp once wdio is fixed47    //await driver.activateApp(appId);48    await driver.executeScript('roku: activateApp', [{appId}]);49    return appId;50  }51  describe('sessions', function () {52    it('should start a session with no app', async function () {53      // relying on the before block above to have done this54      await driver.executeScript('roku: activeApp', []).should.eventually.eql({name: 'Roku'});55    });56    it('should start a session with an app', async function () {57      // kill the existing session first58      await driver.deleteSession();59      driver = await startSession({...CAPS, 'appium:app': APP_ZIP});60      const app = await driver.executeScript('roku: activeApp', []);61      app.name.should.eql(APP_NAME);...

Full Screen

Full Screen

upload.image.ios.simulator.spec.js

Source:upload.image.ios.simulator.spec.js Github

copy

Full Screen

...5  beforeAll(async () => {6    // We started the device in browser, thus webview, mode. We need to switch to the NATIVE_APP mode7    await driver.switchContext('NATIVE_APP');8    // This will start the Photos app9    await driver.activateApp('com.apple.mobileslideshow');10    // A clean fresh sim will start with opening photos11    // and show a "What's new in photo's screen"12    try {13      await IosPhotos.continueButton.waitForDisplayed({timeout: 10000})14      await IosPhotos.continueButton.click()15    } catch (ign) {16      // do nothing if it's not shown, it should not be blocking17    }18    await IosPhotos.allPhotosScreen.waitForDisplayed();19  });20  it('should be able to upload a file to Photos', async () => {21    // Appium can't read file names from the Photo's app, only the date that it has been uploaded22    // For example `Photo, November 01, 7:05 AM`23    // To validate that a photo was uploaded we start on a fresh device, count the amount of current photos...

Full Screen

Full Screen

TC_001_Login.js

Source:TC_001_Login.js Github

copy

Full Screen

...10        console.log("Installation Of App Completed")11    });12    it('Run WebDriverIO App', function () {13        console.log("Launching App");14        driver.activateApp('com.wdiodemoapp');15    });16    it('Login to Appplication',()=>{17    //1. Click on Login Icon on Home Screen18    const LOGIN_ICON_HOME_SCREEN='~Login';19    $(LOGIN_ICON_HOME_SCREEN).click();20    //2. Login to Application21    LoginPage.email_txt_field.setValue(configdata.username);22    LoginPage.password_txt_field.setValue(configdata.password);23    LoginPage.login_btn.click();24    browser.pause(5000);25    LoginPage.success_btn.click();26    });27    it('Close WebDriverIO App', function () {28        console.log("Closing App");...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const wdio = require('webdriverio');2const opts = {3    capabilities: {4    }5};6const client = wdio.remote(opts);7client.init().then(() => {8    return client.activateApp('com.apple.mobilesafari');9}).then(() => {10    return client.pause(5000);11}).then(() => {12    return client.activateApp('com.apple.calculator');13}).then(() => {14    return client.pause(5000);15}).then(() => {16    return client.end();17}).catch((err) => {18    console.log(err);19});20from appium import webdriver21desired_caps = {}22driver.activate_app('com.apple.mobilesafari')23driver.implicitly_wait(5)24driver.activate_app('com.apple.calculator')25driver.implicitly_wait(5)26driver.quit()

Full Screen

Using AI Code Generation

copy

Full Screen

1const wdio = require('webdriverio');2const opts = {3    desiredCapabilities: {4    }5};6const client = wdio.remote(opts);7async function main() {8    await client.init();9    await client.activateApp('com.apple.mobilesafari');10    await client.end();11}12main();13info: [HTTP] {"desiredCapabilities":{"platformName":"iOS","platformVersion":"12.0","deviceName":"iPhone 8","automationName":"XCUITest","app":"com.apple.mobilesafari"},"capabilities":{"firstMatch":[{"appium:platformName":"iOS","appium:platformVersion":"12.0","appium:deviceName":"iPhone 8","appium:automationName":"XCUITest","appium:app":"com.apple.mobilesafari"}]}}14info: [debug] [W3C] Calling AppiumDriver.createSession() with args: [{"platformName":"iOS","platformVersion":"12.0","deviceName":"iPhone 8","automationName":"XCUITest","app":"com.apple.mobilesafari"},null,{"firstMatch":[{"platformName":"iOS","platformVersion":"12.0","deviceName":"iPhone 8","automationName":"XCUIT

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var desiredCaps = {3};4driver.init(desiredCaps)5    .then(function() {6        return driver.activateApp('com.apple.mobilesafari');7    })8    .fin(function() {9        return driver.quit();10    })11    .done();12var wd = require('wd');13var desiredCaps = {14};15driver.init(desiredCaps)16    .then(function() {17        return driver.activateApp('com.apple.mobilesafari');18    })19    .fin(function() {20        return driver.quit();21    })22    .done();

Full Screen

Using AI Code Generation

copy

Full Screen

1const wdio = require("webdriverio");2async function main() {3  const client = await wdio.remote({4    capabilities: {5    },6  });7  await client.activateApp("com.apple.Preferences");8  await client.deleteSession();9}10main();11const wdio = require("webdriverio");12async function main() {13  const client = await wdio.remote({14    capabilities: {15    },16  });17  await client.activateApp("com.apple.Preferences");18  await client.deleteSession();19}20main();21const wdio = require("webdriverio");22async function main() {23  const client = await wdio.remote({24    capabilities: {25    },26  });27  await client.activateApp("com.apple.Preferences");28  await client.deleteSession();29}30main();31const wdio = require("webdriverio");32async function main() {33  const client = await wdio.remote({34    capabilities: {35    },36  });37  await client.activateApp("com.apple.Preferences");38  await client.deleteSession();39}40main();41const wdio = require("webdriverio");42async function main() {

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 assert = chai.assert;7const expect = chai.expect;8const async = require('async');9const caps = {10};11const driver = wd.promiseChainRemote('localhost', 4723);12describe('Activate App', function () {13  this.timeout(600000);14  before(async () => {15    await driver.init(caps);16  });17  it('should activate app', async () => {18    await driver.backgroundApp(1);19    await driver.activateApp('com.example.apple-samplecode.UICatalog');20    let activeApp = await driver.execute('mobile: activeAppInfo');21    console.log(activeApp);22  });23  after(async () => {24    await driver.quit();25  });26});27info: [debug] [JSONWP Proxy] Got response with status 200: "{\"value\":\"com.example.apple-samplecode.UICatalog\",\"sessionId\":\"2E8B1B0B-9F9A-4B5F-8E7B-1B6B5D6B1F5E\",\"status\":0}"

Full Screen

Using AI Code Generation

copy

Full Screen

1import { WebDriver, By, Capabilities, Builder } from 'selenium-webdriver';2import { Options } from 'selenium-webdriver/chrome';3import { Options as FirefoxOptions } from 'selenium-webdriver/firefox';4import { Options as SafariOptions } from 'selenium-webdriver/safari';5import { Options as EdgeOptions } from 'selenium-webdriver/edge';6import { Options as OperaOptions } from 'selenium-webdriver/opera';7import { Options as IEOptions } from 'selenium-webdriver/ie';8import { Options as AndroidOptions } from 'selenium-webdriver/android';9import { Options as IosOptions } from 'selenium-webdriver/ios';10import { assert } from 'chai';11import { Options as AppiumOptions, ServiceBuilder } from 'selenium-webdriver/appium';12import { ServerConfig } from 'selenium-webdriver/remote';13import { Driver } from 'selenium-webdriver/chrome';14import { Driver as FirefoxDriver } from 'selenium-webdriver/firefox';15import { Driver as SafariDriver } from 'selenium-webdriver/safari';16import { Driver as EdgeDriver } from 'selenium-webdriver/edge';17import { Driver as OperaDriver } from 'selenium-webdriver/opera';18import { Driver as IEDriver } from 'selenium-webdriver/ie';19import { Driver as AndroidDriver } from 'selenium-webdriver/android';20import { Driver as IosDriver } from 'selenium-webdriver/ios';21const appiumService = new ServiceBuilder().usingAnyFreePort().build();22const appiumServerConfig = new ServerConfig(appiumService.address());23const appiumOptions = new AppiumOptions().setServer(appiumServerConfig);24const chromeOptions = new Options().addArguments('--disable-gpu');25const firefoxOptions = new FirefoxOptions().addArguments('--disable-gpu');26const safariOptions = new SafariOptions().addArguments('--disable-gpu');27const edgeOptions = new EdgeOptions().addArguments('--disable-gpu');28const operaOptions = new OperaOptions().addArguments('--disable-gpu');29const ieOptions = new IEOptions().addArguments('--disable-gpu');30const androidOptions = new AndroidOptions().addArguments('--disable-gpu');

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