forked from nightwatchjs/nightwatch
/
appium.js
72 lines (54 loc) · 1.85 KB
/
appium.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const AppiumBaseServer = require('./appiumBase.js');
const AppiumServiceBuilder = require('./service-builders/appium');
const {iosRealDeviceUDID} = require('../../utils/mobile.js');
class AppiumServer extends AppiumBaseServer {
static createService(settings) {
const Options = require('./options.js');
const opts = new Options({settings});
opts.updateWebdriverPath();
const appiumService = new AppiumServiceBuilder(settings);
const outputFile = settings.webdriver.log_file_name || '';
appiumService.setOutputFile(outputFile);
return appiumService;
}
get defaultBrowser() {
return null;
}
get ServiceBuilder() {
return AppiumServiceBuilder;
}
get defaultServerUrl() {
return 'http://127.0.0.1:4723';
}
get defaultPort() {
return 4723;
}
get defaultPathPrefix() {
return '/wd/hub';
}
createSessionOptions(argv) {
this.extractAppiumOptions();
// set 'appium:udid' if deviceId present in argv
if (argv && argv.deviceId) {
const platformName = this.desiredCapabilities.platformName;
let udid = argv.deviceId;
if (platformName && platformName.toLowerCase() === 'ios') {
udid = iosRealDeviceUDID(udid);
}
this.desiredCapabilities['appium:udid'] = udid;
}
// if `appium:chromedriverExecutable` is present and left blank,
// assign the path of binary from `chromedriver` NPM package to it.
if (this.desiredCapabilities['appium:chromedriverExecutable'] === '') {
const chromedriver = this.seleniumCapabilities.getChromedriverPath();
if (chromedriver) {
this.desiredCapabilities['appium:chromedriverExecutable'] = chromedriver;
}
}
return super.createSessionOptions(argv) || this.desiredCapabilities;
}
createDriver({options}) {
return this.createAppiumDriver({options});
}
};
module.exports = AppiumServer;