Skip to content

Commit

Permalink
Add back support for browser_binary setting (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewmcgarvey authored Jan 6, 2021
1 parent 8330f4c commit ff7c22d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license: MIT
dependencies:
selenium:
github: matthewmcgarvey/selenium.cr
version: ~> 0.8.0
version: ~> 0.9.0
webdrivers:
github: matthewmcgarvey/webdrivers.cr
version: ~> 0.3.0
Expand Down
11 changes: 9 additions & 2 deletions src/lucky_flow/drivers/chrome.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
abstract class LuckyFlow::Drivers::Chrome < LuckyFlow::Driver
def start_session : Selenium::Session
capabilities = Selenium::Chrome::Capabilities.new
capabilities.chrome_options.args = args
capabilities.chrome_options.binary = browser_binary
driver.create_session(capabilities)
rescue e : IO::Error
retry_start_session(e)
Expand All @@ -9,8 +12,8 @@ abstract class LuckyFlow::Drivers::Chrome < LuckyFlow::Driver
@driver.try(&.stop)
end

protected def capabilities
Selenium::Chrome::Capabilities.new
protected def args : Array(String)
[] of String
end

@driver : Selenium::Driver?
Expand All @@ -27,4 +30,8 @@ abstract class LuckyFlow::Drivers::Chrome < LuckyFlow::Driver
rescue err
raise DriverInstallationError.new(err)
end

private def browser_binary : String?
LuckyFlow.settings.browser_binary
end
end
7 changes: 2 additions & 5 deletions src/lucky_flow/drivers/headless_chrome.cr
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
class LuckyFlow::Drivers::HeadlessChrome < LuckyFlow::Drivers::Chrome
protected def capabilities
capabilities = super
capabilities.args(["no-sandbox", "headless", "disable-gpu"])

capabilities
protected def args : Array(String)
["no-sandbox", "headless", "disable-gpu"]
end
end

0 comments on commit ff7c22d

Please sign in to comment.