From 88d6105f538f075968c152935131bf19bf289532 Mon Sep 17 00:00:00 2001 From: mgiambalvo Date: Fri, 4 Nov 2016 15:33:17 -0700 Subject: [PATCH] fix(gecko): Update geckodriver to 0.11.0 and fix suffixes. (#128) Fixes #111 --- config.json | 2 +- lib/binaries/gecko_driver.ts | 41 ++++++++++++++++++++++++++++++------ lib/cmds/update.ts | 13 ++++-------- 3 files changed, 39 insertions(+), 17 deletions(-) diff --git a/config.json b/config.json index c5337719..4666aeae 100644 --- a/config.json +++ b/config.json @@ -2,7 +2,7 @@ "webdriverVersions": { "selenium": "2.53.1", "chromedriver": "2.25", - "geckodriver": "v0.9.0", + "geckodriver": "v0.11.1", "iedriver": "2.53.1", "androidsdk": "24.4.1", "appium": "1.6.0" diff --git a/lib/binaries/gecko_driver.ts b/lib/binaries/gecko_driver.ts index ccad396f..e3a37ec5 100644 --- a/lib/binaries/gecko_driver.ts +++ b/lib/binaries/gecko_driver.ts @@ -1,9 +1,17 @@ import * as path from 'path'; +import * as semver from 'semver'; import {Config} from '../config'; import {Binary, OS} from './binary'; +type StringMap = { + [key: string]: string +}; +type SuffixMap = { + [key: string]: StringMap +}; + /** * The gecko driver binary. */ @@ -14,10 +22,13 @@ export class GeckoDriver extends Binary { static isDefault = true; static shortName = ['gecko']; - static suffixes: {[key: string]: string} = { - 'Darwin': '-mac.tar.gz', - 'Linux': '-linux64.tar.gz', - 'Windows_NT': '-win64.zip' + private static suffixes: SuffixMap = { + 'Darwin': {'x64': '-macos.tar.gz'}, + 'Linux': {'x64': '-linux64.tar.gz', 'ia32': '-linux32.tar.gz'}, + 'Windows_NT': { + 'x64': '-win64.zip', + 'ia32': '-win32.zip', + } }; constructor(alternateCDN?: string) { @@ -37,15 +48,31 @@ export class GeckoDriver extends Binary { } suffix(ostype: string, arch: string): string { - if (!GeckoDriver.supports(ostype, arch)) { + if (!GeckoDriver.suffixes[ostype][arch]) { throw new Error('GeckoDriver doesn\'t support ${ostype} ${arch}!'); } - return GeckoDriver.suffixes[ostype]; + let version: string = this.version(); + + // No 32-bit builds before 0.10.0 + if (semver.lte(version, '0.10.0')) { + if (arch === 'x64') { + throw new Error('GeckoDriver doesn\'t support ${ostype} ${arch}!'); + } + } + + // Special case old versions on Mac for the name change. + if (semver.lte(version, '0.9.0')) { + if (ostype === 'Darwin') { + return '-mac.tar.gz'; + } + } + + return GeckoDriver.suffixes[ostype][arch]; } static supports(ostype: string, arch: string): boolean { - return arch == 'x64' && (ostype in GeckoDriver.suffixes); + return !!GeckoDriver.suffixes[ostype][arch]; } url(ostype: string, arch: string): string { diff --git a/lib/cmds/update.ts b/lib/cmds/update.ts index 05480c46..99c1581c 100644 --- a/lib/cmds/update.ts +++ b/lib/cmds/update.ts @@ -26,16 +26,13 @@ let prog = new Program() .addOption(Opts[Opt.ALTERNATE_CDN]) .addOption(Opts[Opt.STANDALONE]) .addOption(Opts[Opt.CHROME]) + .addOption(Opts[Opt.GECKO]) .addOption(Opts[Opt.ANDROID]) .addOption(Opts[Opt.ANDROID_API_LEVELS]) .addOption(Opts[Opt.ANDROID_ARCHITECTURES]) .addOption(Opts[Opt.ANDROID_PLATFORMS]) .addOption(Opts[Opt.ANDROID_ACCEPT_LICENSES]); -if (GeckoDriver.supports(os.type(), os.arch())) { - prog.addOption(Opts[Opt.VERSIONS_GECKO]).addOption(Opts[Opt.GECKO]); -} - if (os.type() === 'Darwin') { prog.addOption(Opts[Opt.IOS]); } @@ -47,7 +44,8 @@ if (os.type() === 'Windows_NT') { prog.addOption(Opts[Opt.VERSIONS_STANDALONE]) .addOption(Opts[Opt.VERSIONS_CHROME]) .addOption(Opts[Opt.VERSIONS_APPIUM]) - .addOption(Opts[Opt.VERSIONS_ANDROID]); + .addOption(Opts[Opt.VERSIONS_ANDROID]) + .addOption(Opts[Opt.VERSIONS_GECKO]); if (os.type() === 'Windows_NT') { prog.addOption(Opts[Opt.VERSIONS_IE]); @@ -70,10 +68,7 @@ if (argv._[0] === 'update-run') { function update(options: Options): void { let standalone = options[Opt.STANDALONE].getBoolean(); let chrome = options[Opt.CHROME].getBoolean(); - let gecko = false; - if (GeckoDriver.supports(os.type(), os.arch())) { - gecko = options[Opt.GECKO].getBoolean(); - } + let gecko = options[Opt.GECKO].getBoolean(); let ie: boolean = false; let ie32: boolean = false; if (options[Opt.IE]) {