-
-
Save wellsmuker/cb80dfa6152d1318772cced0c36f1b27 to your computer and use it in GitHub Desktop.
Use Keep Alive in Selenium Ruby
This file contains hidden or 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 hidden or 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