Closed kandebonfim closed 5 years ago
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.
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!
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.
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?
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! ❤️
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
@ronnielivingsince1994 this really helped me. I'm willing to pay at least a coffee for you man!
Do you want it? 🚀
As a matter of fact I have a Ko-fi support page I could surely use a cup tonight!
@ronnielivingsince1994 the link looks broken...
Ah, thats my bad. I've updated the link, you can try now if you want.
Nice!
Thanks for the buildpack!
I'm getting this error on heroku while trying to use selenium with firefox:
Here's my init code: