How to use launchApp method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

Device.test.js

Source:Device.test.js Github

copy

Full Screen

...69    await device.prepare();70    expect(device.deviceDriver.uninstallApp).not.toHaveBeenCalled();71    expect(device.deviceDriver.installApp).not.toHaveBeenCalled();72  });73  it(`launchApp() should launch app with default launch args`, async () => {74    device = validDevice();75    await device.launchApp();76    expect(device.deviceDriver.launchApp).toHaveBeenCalledWith(device._deviceId,77      device._bundleId,78      {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, undefined);79  });80  it('launchApp({languageAndLocale}) should launch app with a specific language/locale', async () => {81    device = validDevice();82    const languageAndLocale = {83      language: 'es-MX',84      locale: 'es-MX'85    };86    await device.launchApp({languageAndLocale});87    expect(device.deviceDriver.launchApp).toHaveBeenCalledWith(device._deviceId,88      device._bundleId,89      {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, languageAndLocale);90  });91  it(`relaunchApp()`, async () => {92    device = validDevice();93    await device.relaunchApp();94    expect(device.deviceDriver.terminate).toHaveBeenCalled();95    expect(device.deviceDriver.launchApp).toHaveBeenCalledWith(device._deviceId,96      device._bundleId,97      {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, undefined);98  });99  it(`relaunchApp({newInstance: false}) should not terminate the app before launch`, async () => {100    device = validDevice();101    await device.relaunchApp({newInstance: false});102    expect(device.deviceDriver.terminate).not.toHaveBeenCalled();103  });104  it(`relaunchApp({newInstance: true}) should terminate the app before launch`, async () => {105    device = validDevice();106    await device.relaunchApp({newInstance: true});107    expect(device.deviceDriver.terminate).toHaveBeenCalled();108  });109  it(`relaunchApp() (no params) should terminate the app before launch - backwards compat`, async () => {110    device = validDevice();111    await device.relaunchApp();112    expect(device.deviceDriver.terminate).toHaveBeenCalled();113  });114  it(`relaunchApp() with delete=true`, async () => {115    device = validDevice();116    fs.existsSync.mockReturnValue(true);117    await device.relaunchApp({delete: true});118    expect(device.deviceDriver.uninstallApp).toHaveBeenCalled();119    expect(device.deviceDriver.installApp).toHaveBeenCalled();120    expect(device.deviceDriver.launchApp).toHaveBeenCalledWith(device._deviceId,121      device._bundleId,122      {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, undefined);123  });124  it(`relaunchApp() without delete when reuse is enabled should not uninstall and install`, async () => {125    device = validDevice();126    argparse.getArgValue.mockReturnValue(true);127    fs.existsSync.mockReturnValue(true);128    await device.relaunchApp();129    expect(device.deviceDriver.uninstallApp).not.toHaveBeenCalled();130    expect(device.deviceDriver.installApp).not.toHaveBeenCalled();131    expect(device.deviceDriver.launchApp).toHaveBeenCalledWith(device._deviceId,132      device._bundleId,133      {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, undefined);134  });135  it(`relaunchApp() with url should send the url as a param in launchParams`, async () => {136    device = await validDevice();137    await device.relaunchApp({url: `scheme://some.url`});138    expect(device.deviceDriver.launchApp).toHaveBeenCalledWith(device._deviceId,139      device._bundleId,140      {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-detoxURLOverride": "scheme://some.url"}, undefined);141  });142  it(`relaunchApp() with url should send the url as a param in launchParams`, async () => {143    device = await validDevice();144    await device.relaunchApp({url: `scheme://some.url`, sourceApp: 'sourceAppBundleId'});145    expect(device.deviceDriver.launchApp).toHaveBeenCalledWith(device._deviceId,146      device._bundleId,147      {148        "-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-detoxURLOverride": "scheme://some.url", "-detoxSourceAppOverride":149        "sourceAppBundleId"150      }, undefined);151  });152  it(`launchApp() with disableTouchIndicators should send a boolean switch as a param in launchParams`, async () => {153    device = await validDevice();154    await device.launchApp({disableTouchIndicators: true});155    expect(device.deviceDriver.launchApp).toHaveBeenCalledWith(device._deviceId,156      device._bundleId,157      {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-detoxDisableTouchIndicators": true}, undefined);158  });159  it(`relaunchApp() with userNofitication should send the userNotification as a param in launchParams`, async () => {160    device = validDevice();161    fs.existsSync.mockReturnValue(true);162    device.deviceDriver.createPayloadFile = jest.fn(() => 'url');163    await device.relaunchApp({userNotification: 'json'});164    expect(device.deviceDriver.launchApp).toHaveBeenCalledWith(device._deviceId,165      device._bundleId,166      {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-detoxUserNotificationDataURL": "url"}, undefined);167  });168  it(`relaunchApp() with url and userNofitication should throw`, async () => {169    device = validDevice();170    try {171      await device.relaunchApp({url: "scheme://some.url", userNotification: 'notif'});172      fail('should fail');173    } catch (ex) {174      expect(ex).toBeDefined();175    }176  });177  it(`relaunchApp() with permissions should send trigger setpermissions before app starts`, async () => {178    device = await validDevice();179    await device.relaunchApp({permissions: {calendar: "YES"}});180    expect(device.deviceDriver.setPermissions).toHaveBeenCalledWith(device._deviceId,181      device._bundleId, {calendar: "YES"});182  });183  it(`launchApp({launchArgs: }) should pass to native as launch args`, async () => {184    device = validDevice();185    await device.launchApp({launchArgs: {arg1: "1", arg2: 2}});186    expect(device.deviceDriver.launchApp).toHaveBeenCalledWith(device._deviceId,187      device._bundleId,188      {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-arg1": "1", "-arg2": 2}, undefined);189  });190  it(`sendToHome() should pass to device driver`, async () => {191    device = validDevice();192    await device.sendToHome();193    expect(device.deviceDriver.sendToHome).toHaveBeenCalledTimes(1);194  });195  it(`shake() should pass to device driver`, async () => {196    device = validDevice();197    await device.shake();198    expect(device.deviceDriver.shake).toHaveBeenCalledTimes(1);199  });200  it(`terminateApp() should pass to device driver`, async () => {201    device = validDevice();202    await device.terminateApp();203    expect(device.deviceDriver.terminate).toHaveBeenCalledTimes(1);204  });205  it(`installApp() with a custom app path should use custom app path`, async () => {206    device = validDevice();207    fs.existsSync.mockReturnValue(true);208    await device.installApp('newAppPath');209    expect(device.deviceDriver.installApp).toHaveBeenCalledWith(device._deviceId, 'newAppPath', undefined);210  });211  it(`installApp() with a custom test app path should use custom test app path`, async () => {212    device = validDevice();213    fs.existsSync.mockReturnValue(true);214    await device.installApp('newAppPath', 'newTestAppPath');215    expect(device.deviceDriver.installApp).toHaveBeenCalledWith(device._deviceId, 'newAppPath', 'newTestAppPath');216  });217  it(`installApp() with no params should use the default path given in configuration`, async () => {218    device = validDevice();219    await device.installApp();220    expect(device.deviceDriver.installApp).toHaveBeenCalledWith(device._deviceId, device._binaryPath, device._testBinaryPath);221  });222  it(`uninstallApp() with a custom app path should use custom app path`, async () => {223    device = validDevice();224    fs.existsSync.mockReturnValue(true);225    await device.uninstallApp('newBundleId');226    expect(device.deviceDriver.uninstallApp).toHaveBeenCalledWith(device._deviceId, 'newBundleId');227  });228  it(`uninstallApp() with no params should use the default path given in configuration`, async () => {229    device = validDevice();230    await device.uninstallApp();231    expect(device.deviceDriver.uninstallApp).toHaveBeenCalledWith(device._deviceId, device._binaryPath);232  });233  it(`shutdown() should pass to device driver`, async () => {234    device = validDevice();235    await device.shutdown();236    expect(device.deviceDriver.shutdown).toHaveBeenCalledTimes(1);237  });238  it(`openURL({url:url}) should pass to device driver`, async () => {239    device = validDevice();240    await device.openURL({url: 'url'});241    expect(device.deviceDriver.deliverPayload).toHaveBeenCalledWith({url: 'url'});242  });243  it(`openURL(notAnObject) should pass to device driver`, async () => {244    device = validDevice();245    try {246      await device.openURL('url');247      fail('should throw');248    } catch (ex) {249      expect(ex).toBeDefined();250    }251  });252  it(`reloadReactNative() should pass to device driver`, async () => {253    device = validDevice();254    await device.reloadReactNative();255    expect(device.deviceDriver.reloadReactNative).toHaveBeenCalledTimes(1);256  });257  it(`setOrientation() should pass to device driver`, async () => {258    device = validDevice();259    await device.setOrientation('param');260    expect(device.deviceDriver.setOrientation).toHaveBeenCalledWith(device._deviceId, 'param');261  });262  it(`sendUserNotification() should pass to device driver`, async () => {263    device = validDevice();264    await device.sendUserNotification('notif');265    expect(device.deviceDriver.createPayloadFile).toHaveBeenCalledTimes(1);266    expect(device.deviceDriver.deliverPayload).toHaveBeenCalledTimes(1);267  });268  it(`sendUserActivity() should pass to device driver`, async () => {269    device = validDevice();270    await device.sendUserActivity('notif');271    expect(device.deviceDriver.createPayloadFile).toHaveBeenCalledTimes(1);272    expect(device.deviceDriver.deliverPayload).toHaveBeenCalledTimes(1);273  });274  it(`setLocation() should pass to device driver`, async () => {275    device = validDevice();276    await device.setLocation(30.1, 30.2);277    expect(device.deviceDriver.setLocation).toHaveBeenCalledWith(device._deviceId, '30.1', '30.2');278  });279  it(`setURLBlacklist() should pass to device driver`, async () => {280    device = validDevice();281    await device.setURLBlacklist();282    expect(device.deviceDriver.setURLBlacklist).toHaveBeenCalledTimes(1);283  });284  it(`enableSynchronization() should pass to device driver`, async () => {285    device = validDevice();286    await device.enableSynchronization();287    expect(device.deviceDriver.enableSynchronization).toHaveBeenCalledTimes(1);288  });289  it(`disableSynchronization() should pass to device driver`, async () => {290    device = validDevice();291    await device.disableSynchronization();292    expect(device.deviceDriver.disableSynchronization).toHaveBeenCalledTimes(1);293  });294  it(`resetContentAndSettings() should pass to device driver`, async () => {295    device = validDevice();296    await device.resetContentAndSettings();297    expect(device.deviceDriver.resetContentAndSettings).toHaveBeenCalledTimes(1);298  });299  it(`getPlatform() should pass to device driver`, async () => {300    device = validDevice();301    device.getPlatform();302    expect(device.deviceDriver.getPlatform).toHaveBeenCalledTimes(1);303  });304  it(`_cleanup() should pass to device driver`, async () => {305    device = validDevice();306    await device._cleanup();307    expect(device.deviceDriver.cleanup).toHaveBeenCalledTimes(1);308  });309  it(`new Device() with invalid device config (no binary) should throw`, () => {310    expect(() => new Device({311      deviceConfig: invalidDeviceNoBinary.configurations['ios.sim.release'],312      deviceDriver: new SimulatorDriver(client),313      sessionConfig: validScheme.session,314    })).toThrowErrorMatchingSnapshot();315  });316  it(`new Device() with invalid device config (no device name) should throw`, () => {317    expect(() => new Device({318      deviceConfig: invalidDeviceNoDeviceName.configurations['ios.sim.release'],319      deviceDriver: new SimulatorDriver(client),320      sessionConfig: validScheme.session,321    })).toThrowErrorMatchingSnapshot();322  });323  it(`launchApp({newInstance: false}) should check if process is in background and reopen it`, async () => {324    const processId = 1;325    device = validDevice();326    device.deviceDriver.getBundleIdFromBinary.mockReturnValue('test.bundle');327    device.deviceDriver.launchApp.mockReturnValue(processId);328    await device.prepare({launchApp: true});329    await device.launchApp({newInstance: false});330    expect(device.deviceDriver.deliverPayload).not.toHaveBeenCalled();331  });332  it(`launchApp({url: url}) should check if process is in background and use openURL() instead of launch args`, async () => {333    const processId = 1;334    device = validDevice();335    device.deviceDriver.getBundleIdFromBinary.mockReturnValue('test.bundle');336    device.deviceDriver.launchApp.mockReturnValue(processId);337    await device.prepare({launchApp: true});338    await device.launchApp({url: 'url://me'});339    expect(device.deviceDriver.deliverPayload).toHaveBeenCalledTimes(1);340  });341  it(`launchApp({url: url}) should check if process is in background and if not use launch args`, async () => {342    const launchParams = {url: 'url://me'};343    const processId = 1;344    const newProcessId = 2;345    device = validDevice();346    device.deviceDriver.getBundleIdFromBinary.mockReturnValue('test.bundle');347    device.deviceDriver.launchApp.mockReturnValueOnce(processId).mockReturnValueOnce(newProcessId);348    await device.prepare();349    await device.launchApp(launchParams);350    expect(device.deviceDriver.deliverPayload).not.toHaveBeenCalled();351  });352  it(`launchApp({url: url}) should check if process is in background and use openURL() instead of launch args`, async () => {353    const launchParams = {url: 'url://me'};354    const processId = 1;355    device = validDevice();356    device.deviceDriver.getBundleIdFromBinary.mockReturnValue('test.bundle');357    device.deviceDriver.launchApp.mockReturnValue(processId);358    await device.prepare({launchApp: true});359    await device.launchApp(launchParams);360    expect(device.deviceDriver.deliverPayload).toHaveBeenCalledWith({delayPayload: true, url: 'url://me'});361  });362  it('launchApp({userActivity: userActivity}) should check if process is in background and if it is use deliverPayload', async () => {363    const launchParams = {userActivity: 'userActivity'};364    const processId = 1;365    device = validDevice();366    device.deviceDriver.getBundleIdFromBinary.mockReturnValue('test.bundle');367    device.deviceDriver.launchApp.mockReturnValueOnce(processId).mockReturnValueOnce(processId);368    device.deviceDriver.createPayloadFile = () => 'url';369    await device.prepare({launchApp: true});370    await device.launchApp(launchParams);371    expect(device.deviceDriver.deliverPayload).toHaveBeenCalledWith({delayPayload: true, detoxUserActivityDataURL: 'url'});372  });373  it('launchApp({userNotification: userNotification}) should check if process is in background and if it is use deliverPayload', async () => {374    const launchParams = {userNotification: 'notification'};375    const processId = 1;376    device = validDevice();377    device.deviceDriver.getBundleIdFromBinary.mockReturnValue('test.bundle');378    device.deviceDriver.launchApp.mockReturnValueOnce(processId).mockReturnValueOnce(processId);379    device.deviceDriver.createPayloadFile = () => 'url';380    await device.prepare({launchApp: true});381    await device.launchApp(launchParams);382    expect(device.deviceDriver.deliverPayload).toHaveBeenCalledTimes(1);383  });384  it(`launchApp({userNotification: userNotification}) should check if process is in background and if not use launch args`, async () => {385    const launchParams = {userNotification: 'notification'};386    const processId = 1;387    const newProcessId = 2;388    device = validDevice();389    device.deviceDriver.getBundleIdFromBinary.mockReturnValue('test.bundle');390    device.deviceDriver.launchApp.mockReturnValueOnce(processId).mockReturnValueOnce(newProcessId);391    await device.prepare();392    await device.launchApp(launchParams);393    expect(device.deviceDriver.deliverPayload).not.toHaveBeenCalled();394  });395  it(`launchApp({userNotification: userNotification, url: url}) should fail`, async () => {396    const launchParams = {userNotification: 'notification', url: 'url://me'};397    const processId = 1;398    device = validDevice();399    device.deviceDriver.getBundleIdFromBinary.mockReturnValue('test.bundle');400    device.deviceDriver.launchApp.mockReturnValueOnce(processId).mockReturnValueOnce(processId);401    await device.prepare();402    try {403      await device.launchApp(launchParams);404      fail('should throw');405    } catch (ex) {406      expect(ex).toBeDefined();407    }408    expect(device.deviceDriver.deliverPayload).not.toHaveBeenCalled();409  });410  async function launchAndTestBinaryPath(configuration) {411    const device = schemeDevice(configurationsMock.pathsTests, configuration);412    await device.prepare();413    await device.launchApp();414    return device.deviceDriver.installApp.mock.calls[0][1];415  }416  it(`should accept absolute path for binary`, async () => {417    const actualPath = await launchAndTestBinaryPath('absolutePath');418    expect(actualPath).toEqual(process.platform === 'win32' ? 'C:\\Temp\\abcdef\\123' : '/tmp/abcdef/123');419  });420  it(`should accept relative path for binary`, async () => {421    const actualPath = await launchAndTestBinaryPath('relativePath');422    expect(actualPath).toEqual(path.join(process.cwd(), 'abcdef/123'));423  });424  it(`pressBack() should be called`, async () => {425    device = validDevice();426    await device.pressBack();427    expect(device.deviceDriver.pressBack).toHaveBeenCalledWith(device._deviceId);...

Full Screen

Full Screen

server.js

Source:server.js Github

copy

Full Screen

...17db.connect(function (err) {18  if (err) throw err;19});20//Initialize the app21function launchApp() {22  inquirer23    .prompt([24      {25        type: "list",26        name: "userSelect",27        message:28          "Welcome to your employee database! Please select an option below.",29        choices: [30          "View All Employees",31          "Add an Employee",32          "Update Employee Role",33          "View All Departments",34          "View All Roles",35          "Add a Department",36          "Add a Role",37          "Exit",38        ],39      },40    ])41    .then((answer) => {42      console.log(answer);43      switch (answer.userSelect) {44        case "View All Employees":45          viewEmployee();46          break;47        case "Add an Employee":48          addEmployee();49          break;50        case "Update Employee Role":51          updateRole();52          break;53        case "View All Roles":54          viewRoles();55          break;56        case "View All Departments":57          viewDepartment();58          break;59        case "Add a Department":60          addDepartment();61          break;62        case "Add a Role":63          addRole();64          break;65        case "Exit":66          console.log("Goodbye!");67          db.end();68          break;69      }70    });71  function viewEmployee() {72    let query = "SELECT * FROM employee";73    db.query(query, function (err, res) {74      if (err) throw err;75      console.log(res.length + " employees are currently employed!");76      console.table("Here are all employees:", res);77      launchApp();78    });79  }80  //Enter new employee information and add to employee table81  function addEmployee() {82    db.query("SELECT * FROM role", function (err, res) {83      if (err) throw err;84      inquirer85        .prompt([86          {87            name: "first_name",88            type: "input",89            message: "What is the employee's fist name? ",90          },91          {92            name: "last_name",93            type: "input",94            message: "What is the employee's last name? ",95          },96          {97            name: "manager_id",98            type: "input",99            message: "What is the employee's manager's ID? ",100          },101          {102            name: "role",103            type: "list",104            choices: function () {105              var roleArray = [];106              for (let i = 0; i < res.length; i++) {107                roleArray.push(res[i].title);108              }109              return roleArray;110            },111            message: "What is this employee's role? ",112          },113        ])114        .then(function (answer) {115          let role_id;116          for (let a = 0; a < res.length; a++) {117            if (res[a].title == answer.role) {118              role_id = res[a].id;119              console.log(role_id);120            }121          }122          db.query(123            "INSERT INTO employee SET ?",124            {125              first_name: answer.first_name,126              last_name: answer.last_name,127              manager_id: answer.manager_id,128              role_id: role_id,129            },130            function (err) {131              if (err) throw err;132              console.table(res);133              console.log("Your employee has been added!");134              launchApp();135            }136          );137        });138    });139  }140  //Add a department to department table141  function addDepartment() {142    inquirer143      .prompt([144        {145          name: "newDept",146          type: "input",147          message: "What is the name of the department?",148        },149      ])150      .then(function (answer) {151        db.query("INSERT INTO department SET ?", {152          name: answer.newDept,153        });154        let query = "SELECT * FROM department";155        db.query(query, function (err, res) {156          if (err) throw err;157          console.log("Your new department has been added!");158          console.table("All Departments:", res);159          launchApp();160        });161      });162  }163  //Add a new role to role table164  function addRole() {165    db.query("SELECT * FROM department", function (err, res) {166      if (err) throw err;167      inquirer168        .prompt([169          {170            name: "new_role",171            type: "input",172            message: "What new role would you like to add?",173          },174          {175            name: "salary",176            type: "input",177            message: "What is the salary of this role? (Enter a number)",178          },179          {180            name: "Department",181            type: "list",182            choices: function () {183              let deptArray = [];184              for (let i = 0; i < res.length; i++) {185                deptArray.push(res[i].name);186              }187              return deptArray;188            },189          },190        ])191        .then(function (answer) {192          let department_id;193          for (let a = 0; a < res.length; a++) {194            if (res[a].name == answer.Department) {195              department_id = res[a].id;196            }197          }198          db.query(199            "INSERT INTO role SET ?",200            {201              title: answer.new_role,202              salary: answer.salary,203              department_id: department_id,204            },205            function (err, res) {206              if (err) throw err;207              console.log("Your new role has been added!");208              console.table("All Roles:", res);209              launchApp();210            }211          );212        });213    });214  }215  //View all departments216  function viewDepartment() {217    let query = "SELECT * FROM department";218    db.query(query, function (err, res) {219      if (err) throw err;220      console.table("All Departments:", res);221      launchApp();222    });223  }224  //View all roles225  function viewRoles() {226    let query = "SELECT * FROM role";227    db.query(query, function (err, res) {228      if (err) throw err;229      console.table("All Roles:", res);230      launchApp();231    });232  }233  //Update a current role234  function updateRole() {235    let query = "UPDATE employee SET role_id = ? WHERE id = ?";236    db.query(237      `SELECT CONCAT(first_name," ",last_name) AS nameOfEmployee, id FROM employee;`,238      function (errEmployee, resEmployee) {239        if (errEmployee) throw errEmployee;240        db.query("Select title, id FROM role", function (errRole, resRole) {241          if (errRole) throw errRole;242          inquirer243            .prompt([244              {245                name: "nameOfEmployee",246                type: "list",247                message: "Select employee.",248                choices: resEmployee.map((employee) => {249                  return {250                    name: employee.nameOfEmployee,251                    value: employee.id,252                  };253                }),254              },255              {256                name: "employeeRole",257                type: "list",258                message: "Select employee's new role.",259                choices: resRole.map((role) => {260                  return {261                    name: role.title,262                    value: role.id,263                  };264                }),265              },266            ])267            .then(function (answer) {268              db.query(269                "UPDATE employee SET role_id = ? WHERE id = ?",270                [answer.employeeRole, answer.nameOfEmployee],271                function (err) {272                  if (err) throw err;273                  console.log("Employee role has been updated!");274                  launchApp();275                }276              );277            });278        });279      }280    );281  }282}...

Full Screen

Full Screen

06.device.test.js

Source:06.device.test.js Github

copy

Full Screen

...5    await element(by.text('Say Hello')).tap();6    await expect(element(by.text('Hello!!!'))).toBeVisible();7  });8  it('relaunchApp - should tap successfully', async () => {9    await device.relaunchApp();10    await element(by.text('Sanity')).tap();11    await element(by.text('Say Hello')).tap();12    await expect(element(by.text('Hello!!!'))).toBeVisible();13  });14  it('relaunchApp({delete: true}) - should tap successfully', async () => {15    await device.relaunchApp({delete: true});16    await element(by.text('Sanity')).tap();17    await element(by.text('Say Hello')).tap();18    await expect(element(by.text('Hello!!!'))).toBeVisible();19  });20  it('uninstall() + install() + relaunch() - should tap successfully', async () => {21    await device.uninstallApp();22    await device.installApp();23    await device.relaunchApp();24    await element(by.text('Sanity')).tap();25    await element(by.text('Say Hello')).tap();26    await expect(element(by.text('Hello!!!'))).toBeVisible();27  });28  it('launchApp({newInstance: true}) + sendToHome() + launchApp() - should bring up previous instance', async () => {29    await device.launchApp({newInstance: true});30    await element(by.text('Sanity')).tap();31    await element(by.text('Say Hello')).tap();32    await device.sendToHome();33    await device.launchApp();34    await expect(element(by.text('Hello!!!'))).toBeVisible();35  });36  // // Passing on iOS, not implemented on Android37  // it('launchApp in a different language', async () => {38  //   let languageAndLocale = {39  //     language: "es-MX",40  //     locale: "es-MX"41  //   };42  //   await device.launchApp({newInstance: true, languageAndLocale});43  //   await element(by.text('Language')).tap();44  //   await expect(element(by.text(`Current locale: ${languageAndLocale.locale}`))).toBeVisible();45  //   await expect(element(by.text(`Current language: ${languageAndLocale.language}`))).toBeVisible();46  //   languageAndLocale = {47  //     language: "en-US",48  //     locale: "en-US"49  //   };50  //   await device.launchApp({newInstance: true, languageAndLocale});51  //   await element(by.text('Language')).tap();52  //   await expect(element(by.text(`Current locale: ${languageAndLocale.locale}`))).toBeVisible();53  //   await expect(element(by.text(`Current language: ${languageAndLocale.language}`))).toBeVisible();54  // });55  it('resetContentAndSettings() + install() + relaunch() - should tap successfully', async () => {56    await device.resetContentAndSettings();57    await device.installApp();58    await device.launchApp({ newInstance: true });59    await element(by.text('Sanity')).tap();60    await element(by.text('Say Hello')).tap();61    await expect(element(by.text('Hello!!!'))).toBeVisible();62  });63  it(':ios: shake() should shake screen', async () => {64    await device.reloadReactNative();65    await element(by.text('Shake')).tap();66    await device.shake();67    await expect(element(by.text('Shaken, not stirred'))).toBeVisible();68  });69  it(':android: device back button - should show popup back pressed when back button is pressed', async () => {70    await device.reloadReactNative();71    await element(by.text('Actions')).tap();72    await device.pressBack();...

Full Screen

Full Screen

11.user-notifications.test.js

Source:11.user-notifications.test.js Github

copy

Full Screen

1describe(':ios: User Notifications', () => {2  it('Init from push notification', async () => {3    await device.launchApp({newInstance: true, userNotification: userNotificationPushTrigger});4    await expect(element(by.text('From push'))).toBeVisible();5  });6  xit('Init from calendar notification', async () => {7    await device.launchApp({newInstance: true, userNotification: userNotificationCalendarTrigger});8    await expect(element(by.text('From calendar'))).toBeVisible();9  });10  it('Background push notification', async () => {11    await device.launchApp({newInstance: true});12    await device.sendToHome();13    await device.launchApp({newInstance: false, userNotification: userNotificationPushTrigger});14    await expect(element(by.text('From push'))).toBeVisible();15  });16  it('Background calendar notification', async () => {17    await device.launchApp({newInstance: true});18    await device.sendToHome();19    await device.launchApp({newInstance: false, userNotification: userNotificationCalendarTrigger});20    await expect(element(by.text('From calendar'))).toBeVisible();21  });22  it('Foreground push notifications', async () => {23    await device.launchApp({newInstance: true});24    await device.sendUserNotification(userNotificationCalendarTrigger);25    await expect(element(by.text('From calendar'))).toBeVisible();26  });27  it('Foreground calendar notifications', async () => {28    await device.launchApp({newInstance: true});29    await device.sendUserNotification(userNotificationCalendarTrigger);30    await expect(element(by.text('From calendar'))).toBeVisible();31  });32});33const userNotificationPushTrigger = {34  "trigger": {35    "type": "push"36  },37  "title": "From push",38  "subtitle": "Subtitle",39  "body": "Body",40  "badge": 1,41  "payload": {42    "key1": "value1",...

Full Screen

Full Screen

group__nfc__launch__app__rec.js

Source:group__nfc__launch__app__rec.js Github

copy

Full Screen

1var group__nfc__launch__app__rec =2[3    [ "win_launchapp_payload_desc_t", "structwin__launchapp__payload__desc__t.html", [4      [ "app_id", "structwin__launchapp__payload__desc__t.html#ae04b88fce4a26a13e7070e6c83b53e04", null ],5      [ "app_id_length", "structwin__launchapp__payload__desc__t.html#a646459c8229ea8c4e04f5cb60c44226f", null ],6      [ "platform", "structwin__launchapp__payload__desc__t.html#a1dc5b20f77e906325387f2399f43c448", null ],7      [ "platform_length", "structwin__launchapp__payload__desc__t.html#a9116740dbec581c63daedb28d007ded4", null ]8    ] ],9    [ "NFC_ANDROID_REC_TYPE_LENGTH", "group__nfc__launch__app__rec.html#gad54f7048905f67c5c529dc8074cb381c", null ],10    [ "NFC_NDEF_ANDROID_LAUNCHAPP_RECORD_DESC", "group__nfc__launch__app__rec.html#ga05f5fd15ef8b30439ae0cdd858878882", null ],11    [ "NFC_NDEF_ANDROID_LAUNCHAPP_RECORD_DESC_DEF", "group__nfc__launch__app__rec.html#gade1a87a41b9a9e58db857f30db30d0a7", null ],12    [ "NFC_NDEF_WINDOWS_LAUNCHAPP_RECORD_DESC", "group__nfc__launch__app__rec.html#ga4a078cdd8861b0569df4aa109b4ded08", null ],13    [ "NFC_NDEF_WINDOWS_LAUNCHAPP_RECORD_DESC_DEF", "group__nfc__launch__app__rec.html#gadf5ccc06dc5f0d260f0bee70a80b8f6c", null ],14    [ "NFC_WINDOWS_PLAT_TYPE_LENGTH", "group__nfc__launch__app__rec.html#gaa9deddb74602127a6fd5a311ef8314e3", null ],15    [ "NFC_WINDOWS_REC_TYPE_LENGTH", "group__nfc__launch__app__rec.html#ga38ca289091bb2eb236a5bba39d2a831e", null ],16    [ "nfc_win_launchapp_payload_constructor", "group__nfc__launch__app__rec.html#gaf6a9df5a2a2246b0243845d77b20ce76", null ],17    [ "ndef_android_launchapp_rec_type", "group__nfc__launch__app__rec.html#gadc1507d1b8ecf4e6b5fd2387bcfaf3f1", null ],18    [ "ndef_windows_launchapp_plat_type", "group__nfc__launch__app__rec.html#ga3d75c7ed8ee4baf89212f572611580a9", null ],19    [ "ndef_windows_launchapp_rec_type", "group__nfc__launch__app__rec.html#ga2d8a43c99fe1700375947fbbb905b91b", null ]...

Full Screen

Full Screen

15.urls.test.js

Source:15.urls.test.js Github

copy

Full Screen

1describe('Open URLs', () => {2  afterAll(async () => {3    await device.launchApp({4      newInstance: true,5      url: undefined,6      launchArgs: undefined,7    });8  });9  const withDefaultArgs = () => ({10    url: 'detoxtesturlscheme://such-string',11    launchArgs: undefined,12  });13  const withSingleInstanceActivityArgs = () => ({14    url: 'detoxtesturlscheme.singleinstance://such-string',15    launchArgs: { androidSingleInstanceActivity: true },16  });17  [18    {19      platform: '',20      ...withDefaultArgs(),21    },22    {23      platform: 'android',24      ...withSingleInstanceActivityArgs(),25    }26  ].forEach((testSpec) => {27    const {platform, url, launchArgs} = testSpec;28    const _platform = platform ? `:${platform}: ` : '';29    it(`${_platform}device.launchApp() with a URL and a fresh app should launch app and trigger handling open url handling in app`, async () => {30      await device.launchApp({newInstance: true, url, launchArgs});31      await expect(element(by.text(url))).toBeVisible();32    });33    it(`${_platform}device.openURL() should trigger open url handling in app when app is in foreground`, async () => {34      await device.launchApp({newInstance: true, launchArgs});35      await expect(element(by.text(url))).toBeNotVisible();36      await device.openURL({url});37      await expect(element(by.text(url))).toBeVisible();38    });39    it(`${_platform}device.launchApp() with a URL should trigger url handling when app is in background`, async () => {40      await device.launchApp({newInstance: true, launchArgs});41      await expect(element(by.text(url))).toBeNotVisible();42      await device.sendToHome();43      await device.launchApp({newInstance: false, url});44      await expect(element(by.text(url))).toBeVisible();45    });46  });...

Full Screen

Full Screen

test-LaunchApp.js

Source:test-LaunchApp.js Github

copy

Full Screen

1/**2 * @file LaunchApp test3 * @author yelvye@baidu.com4 */5require('should');6const LaunchApp = require('../../../lib/directive/AppLuncher/LaunchApp');7describe('Test AppLuncher/LaunchApp.js', () => {8    let launchApp = new LaunchApp('appName', 'packageName', 'deepLink');9    launchApp.setAppName('appName by set');10    launchApp.setDeepLink('deepLink by set');11    launchApp.setPackageName('packageName by set');12    launchApp.setToken('token by set');13    it('#getData', () => {14        launchApp.getData().should.deepEqual({15            type: 'AppLauncher.LaunchApp',16            appName: 'appName by set',17            packageName: 'packageName by set',18            deepLink: 'deepLink by set',19            token: 'token by set'20        });21    });...

Full Screen

Full Screen

structwin__launchapp__payload__desc__t.js

Source:structwin__launchapp__payload__desc__t.js Github

copy

Full Screen

1var structwin__launchapp__payload__desc__t =2[3    [ "app_id", "structwin__launchapp__payload__desc__t.html#ae04b88fce4a26a13e7070e6c83b53e04", null ],4    [ "app_id_length", "structwin__launchapp__payload__desc__t.html#a646459c8229ea8c4e04f5cb60c44226f", null ],5    [ "platform", "structwin__launchapp__payload__desc__t.html#a1dc5b20f77e906325387f2399f43c448", null ],6    [ "platform_length", "structwin__launchapp__payload__desc__t.html#a9116740dbec581c63daedb28d007ded4", null ]...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const wdio = require('webdriverio');2const opts = {3    desiredCapabilities: {4    }5};6(async () => {7    const client = await wdio.remote(opts);8    await client.launchApp();9    await client.deleteSession();10})().catch((e) => console.error(e));11[0-0] 2017-11-20T10:26:29.671Z INFO webdriver: DATA { desiredCapabilities:12   { platformName: 'iOS',13     automationName: 'XCUITest' },14   { alwaysMatch:15      { platformName: 'iOS',16        automationName: 'XCUITest' },17     firstMatch: [ {} ] } }18[0-0] 2017-11-20T10:26:31.228Z INFO webdriver: COMMAND launchApp()19[0-0] 2017-11-20T10:26:31.228Z INFO webdriver: DATA {}

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var caps = {3};4driver.init(caps).then(function () {5  return driver.launchApp();6});7    at XCUITestDriver.launchApp$ (../../../lib/driver.js:193:15)8    at tryCatch (/Users/rajdeep/.nvm/versions/node/v6.11.1/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)9    at GeneratorFunctionPrototype.invoke [as _invoke] (/Users/rajdeep/.nvm/versions/node/v6.11.1/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)10    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Users/rajdeep/.nvm/versions/node/v6.11.1/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)11    at GeneratorFunctionPrototype.invoke (/Users/rajdeep/.nvm/versions/node/v6.11.1/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)12* Appium version (or git revision) that exhibits the issue: 1.6.513* Last Appium version that did not exhibit the issue (if applicable):

Full Screen

Using AI Code Generation

copy

Full Screen

1import wd from 'wd';2import { iosCaps } from './caps';3import { HOST, PORT } from './constants';4const driver = wd.promiseChainRemote(HOST, PORT);5(async () => {6  try {7    await driver.init(iosCaps);8    await driver.launchApp();9  } catch (err) {10    console.error(err);11  }12})();13const iosCaps = {14};15export { iosCaps };16const HOST = 'localhost';17const PORT = 4723;18export { HOST, PORT };

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const assert = require('assert');3const {exec} = require('child_process');4const {execSync} = require('child_process');5const {waitForCondition} = require('asyncbox');6const {IOSPerformanceLog} = require('appium-ios-log');7const {getSimulator} = require('appium-ios-simulator');8const {getLogger} = require('appium-support');9const {fs} = require('appium-support');10const SIMULATOR_UDID = 'D2F6C2B7-0D4A-4B9C-AC4D-4A4A3F3F7A3F';11const APP_BUNDLE_ID = 'com.example.apple-samplecode.UICatalog';12const LAUNCH_TIMEOUT = 60000;13const log = getLogger('Appium-XCUITest-Driver');14let iosLog = new IOSPerformanceLog({15});16let driver;17async function launchApp () {18  const isInstalled = await isAppInstalled();19  if (!isInstalled) {20    await installApp();21  }22  await iosLog.startCapture();23  await driver.execute('mobile: launchApp', {24  });25  await waitForCondition(async () => {26    const source = await driver.source();27    return source.includes('UICatalog');28  }, {29  });30}31async function isAppInstalled () {32  const {stdout} = await exec(`xcrun simctl get_app_container ${SIMULATOR_UDID} ${APP_BUNDLE_ID}`);33  return stdout.includes(APP_BUNDLE_ID);34}35async function installApp () {36  const appPath = await getAppPath();37  await execSync(`xcrun simctl install ${SIMULATOR_UDID} ${appPath}`);38}39async function getAppPath () {40  const appDir = await getSimulator(SIMULATOR_UDID).getDir();41  return `${appDir}/data/Containers/Bundle/Application/`;42}43async function startDriver () {44  await driver.init({

Full Screen

Using AI Code Generation

copy

Full Screen

1const wdio = require('webdriverio');2const opts = {3    desiredCapabilities: {4    }5};6async function launchAppWithBundleId () {7    let client = await wdio.remote(opts);8    await client.launchApp();9    await client.deleteSession();10}11launchAppWithBundleId();12const wdio = require('webdriverio');13const opts = {14    desiredCapabilities: {15    }16};17async function launchAppWithBundleId () {18    let client = await wdio.remote(opts);19    await client.launchApp();20    await client.deleteSession();21}22launchAppWithBundleId();23const wdio = require('webdriverio');24const opts = {25    desiredCapabilities: {26    }27};28async function launchAppWithBundleId () {29    let client = await wdio.remote(opts);30    await client.launchApp();31    await client.deleteSession();32}33launchAppWithBundleId();34const wdio = require('webdriverio');35const opts = {36    desiredCapabilities: {

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const { HOST, PORT, BUNDLE_ID } = require('./constants');3const { assert } = require('chai');4describe('Test Appium Xcuitest Driver', () => {5  let driver;6  before(async () => {7    driver = await wd.promiseChainRemote(HOST, PORT);8    await driver.init({9    });10  });11  it('should launch app', async () => {12    const bundleId = await driver.execute('mobile: launchApp', { bundleId: BUNDLE_ID });13    assert.strictEqual(bundleId, BUNDLE_ID);14  });15  after(async () => {16    await driver.quit();17  });18});19const HOST = 'localhost';20const PORT = 4723;21const BUNDLE_ID = 'com.example.testApp';22module.exports = {23};24{25  "scripts": {26  },27  "dependencies": {28  }29}30{31  "dependencies": {32    "@babel/code-frame": {

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const path = require('path');3const app = path.resolve(__dirname, 'app', 'TestApp.app.zip');4const appPackage = 'com.example.apple-samplecode.UICatalog';5    .init({6    })7    .then(() => {8        return driver.launchApp();9    })10    .then(() => {11        return driver.quit();12    })13    .catch((err) => {14        console.log('Error: ', err);15    });

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const assert = require('assert');3const {exec} = require('child_process');4const {CONFIG, CAPS} = require('./config');5const {getAppPath} = require('./utils');6async function main() {7  const driver = await wd.promiseChainRemote(CONFIG);8  const appPath = getAppPath();9  const caps = Object.assign(CAPS, {app: appPath});10  await driver.init(caps);11  await driver.launchApp();12  await driver.quit();13}14main();15const CONFIG = {16};17const CAPS = {18};19module.exports = {CONFIG, CAPS};20const path = require('path');21function getAppPath() {22  const appDir = path.join(__dirname, 'apps');23  return path.join(appDir, 'TestApp.app');24}25module.exports = {getAppPath};26Error: Could not navigate to webview; there are none!27    at XCUITestDriver.callee$0$0$ (/Users/username/appium-xcuitest-driver/lib/commands/web.js:32:13)28    at tryCatch (/Users/username/appium-xcuitest-driver/node_modules/babel-runtime/regenerator/runtime.js:67:40)29    at GeneratorFunctionPrototype.invoke [as _invoke] (/Users/username/appium-xcuitest-driver/node_modules/babel-runtime/regenerator/runtime.js:315:22)30    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Users/username/appium-xcuitest-driver/node_modules/babel-runtime/regenerator/runtime.js:100:21)31    at GeneratorFunctionPrototype.invoke (/Users/username/appium-xcuitest-driver/node_modules/babel-runtime/regenerator/runtime.js:136:37)32    at run (/Users/username/appium-xcuitest-driver/node_modules/core-js/modules/es

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