Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should double tap on an element', async function () {
// FIXME: Multitouch does not work as expected in Xcode < 9.
// cloud tests are run on Linux, so no Xcode version to check
if (!process.env.CLOUD && (await xcode.getVersion(true)).major < 9) {
return this.skip();
}
await driver.execute('mobile: scroll', {direction: 'down'});
await driver.elementByAccessibilityId('Steppers').click();
let stepper = await driver.elementByAccessibilityId('Increment');
let action = new wd.TouchAction(driver);
action.tap({el: stepper, count: 2});
await action.perform();
await driver.elementByAccessibilityId('2')
.should.not.be.rejected;
});
it(`should swipe the table and the bottom cell's Y position should change accordingly`, async function () {
before(async function () {
// Don't do these tests on Sauce Labs
if (process.env.CLOUD) {
this.skip();
}
xcodeVersion = await getVersion(true);
});
describe('with fresh sim', function () {
async function killAllSimulators (timeout = DEFAULT_SIM_SHUTDOWN_TIMEOUT) {
log.debug('Killing all iOS Simulators');
const xcodeVersion = await getVersion(true);
const appName = xcodeVersion.major >= 7 ? 'Simulator' : 'iOS Simulator';
// later versions are slower to close
timeout = timeout * (xcodeVersion.major >= 8 ? 2 : 1);
try {
await exec('xcrun', ['simctl', 'shutdown', xcodeVersion.major > 8 ? 'all' : 'booted'], {timeout});
} catch (ign) {}
const pids = [];
try {
const {stdout} = await exec('pgrep', ['-f', `${appName}.app/Contents/MacOS/`]);
if (stdout.trim()) {
pids.push(...(stdout.trim().split(/\s+/)));
}
} catch (e) {
before(async function () {
let exists = await fs.exists(app);
if (!exists) {
app = path.resolve(__dirname, '..', '..', '..', 'test', 'assets', 'TestApp-iphonesimulator.app');
}
xcodeVersion = await xcode.getVersion(true);
});
before(async function () {
({major, minor} = await xcode.getVersion(true));
if (major < 8 || (major === 8 && minor < 1)) {
return this.skip();
}
const sdk = process.env.IOS_SDK || _.last(validSdks);
udid = await createDevice('runningSimTest', DEVICE_NAME, sdk);
await bootDevice(udid);
await startBootMonitor(udid, {timeout: MOCHA_TIMEOUT});
});
after(async function () {
async configure () {
if (!this.xcodeVersion) {
this.xcodeVersion = await xcode.getVersion(true);
}
if (this.xcodeVersion.versionFloat === 6.0 && this.withoutDelay) {
log.info('In xcode 6.0, instruments-without-delay does not work. ' +
'If using Appium, you can disable instruments-without-delay ' +
'with the --native-instruments-lib server flag');
}
if (this.xcodeVersion.versionString === '5.0.1') {
throw new Error('Xcode 5.0.1 ships with a broken version of ' +
'Instruments. please upgrade to 5.0.2');
}
if (!this.template) {
this.template = await xcode.getAutomationTraceTemplatePath();
}
if (!this.instrumentsPath) {
async function getDeviceString (opts) {
let xcodeVersion = await xcode.getVersion(true);
handleUnsupportedXcode(xcodeVersion);
log.info(`Retrieving device name string for Xcode version ${xcodeVersion.versionString}`);
if (xcodeVersion.major >= 8) {
return await SimulatorXcode7.getDeviceString(opts);
} else if (xcodeVersion.major === 7) {
return await SimulatorXcode7.getDeviceString(opts);
} else if (xcodeVersion.major === 6) {
return await SimulatorXcode6.getDeviceString(opts);
}
}
async configure () {
if (!this.xcodeVersion) {
this.xcodeVersion = await xcode.getVersion(true);
}
if (this.xcodeVersion.versionFloat === 6.0 && this.withoutDelay) {
log.info('In xcode 6.0, instruments-without-delay does not work. ' +
'If using Appium, you can disable instruments-without-delay ' +
'with the --native-instruments-lib server flag');
}
if (this.xcodeVersion.versionString === '5.0.1') {
throw new Error('Xcode 5.0.1 ships with a broken version of ' +
'Instruments. please upgrade to 5.0.2');
}
if (this.xcodeVersion.major > 7) {
throw new Error(`Instruments-based automation was removed in Xcode 8. ` +
`Xcode ${this.xcodeVersion.versionString} is not supported. ` +
`Please try the XCUItest driver.`);
}