Skip to content

Commit

Permalink
fix(webdriver-manager): fix IEDriver install and running via windows
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tombatossals authored and juliemr committed Dec 4, 2013
1 parent e97ea35 commit e98f71e
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions bin/webdriver-manager
Expand Up @@ -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';
}
}
}
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e98f71e

Please sign in to comment.