Skip to content

Instantly share code, notes, and snippets.

@titusfortner
Last active December 15, 2022 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save titusfortner/6f80e3828855e2d4981f35682aa173a5 to your computer and use it in GitHub Desktop.
Save titusfortner/6f80e3828855e2d4981f35682aa173a5 to your computer and use it in GitHub Desktop.
Use Keep Alive in Selenium Ruby
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
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
@nroose
Copy link

nroose commented Dec 15, 2022

Seems like a missing end in keep_alive.rb.

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