|
1 | 1 | const argv = require('yargs').argv;
|
2 | 2 | const AppiumDriver = require('nativescript-dev-appium').AppiumDriver;
|
| 3 | +const DeviceManager = require('nativescript-dev-appium').DeviceManager; |
3 | 4 | const fs = require('fs');
|
4 | 5 |
|
5 | 6 | const components = [
|
@@ -39,13 +40,23 @@ const makeDir = (path) => {
|
39 | 40 | makeDir('screenshots');
|
40 | 41 | makeDir(`screenshots/${argv.runType}`);
|
41 | 42 |
|
42 |
| - AppiumDriver.createAppiumDriver(4723, { |
43 |
| - isSauceLab: argv.sauceLab || false, |
44 |
| - runType: argv.runType, |
45 |
| - appPath: argv.appPath, //'nativescriptvueuitests-debug.apk', |
46 |
| - appiumCaps: require('./appium.capabilities.json')[argv.runType], |
47 |
| - verbose: argv.verbose || false, |
48 |
| - }) |
| 43 | + const appiumCaps = require('./appium.capabilities.json')[argv.runType]; |
| 44 | + let args = { |
| 45 | + isSauceLab: argv.sauceLab || false, |
| 46 | + runType: argv.runType, |
| 47 | + appPath: argv.appPath, //'nativescriptvueuitests-debug.apk', |
| 48 | + appiumCaps: appiumCaps, |
| 49 | + verbose: argv.verbose || false, |
| 50 | + } |
| 51 | + // Hack to fix a `Cannot read property 'token' of undefined` error |
| 52 | + // See https://github.com/NativeScript/nativescript-dev-appium/issues/142 |
| 53 | + if (args.isAndroid) { |
| 54 | + args.device = DeviceManager.getDefaultDevice(args, appiumCaps.avd); |
| 55 | + } else { |
| 56 | + args.device = DeviceManager.getDefaultDevice(args); |
| 57 | + } |
| 58 | + |
| 59 | + AppiumDriver.createAppiumDriver(4723, args) |
49 | 60 | .then(driver => run(driver))
|
50 | 61 | .then(() => console.log('Buh-Bye...'))
|
51 | 62 | .catch((err) => console.log(err));
|
|
0 commit comments