Last active
December 15, 2022 18:14
-
-
Save titusfortner/6f80e3828855e2d4981f35682aa173a5 to your computer and use it in GitHub Desktop.
Use Keep Alive in Selenium Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Selenium | |
module WebDriver | |
module Remote | |
module Http | |
class KeepAlive < Default | |
def close | |
super | |
@http.finish if @http&.started? | |
end | |
private | |
def http | |
super.tap do |http| | |
http.start unless http.started? | |
end | |
end | |
end # KeepAlive | |
end # Http | |
end # Remote | |
end # WebDriver | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'keep_alive' | |
http_client = Selenium::WebDriver::Remote::Http::KeepAlive.new | |
# Selenium Example | |
driver = Selenium::Driver.for :chrome, http_client: http_client | |
# Watir Example | |
browser = Watir::Browser.new :chrome, http_client: http_client | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Seems like a missing
end
in keep_alive.rb.