How to use deleteDeviceWithRetry method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

Run Appium Xcuitest Driver automation tests on LambdaTest cloud grid

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

Sign up Free
_

simulator.js

Source: simulator.js Github

copy
1import _ from 'lodash';
2import Simctl from 'node-simctl';
3import { retryInterval } from 'asyncbox';
4import { killAllSimulators as simKill } from 'appium-ios-simulator';
5import { resetTestProcesses } from '../../../lib/utils';
6
7
8async function killAllSimulators () {
9  if (process.env.CLOUD) {
10    return;
11  }
12
13  const simctl = new Simctl();
14  const allDevices = _.flatMap(_.values(await simctl.getDevices()));
15  const bootedDevices = allDevices.filter((device) => device.state === 'Booted');
16
17  for (const {udid} of bootedDevices) {
18    // It is necessary to stop the corresponding xcodebuild process before killing
19    // the simulator, otherwise it will be automatically restarted
20    await resetTestProcesses(udid, true);
21    simctl.udid = udid;
22    await simctl.shutdownDevice();
23  }
24  await simKill();
25}
26
27async function shutdownSimulator (device) {
28  // stop XCTest processes if running to avoid unexpected side effects
29  await resetTestProcesses(device.udid, true);
30  await device.shutdown();
31}
32
33async function deleteDeviceWithRetry (udid) {
34  const simctl = new Simctl({udid});
35  try {
36    await retryInterval(10, 1000, simctl.deleteDevice.bind(simctl));
37  } catch (ign) {}
38}
39
40
41export { killAllSimulators, shutdownSimulator, deleteDeviceWithRetry };
42
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run JavaScript Tests on LambdaTest Cloud Grid

Execute automation tests with Appium Xcuitest Driver on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)