From e98f71ebd7778d5c77c41bbecc73e31f1aeca177 Mon Sep 17 00:00:00 2001 From: tombatossals Date: Tue, 3 Dec 2013 10:32:35 +0100 Subject: [PATCH] fix(webdriver-manager): fix IEDriver install and running via windows Changed the binaries.ie.url function to return the correct URL for the IEDriverServer. Created the zip object in the win32 section to be able to decompress IEDriverServer. Added a function to normalize a command across OS and spawn it. It allows start the webdriver in win32. Seen here: https://github.com/yeoman/generator/blob/master/lib/actions/spawn_command.js --- bin/webdriver-manager | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/bin/webdriver-manager b/bin/webdriver-manager index d1b57bcdf..a642490b5 100755 --- a/bin/webdriver-manager +++ b/bin/webdriver-manager @@ -56,11 +56,9 @@ var binaries = { var urlPrefix = 'https://selenium.googlecode.com/files/IEDriverServer'; if (os.type() == 'Windows_NT') { if (os.arch() == 'x64') { - binaries.iedriver.url = urlPrefix + '_x64_' + versions.iedriver + - '.zip'; + return urlPrefix + '_x64_' + versions.iedriver + '.zip'; } else { - binaries.iedriver.url = urlPrefix + '_win32_' + versions.iedriver + - '.zip'; + return urlPrefix + '_win32_' + versions.iedriver + '.zip'; } } } @@ -125,6 +123,18 @@ var httpGetFile = function(fileUrl, fileName, outputDir, callback) { }); }; +/** + * Normalize a command across OS + */ +var spawnCommand = function(command, args) { + var win32 = process.platform === 'win32'; + var winCommand = win32 ? 'cmd' : command; + var finalArgs = win32 ? ['/c'].concat(command, args) : args; + + return require('child_process').spawn(winCommand, finalArgs, + { stdio: 'inherit' }); +}; + /** * If a new version of the file with the given url exists, download and * delete the old version. @@ -197,8 +207,7 @@ switch (argv._[0]) { args.push('-Dwebdriver.ie.driver=' + path.join(argv.out_dir, executableName('IEDriverServer'))); } - var javaChild = require('child_process').spawn( - 'java', args, { stdio: 'inherit' }); + spawnCommand('java', args); break; case 'status': for (name in binaries) { @@ -232,6 +241,7 @@ switch (argv._[0]) { if (argv.ie) { downloadIfNew(binaries.ie, argv.out_dir, existingFiles, function(filename) { + var zip = new AdmZip(filename); // Expected contents of the zip: // IEDriverServer.exe zip.extractAllTo(argv.out_dir);