-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add bin target w/.exe extension #29
add bin target w/.exe extension #29
Conversation
huh I'm surprised others didnt have this issue, PR looks good though. I have not seen the chromedriver package do this either |
Will publish a new version later today |
I'm surprised as well! Especially since selenium-webdriver looks for chromedriver.exe on Windows: And the node-chromedriver package doesn't create an ".exe" alias. As a result, I have the same problem with that package: $ npm install -g chromedriver
c:\mozilla-build\node-v8.1.4-win-x64\chromedriver -> c:\mozilla-build\node-v8.1.4-win-x64\node_modules\chromedriver\bin\chromedriver
> chromedriver@2.31.0 install c:\mozilla-build\node-v8.1.4-win-x64\node_modules\chromedriver
> node install.js
Downloading https://chromedriver.storage.googleapis.com/2.31/chromedriver_win32.zip
Saving to C:\Users\myk\AppData\Local\Temp\chromedriver\chromedriver_win32.zip
Received 782K...
Received 1568K...
Received 2352K...
Received 3136K...
Received 3920K...
Received 3922K total.
Extracting zip contents
Copying to target path c:\mozilla-build\node-v8.1.4-win-x64\node_modules\chromedriver\lib\chromedriver
Done. ChromeDriver binary available at c:\mozilla-build\node-v8.1.4-win-x64\node_modules\chromedriver\lib\chromedriver\chromedriver.exe
+ chromedriver@2.31.0
added 85 packages in 13.765s
$ which chromedriver
/c/mozilla-build/node-v8.1.4-win-x64/chromedriver
$ which chromedriver.exe
which: chromedriver.exe: unknown command
$ mkdir temp && cd temp
$ npm install selenium-webdriver
npm WARN saveError ENOENT: no such file or directory, open 'c:\Users\myk\temp\package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open 'c:\Users\myk\temp\package.json'
npm WARN temp No description
npm WARN temp No repository field.
npm WARN temp No README data
npm WARN temp No license field.
+ selenium-webdriver@3.5.0
added 30 packages in 13.813s
$ node
> const { Builder, By, Key, promise, until } = require('selenium-webdriver');
undefined
> const chrome = require('selenium-webdriver/chrome');
undefined
> const driver = new Builder().forBrowser('chrome').build();
Error: The ChromeDriver could not be found on the current PATH. Please download the latest version of the ChromeDriver from http://chromedriver.storage.googleapis.com/index.html
and ensure it can be found on your PATH.
at ServiceBuilder (c:\Users\myk\temp\node_modules\selenium-webdriver\chrome.js:215:13)
at getDefaultService (c:\Users\myk\temp\node_modules\selenium-webdriver\chrome.js:304:22)
at Function.createSession (c:\Users\myk\temp\node_modules\selenium-webdriver\chrome.js:752:44)
at createDriver (c:\Users\myk\temp\node_modules\selenium-webdriver\index.js:170:33)
at Builder.build (c:\Users\myk\temp\node_modules\selenium-webdriver\index.js:642:16)
at repl:1:51
at ContextifyScript.Script.runInThisContext (vm.js:44:33)
at REPLServer.defaultEval (repl.js:239:29)
at bound (domain.js:301:14)
at REPLServer.runBound [as eval] (domain.js:314:12) I found giggio/node-chromedriver#90 about it, which was closed because "You should be able to get the path to the binary using the exported path property, and then configure selenium." Which is a reasonable workaround, although it doesn't obviate the issue. Note that I'm installing both driver packages globally, whereas the node-chromedriver docs describe installing them locally. But when I do that and then run the Selenium example in the node-chromedriver docs (which is "Tested for selenium-webdriver version 2.48.2"), it still can't find the executable: $ npm install chromedriver
> chromedriver@2.31.0 install c:\Users\myk\temp\node_modules\chromedriver
> node install.js
Downloading https://chromedriver.storage.googleapis.com/2.31/chromedriver_win32.zip
Saving to C:\Users\myk\AppData\Local\Temp\chromedriver\chromedriver_win32.zip
Received 782K...
Received 1568K...
Received 2352K...
Received 3136K...
Received 3920K...
Received 3922K total.
Extracting zip contents
Copying to target path c:\Users\myk\temp\node_modules\chromedriver\lib\chromedriver
Done. ChromeDriver binary available at c:\Users\myk\temp\node_modules\chromedriver\lib\chromedriver\chromedriver.exe
npm WARN saveError ENOENT: no such file or directory, open 'c:\Users\myk\temp\package.json'
npm WARN enoent ENOENT: no such file or directory, open 'c:\Users\myk\temp\package.json'
npm WARN temp No description
npm WARN temp No repository field.
npm WARN temp No README data
npm WARN temp No license field.
+ chromedriver@2.31.0
added 69 packages in 9.922s
$ node
> require('chromedriver');
{ path: 'c:\\Users\\myk\\temp\\node_modules\\chromedriver\\lib\\chromedriver\\chromedriver.exe',
version: '2.31',
start: [Function],
stop: [Function] }
> var webdriver = require('selenium-webdriver');
undefined
> var driver = new webdriver.Builder().forBrowser('chrome').build();
undefined
> WebDriverError: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Windows NT 10.0.15063 x86_64)
at Object.checkLegacyResponse (c:\Users\myk\temp\node_modules\selenium-webdriver\lib\error.js:529:15)
at parseHttpResponse (c:\Users\myk\temp\node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (c:\Users\myk\temp\node_modules\selenium-webdriver\lib\http.js:441:30)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:208:7)
From: Task: WebDriver.createSession()
at Function.createSession (c:\Users\myk\temp\node_modules\selenium-webdriver\lib\webdriver.js:769:24)
at Function.createSession (c:\Users\myk\temp\node_modules\selenium-webdriver\chrome.js:761:15)
at createDriver (c:\Users\myk\temp\node_modules\selenium-webdriver\index.js:170:33)
at Builder.build (c:\Users\myk\temp\node_modules\selenium-webdriver\index.js:642:16)
at repl:1:59
at ContextifyScript.Script.runInThisContext (vm.js:44:33)
at REPLServer.defaultEval (repl.js:239:29)
at bound (domain.js:301:14)
at REPLServer.runBound [as eval] (domain.js:314:12)
at REPLServer.onLine (repl.js:433:10) |
This reverts commit f461013.
On Windows, as on other platforms, this package installs the ./bin/geckodriver script to a directory in PATH (which then runs the geckodriver.exe executable that gets downloaded to the package's directory). But the selenium-webdriver package expects to find a geckodriver.exe executable in the PATH on Windows:
https://github.com/SeleniumHQ/selenium/blob/master/javascript/node/selenium-webdriver/firefox/index.js#L296-L297
So it can't find the executable after I install it via this package.
This pull request is a hack that directs npm to install ./bin/geckodriver as geckodriver.exe as well. I'm not happy with this approach, since it happens on all three platforms rather than only on Windows. But it does solve the problem (and shouldn't cause problems on Mac/Linux).
An alternative might be to create this copy in the postinstall step, where we can test for platform.