Skip to content
This repository has been archived by the owner on Apr 1, 2019. It is now read-only.

Add support for the Windows executable #19

Closed
kevinrood opened this issue Jul 15, 2015 · 22 comments
Closed

Add support for the Windows executable #19

kevinrood opened this issue Jul 15, 2015 · 22 comments

Comments

@kevinrood
Copy link
Contributor

No description provided.

@flavorjones
Copy link
Owner

Hi @kevinrood, thanks for opening this issue.

I'm not sure what you mean here, though, as chromedriver-helper has supported Windows forever. Can you provide more information on what's not working for you, as well as information on what version of Windows, Ruby and chromedriver-helper you're using?

@Christopher-Steel
Copy link

Hello @flavorjones,

TL;DR: your wrapper script is never called by Selenium on Windows because it is named chromedriver instead of chromedriver.exe

First of all, very nice gem, I was happy to find it. It's worked perfectly for me both on Linux and on Mac OS. However, on Windows it does not work as smoothly.

I'm on Windows 7, using Git Bash to run the bundle install command.
This is my ruby version:

$ ruby --version
ruby 2.1.7p400 (2015-08-18 revision 51632) [i386-mingw32]

And here is the error printed when I try to run my ruby app after bundle install:

C:/Ruby21/lib/ruby/gems/2.1.0/gems/selenium-webdriver-2.47.1/lib/selenium/webdriver/chrome/service.rb:37:in `executable_path': Unable to find the chromedriver executable. Please download the server from http://chromedriver.storage.googleapis.com/index.html and place it somewhere on your PATH. More info at https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. (Selenium::WebDriver::Error::WebDriverError)
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/selenium-webdriver-2.47.1/lib/selenium/webdriver/chrome/service.rb:50:in `default_service'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/selenium-webdriver-2.47.1/lib/selenium/webdriver/chrome/bridge.rb:33:in `initialize'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/selenium-webdriver-2.47.1/lib/selenium/webdriver/common/driver.rb:56:in `new'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/selenium-webdriver-2.47.1/lib/selenium/webdriver/common/driver.rb:56:in `for'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/selenium-webdriver-2.47.1/lib/selenium/webdriver.rb:86:in `for'
        from C:/Users/testaccount/Documents/roach/session.rb:33:in `chrome_open'
        from C:/Users/testaccount/Documents/roach/session.rb:13:in `initialize'
        from C:/Users/testaccount/Documents/roach/roach_test.rb:17:in `new'
        from C:/Users/testaccount/Documents/roach/roach_test.rb:17:in `<main>'
UPDATE:

Currently testing on Windows 8, with cmd.exe and the same version of Ruby, I'll let you know the results when I'm done

UPDATE 2:

I had the exact same result on Windows 8 using cmd.exe

UPDATE 3:

I foraged around and ended up finding that a non windows version of chromedriver got installed, it was named chromedriver without the .exe and when I tried renaming it to add the .exe, it just crashed on load. I grabbed the file manually from google code and replaced the one installed by your gem and it fixed the problem.

I was curious about the source of this problem so I tried printing RbConfig::CONFIG["host_os"] in both Git Bash and cmd.exe and got
mingw32
in both cases

I'll do further investigation if I have the time for it, maybe even a pull request if I find the cause.

UPDATE 4:

My previous conclusion was wrong. The file I found was not chromedriver, it was the ruby script called chromedriver that gets copied to the ruby bin path when installing your gem. This means that there is a problem with the Chromedriver::Helper::run itself.
From the looks of it, it should be putting chromedriver in "~/.chromedriver-helper", however no directory or file is created when the code is run. I'll keep the investigation going.

UPDATE 5:

Alright, I've narrowed it down.

The way you seen to have build this is by having a ruby script named chromedriver copied to the users ruby bin folder through Gem::Specification::executables. This script then checks in ~/.chromedriver-helper/ to see if you already have the chromedriver binary and if you haven't it downloads it. Basically your script is a cached downloader for chromedriver.

While this is clever because it means that your file gets called when Selenium or other tries to use chromedriver, it does not work with Selenium on Windows because Selenium tries to use chromedriver.exe, not chromedriver. And while your script correctly accounts for windows by looking for chromedriver.exe, your script is never called because it isn't named chromedriver.exe

@aaronbriel
Copy link

aaronbriel commented Jun 15, 2016

I'm seeing this same issue on Windows 10. I've installed chromedriver-helper via gem install. Even with chromedriver.exe in my PATH I see the following error when attempting to run:
Unable to find the chromedriver executable. Please download the server from http://chromedriver.storage.googleapis.com/index.html and place it somewhere on your PATH. More info at https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. (Selenium::WebDriver::Error::WebDriverError)

When I added ~/.chromedriver-helper/win to my PATH this resolved the issue.

flavorjones added a commit that referenced this issue Mar 15, 2017
@flavorjones
Copy link
Owner

I've reproduced this, and I've put a failing integration test on the branch flavorjones-19-failing-windows-integration-test.

Unfortunately, I don't know how to make this test pass on Windows, and so I need your help.

Currently if I put a ruby script in bin/chromedriver.exe, Windows fails to run it (I see the error as Errno::EINVAL: Invalid argument - "chromedriver.exe" -v). I could make this a powershell script, but it would only work if people had lowered their security settings.

Any ideas on how to make that test pass?

@flavorjones
Copy link
Owner

Bumping this, anyone have an idea on what a solution looks like?

@matti
Copy link

matti commented Aug 27, 2018

could chromedriver add that directory to PATH ?

@flavorjones
Copy link
Owner

@matti The question of whether it's in the users $PATH doesn't affect the fact that default Windows security settings will not allow running a powershell script.

However, one other potential solution I haven't explored is using Selenium::WebDriver::Chrome.driver_path which might allow us to run powershell.exe with appropriate args to fire up a script.

@flavorjones
Copy link
Owner

Nope, recent versions of Selenium::WebDriver will only accept executables as an argument to driver_path=.

Still looking for a solution here.

@hajarNasr
Copy link

@flavorjones Thank you for your quick response. I am new to codding but since there's not a solution yet I made Platform.assert_executable path in drive_path in Chrome.rb as a comment, so it doesn't check whether or not chromedriver-helper is executable anymore. And rake test worked but I am not sure if that would break another part in the code?

@philipfong
Copy link

Hey there. I'm on a Windows 7 box and am able to get chromedriver to work on version 1.2.0. However on the latest version of the gem, I get the "not executable" error.

On 1.2.0, I'm able to simply go through a bundle install, followed by a chromedriver-update. I'm able to run tests using the oddly versioned 70.0.3538.16. Strangely, forcing 2.42 does NOT work and will produce an error.

It looks like on 1.2.0, chromedriver.exe is installed to C:\Users\philipfong.chromedriver-helper\70.0.3538.16\win directory. Is there a reason that an .exe is not used for the latest version of this gem?

@flavorjones
Copy link
Owner

@philipfong I'm not sure what you're asking, and I'm sorry for that.

This issue is describing a problem where, on modern Windowses (which I don't believe includes Windows 7) do not allow the execution of powershell scripts (as a matter of security policy), and so the "shim" script that this gem uses will not execute.

You seem to be describing a different problem, and so I'd like to ask that you open a new issue, please, and start from the beginning when describing what you're seeing. Thank you.

@shbeavers
Copy link

Adding chromedriver.exe to the C:\Windows\System32\ directory gets chromedriver working. However, this doesn't address why the chromedriver-helper installer isn't working anymore.

I've seen this problem on two Windows 10 machines where only recently has Ruby been installed along with a very recent version of chromedriver-helper. With systems that were set up in August, chomedriver-helper's install of Chromedriver functioned perfectly. These systems continued to work after updating to the latest versions of chromedriver-helper and chromedriver. The initial installation installed a .chromedriver-helper folder in the C:\Users\UserName directory with chromedriver.exe inside it a couple of folders deep (~\2.40\win).

So I'm inclined to ask "what changed?" in the past couple of months to break what had been working. Meanwhile, I'm content with the simple workaround of manually placing chromedriver.exe in a PATH location.

@flavorjones
Copy link
Owner

@shbeavers Thanks for your comment. I've tried to describe the issue above, and it's not due to anything that's changed in the past few months. This issue dates to 2015, and may or may not manifest depending on what security settings are present on your particular windows machines. Pre-Windows-10 this may have worked depending on group policy settings, etc.

Please also note that placing chromedriver.exe in your PATH means you really don't need this gem! Which is great if you're happy with that solution.

@shbeavers
Copy link

shbeavers commented Nov 7, 2018 via email

@philipfong
Copy link

@flavorjones sorry if I was unclear. What I was getting at was that using version 1.2.0 on Windows 7 works just fine whereas the latest version of the gem does not.

If you need steps to reproduce, simply run gem install chromedriver-helper then a chromedriver-update and failures will happen when attempting to run tests on Windows 7. However on 1.2.0 things work just fine.

I'm with @shbeavers in pretty much asking "what changed?"

@cmetadata
Copy link

The only solution for me is to use 1.2.0.

@flavorjones
Copy link
Owner

Hi all,

If something's not working that's changed since v1.2.0 then can someone please open a new ticket and we can dig in there? Again, this ticket was opened to describe an issue related to Windows 10 file permissioning that's existed for several years, and v1.2.0 was released earlier in Feb 2018.

Having a second (or third) issue here makes this information harder to find, so thank you in advance for helping me out and opening a new issue.

@cmetadata
Copy link

I read changing this

     def assert_executable(path)
        assert_file(path)

        return if File.executable? path
        raise Error::WebDriverError, "not executable: #{path.inspect}"
      end

To this

     def assert_executable(path)
        assert_file(path)

        return nil
        raise Error::WebDriverError, "not executable: #{path.inspect}"
      end

Also addresses the issue. So maybe that's a place to start?

@flavorjones
Copy link
Owner

@whatisc please see my request at #19 (comment)

@cmetadata
Copy link

I was under the impression it's the same issue? But maybe not.

@GrayStrider
Copy link

I read changing this

     def assert_executable(path)
        assert_file(path)

        return if File.executable? path
        raise Error::WebDriverError, "not executable: #{path.inspect}"
      end

To this

     def assert_executable(path)
        assert_file(path)

        return nil
        raise Error::WebDriverError, "not executable: #{path.inspect}"
      end

Also addresses the issue. So maybe that's a place to start?

Had this problem, worked. Thanks

@flavorjones
Copy link
Owner

I'm going to close this issue, as the gem is being deprecated in favor of webdrivers, see #83.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants