Skip to content
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

Unable to find Mozilla geckodriver #1

Closed
kandebonfim opened this issue Jul 29, 2019 · 11 comments
Closed

Unable to find Mozilla geckodriver #1

kandebonfim opened this issue Jul 29, 2019 · 11 comments

Comments

@kandebonfim
Copy link

kandebonfim commented Jul 29, 2019

Thanks for the buildpack!

I'm getting this error on heroku while trying to use selenium with firefox:

Selenium::WebDriver::Error::WebDriverError:  Unable to find Mozilla geckodriver. Please download the server from https://github.com/mozilla/geckodriver/releases and place it somewhere on your PATH. More info at https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver.

Here's my init code:

profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.download.dir'] = download_dir
profile['browser.download.folderList'] = 2
profile['browser.helperApps.neverAsk.saveToDisk'] = 'images/jpeg, application/pdf, application/octet-stream'
profile['browser.acceptInsecureCerts'] = true
profile['pdfjs.disabled'] = true

caps = Selenium::WebDriver::Remote::Capabilities.firefox
caps['acceptInsecureCerts'] = true

driver = Selenium::WebDriver.for :firefox, profile: profile, desired_capabilities: caps
@pyronlaboratory
Copy link
Owner

pyronlaboratory commented Aug 4, 2019

Make sure your environment variable are set to the following:

FIREFOX_BIN: /app/vendor/firefox/firefox
GECKODRIVER_PATH: /app/vendor/geckodriver/geckodriver
LD_LIBRARY_PATH: /usr/local/lib:/usr/lib:/lib:/app/vendor
PATH: /usr/local/bin:/usr/bin:/bin:/app/vendor/

This should do the trick.

@pyronlaboratory pyronlaboratory self-assigned this Aug 4, 2019
@kandebonfim
Copy link
Author

Hey, @ronnielivingsince1994! Took me a while to see your response here. I really need to get this working...

I've set those environment variables you said and tried again. Now I'm getting:

2019-08-15 23:11:52 WARN Selenium [DEPRECATION] :profile is deprecated. Use Selenium::WebDriver::Firefox::Options#profile= instead.
Selenium::WebDriver::Error::WebDriverError: not a file: "/app/vendor/geckodriver"
        from app/models/registry_order.rb:429:in `anac_sign_up'
        from app/models/registry_order.rb:402:in `anac_process'
        from (irb):2

Thanks in advance for helping me!

@pyronlaboratory
Copy link
Owner

From your error message, I understand that you're using Ruby probably. I'm more of a Python guy myself. Anyhoo, if you could get me a more detailed error log message, I would be able to investigate more.

Here, Selenium::WebDriver.logger.level = :debug add this to code to enable complete logs.

@pyronlaboratory
Copy link
Owner

Also could you make sure if you have set the config variables properly, since I see not a file: "/app/vendor/geckodriver" cause this is a directory and geckodriver is within that directory, so the path should be /app/vendor/geckodriver/geckodriver.. Or did you change the location of your driver?

@kandebonfim
Copy link
Author

Ok, I managed to pass the Selenium::WebDriver::Error::WebDriverError: not a file: "/app/vendor/geckodriver" error by using:

Selenium::WebDriver::Firefox.driver_path="/app/vendor/geckodriver/geckodriver"
Selenium::WebDriver::Firefox::Binary.path="/app/vendor/firefox/firefox"

I also changed the debug settings as you said:

Selenium::WebDriver.logger.level = :debug

And now I'm getting:

driver = Selenium::WebDriver.for :firefox
2019-08-16 14:00:43 DEBUG Selenium Executing Process ["/app/vendor/geckodriver/geckodriver", "--binary=/app/vendor/firefox/firefox", "--port=4445"]
2019-08-16 14:00:43 DEBUG Selenium polling for socket on ["127.0.0.1", 4445]
1565974843814   geckodriver     INFO    geckodriver 0.19.1
1565974843823   geckodriver     INFO    Listening on 127.0.0.1:4445
2019-08-16 14:00:44 INFO Selenium Skipping handshake as we know it is W3C.
2019-08-16 14:00:44 INFO Selenium -> POST session
2019-08-16 14:00:44 INFO Selenium    >>> http://127.0.0.1:4445/session | {"desiredCapabilities":{"browserName":"firefox","marionette":true,"timeouts":{},"moz:firefoxOptions":{}},"capabilities":{"firstMatch":[{"browserName":"firefox","timeouts":{},"moz:firefoxOptions":{}}]}}
2019-08-16 14:00:44 DEBUG Selenium      > {"Accept"=>"application/json", "Content-Type"=>"application/json; charset=UTF-8", "User-Agent"=>"selenium/3.12.0 (ruby linux)", "Content-Length"=>"201"}
1565974844197   mozrunner::runner       INFO    Running command: "/app/vendor/firefox/firefox" "-marionette" "-profile" "/tmp/rust_mozprofile.FS0xz381h8i5"
Error: GDK_BACKEND does not match available displays
2019-08-16 14:00:44 INFO Selenium <- {"value":{"error":"unknown error","message":"Process unexpectedly closed with status: 1","stacktrace":"stack backtrace:\n   0:           0x4edb3c - backtrace::backtrace::trace::hc4bd56a2f176de7e\n   1:           0x4edb72 - backtrace::capture::Backtrace::new::he3b2a15d39027c46\n   2:           0x440ac8 - webdriver::error::WebDriverError::new::ha0fbd6d1a1131b43\n   3:           0x4487ce - geckodriver::marionette::MarionetteHandler::create_connection::hf0532ddb9e159684\n   4:           0x428570 - <webdriver::server::Dispatcher<T, U>>::run::h2119c674d7b88193\n   5:           0x4029b9 - std::sys_common::backtrace::__rust_begin_short_backtrace::h21d98a9ff86d4c25\n   6:           0x40be65 - std::panicking::try::do_call::h5cff0c9b18cfdbba\n   7:           0x5e6a6c - panic_unwind::__rust_maybe_catch_panic\n                        at /checkout/src/libpanic_unwind/lib.rs:99\n   8:           0x41eb22 - <F as alloc::boxed::FnBox<A>>::call_box::h413eb1d9d9f1c473\n   9:           0x5df13b - alloc::boxed::{{impl}}::call_once<(),()>\n                        at /checkout/src/liballoc/boxed.rs:692\n                         - std::sys_common::thread::start_thread\n                        at /checkout/src/libstd/sys_common/thread.rs:21\n                         - std::sys::imp::thread::{{impl}}::new::thread_start\n                        at /checkout/src/libstd/sys/unix/thread.rs:84"}}
Selenium::WebDriver::Error::UnknownError: Process unexpectedly closed with status: 1

Thanks one more time for the help, internet stranger! ❤️

@kandebonfim
Copy link
Author

Wow, finally did it! Here's what I did:

profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.download.dir'] = download_dir
profile['browser.download.folderList'] = 2
profile['browser.helperApps.neverAsk.saveToDisk'] = 'images/jpeg, application/pdf, application/octet-stream'
profile['browser.acceptInsecureCerts'] = true
profile['pdfjs.disabled'] = true

caps = Selenium::WebDriver::Remote::Capabilities.firefox
caps['acceptInsecureCerts'] = true

options = ::Selenium::WebDriver::Firefox::Options.new
options.args << '--headless'

Selenium::WebDriver::Firefox.driver_path="/app/vendor/geckodriver/geckodriver"
Selenium::WebDriver::Firefox::Binary.path="/app/vendor/firefox/firefox"

# Debug
# Selenium::WebDriver.logger.level = :debug

driver = Selenium::WebDriver.for :firefox, profile: profile, desired_capabilities: caps, options: options
driver.navigate.to "https://www.google.com"
puts driver.title

@kandebonfim
Copy link
Author

@ronnielivingsince1994 this really helped me. I'm willing to pay at least a coffee for you man!

Do you want it? 🚀

@pyronlaboratory
Copy link
Owner

pyronlaboratory commented Aug 16, 2019

As a matter of fact I have a Ko-fi support page I could surely use a cup tonight!

@kandebonfim
Copy link
Author

@ronnielivingsince1994 the link looks broken...

Screen Shot 2019-08-27 at 15 17 01

@pyronlaboratory
Copy link
Owner

Ah, thats my bad. I've updated the link, you can try now if you want.

@kandebonfim
Copy link
Author

Nice!

Screen Shot 2019-08-28 at 19 24 09

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

No branches or pull requests

2 participants