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

Include Firefox driver #161

Closed
wout opened this issue Feb 22, 2024 · 2 comments
Closed

Include Firefox driver #161

wout opened this issue Feb 22, 2024 · 2 comments

Comments

@wout
Copy link
Contributor

wout commented Feb 22, 2024

In true Lucky spirit (aka "it just works"), having the Firefox driver included in the repo would be nice. Or at least documented. Using it would then be just a matter of changing a keyword for LuckyFlow.default_driver.

Here's what I came up with. Not sure if it's 100%, but it works as expected:

module LuckyFlow::Selenium
  class Firefox::Driver < Driver
    private getter driver : ::Selenium::Driver do
      service = ::Selenium::Service.firefox(driver_path: driver_path)
      ::Selenium::Driver.for(:firefox, service: service)
    end

    def initialize(&)
      super ::Selenium::Firefox::Capabilities.new
      yield @capabilities.as(::Selenium::Firefox::Capabilities)
    end

    private def driver_path
      LuckyFlow.settings.driver_path || Webdrivers::Geckodriver.install
    rescue err
      raise DriverInstallationError.new(err)
    end
  end
end

LuckyFlow::Registry.register :firefox do
  LuckyFlow::Selenium::Firefox::Driver.new { }
end

LuckyFlow::Registry.register :headless_firefox do
  LuckyFlow::Selenium::Firefox::Driver.new do |config|
    config.firefox_options.args = ["--headless"]
  end
end

Let me know if you'd like a PR.

Sidenote: I was forced to use Firefox because Chrome kept giving me element click intercepted: Element is not clickable at point (x, y). I tried a bunch of things without success, including different versions of Chrome.

@jwoertink
Copy link
Member

I'm down to add it in if you wanted to submit a PR. That would be awesome!

@jwoertink
Copy link
Member

Fixed by #162

Thanks!

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

No branches or pull requests

2 participants