Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve Appium support in Nightwatch (#3519)
- Loading branch information
Showing
25 changed files
with
1,259 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const {WebDriver} = require('selenium-webdriver'); | ||
const {Executor} = require('selenium-webdriver/http'); | ||
const http = require('selenium-webdriver/http'); | ||
const SeleniumServer = require('./selenium'); | ||
const {isObject} = require('../../utils'); | ||
|
||
|
||
class AppiumBaseServer extends SeleniumServer { | ||
extractAppiumOptions() { | ||
// break 'appium:options' to individual configs | ||
if (isObject(this.desiredCapabilities['appium:options'])) { | ||
const appiumOptions = this.desiredCapabilities['appium:options']; | ||
for (let key of Object.keys(appiumOptions)) { | ||
const value = appiumOptions[key]; | ||
|
||
if (!key.startsWith('appium:')) { | ||
key = `appium:${key}`; | ||
} | ||
this.desiredCapabilities[key] = value; | ||
} | ||
|
||
delete this.desiredCapabilities['appium:options']; | ||
} | ||
} | ||
|
||
createAppiumDriver({options}) { | ||
const httpClient = new http.HttpClient(this.getServerUrl()); | ||
|
||
return WebDriver.createSession(new Executor(httpClient), options); | ||
} | ||
}; | ||
|
||
module.exports = AppiumBaseServer; |
23 changes: 23 additions & 0 deletions
23
lib/transport/selenium-webdriver/browserstack/appAutomate.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const BrowserStack = require('./browserstack.js'); | ||
|
||
class AppAutomate extends BrowserStack { | ||
get ApiUrl() { | ||
return `https://api.browserstack.com/${this.productNamespace}`; | ||
} | ||
|
||
get productNamespace() { | ||
return 'app-automate'; | ||
} | ||
|
||
createSessionOptions() { | ||
this.extractAppiumOptions(); | ||
|
||
return this.desiredCapabilities; | ||
} | ||
|
||
createDriver({options}) { | ||
return this.createAppiumDriver({options}); | ||
} | ||
} | ||
|
||
module.exports = AppAutomate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const BrowserStack = require('./browserstack.js'); | ||
const {Capabilities} = require('selenium-webdriver'); | ||
|
||
class Automate extends BrowserStack { | ||
get ApiUrl() { | ||
return `https://api.browserstack.com/${this.productNamespace}`; | ||
} | ||
|
||
get productNamespace() { | ||
return 'automate'; | ||
} | ||
|
||
createDriver({options = this.desiredCapabilities}) { | ||
if (options instanceof Capabilities) { | ||
return super.createDriver({options}); | ||
} | ||
|
||
return this.createAppiumDriver({options}); | ||
} | ||
} | ||
|
||
module.exports = Automate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.