Skip to content

Commit 1f7cfcc

Browse files
committed
try monkey patch to stop the driver
1 parent b69d395 commit 1f7cfcc

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Diff for: examples/ruby/lib/monkey_patch.rb

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module Selenium
2+
module WebDriver
3+
module Chrome
4+
class Driver < Chromium::Driver
5+
include LocalDriver
6+
7+
def initialize(options: nil, service: nil, url: nil, **opts)
8+
caps, url = initialize_local_driver(options, service, url)
9+
10+
begin
11+
super(caps: caps, url: url, **opts)
12+
rescue Selenium::WebDriver::Error::WebDriverError => e
13+
@service_manager&.stop
14+
raise
15+
end
16+
end
17+
end
18+
end
19+
end
20+
end

Diff for: examples/ruby/spec/spec_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require 'selenium-webdriver'
44
require 'selenium/webdriver/support/guards'
5+
require_relative '../lib/monkey_patch'
56

67
RSpec.configure do |config|
78
# Enable flags like --only-failures and --next-failure
@@ -34,6 +35,7 @@ def start_session
3435
options.add_argument('disable-search-engine-choice-screen')
3536
options.add_argument('--no-sandbox')
3637
options.browser_version = 'stable'
38+
@service = Selenium::WebDriver::Service.chrome
3739
@driver = Selenium::WebDriver.for(:chrome, options: options)
3840
end
3941

0 commit comments

Comments
 (0)