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


Source: simulator.js Github

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';
8async function killAllSimulators () {
9  if (process.env.CLOUD) {
10    return;
11  }
13  const simctl = new Simctl();
14  const allDevices = _.flatMap(_.values(await simctl.getDevices()));
15  const bootedDevices = allDevices.filter((device) => device.state === 'Booted');
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();
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();
33async function deleteDeviceWithRetry (udid) {
34  const simctl = new Simctl({udid});
35  try {
36    await retryInterval(10, 1000, simctl.deleteDevice.bind(simctl));
37  } catch (ign) {}
41export { killAllSimulators, shutdownSimulator, deleteDeviceWithRetry };
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

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

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)