From cea2448c55e9a34a3988d6e34f234432fbfb3f63 Mon Sep 17 00:00:00 2001 From: Isaac Murchie Date: Fri, 27 Jan 2017 08:00:33 -0500 Subject: [PATCH] Add version string to driver announcement --- lib/appium.js | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/lib/appium.js b/lib/appium.js index 89552f47..b19f48ca 100644 --- a/lib/appium.js +++ b/lib/appium.js @@ -96,6 +96,25 @@ class AppiumDriver extends BaseDriver { throw new Error(`${msg} Please check your desired capabilities.`); } + getDriverVersion (driver) { + const NAME_DRIVER_MAP = { + SelendroidDriver: 'appium-selendroid-driver', + AndroidUiautomator2Driver: 'appium-uiautomator2-driver', + XCUITestDriver: 'appium-xcuitest-driver', + YouiEngineDriver: 'appium-youiengine-driver', + FakeDriver: 'appium-fake-driver', + AndroidDriver: 'appium-android-driver', + IosDriver: 'appium-ios-driver', + WindowsDriver: 'appium-windows-driver', + }; + if (!NAME_DRIVER_MAP[driver.name]) { + log.warn(`Unable to get version of driver '${driver.name}'`); + return; + } + let {version} = require(`${NAME_DRIVER_MAP[driver.name]}/package.json`); + return version; + } + async getStatus () { let config = await getAppiumConfig(); let gitSha = config['git-sha']; @@ -114,16 +133,23 @@ class AppiumDriver extends BaseDriver { return sessions; } - async createSession (caps, reqCaps) { - caps = _.defaults(_.clone(caps), this.args.defaultCapabilities); - let InnerDriver = this.getDriverForCaps(caps); - let curSessions; - log.info(`Creating new ${InnerDriver.name} session`); + printNewSessionAnnouncement (driver, caps) { + let driverVersion = this.getDriverVersion(driver); + let introString = driverVersion ? + `Creating new ${driver.name} (v${driverVersion}) session` : + `Creating new ${driver.name} session`; + log.info(introString); log.info('Capabilities:'); util.inspect(caps); for (let [cap, value] of _.toPairs(caps)) { log.info(` ${cap}: ${util.inspect(value)}`); } + } + + async createSession (caps, reqCaps) { + caps = _.defaults(_.clone(caps), this.args.defaultCapabilities); + let InnerDriver = this.getDriverForCaps(caps); + this.printNewSessionAnnouncement(InnerDriver, caps); // sessionOverride server flag check // this will need to be re-thought when we go to multiple session support @@ -140,6 +166,7 @@ class AppiumDriver extends BaseDriver { } } + let curSessions; try { curSessions = this.curSessionDataForDriver(InnerDriver); } catch (e) {