Skip to content

Commit f95a18c

Browse files
committed
monkey patch the guards too
1 parent a7d34d5 commit f95a18c

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

examples/ruby/lib/monkey_patch.rb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Selenium
24
module WebDriver
35
module Chrome
@@ -9,12 +11,26 @@ def initialize(options: nil, service: nil, url: nil, **opts)
911

1012
begin
1113
super(caps: caps, url: url, **opts)
12-
rescue Selenium::WebDriver::Error::WebDriverError => e
14+
rescue Selenium::WebDriver::Error::WebDriverError
1315
@service_manager&.stop
1416
raise
1517
end
1618
end
1719
end
1820
end
1921
end
20-
end
22+
end
23+
24+
module Selenium
25+
module WebDriver
26+
module Support
27+
class Guards
28+
def add_condition(name, condition = nil, &)
29+
condition = false if condition.nil?
30+
@guard_conditions << GuardCondition.new(name, condition, &)
31+
WebDriver.logger.info "Running with Guard '#{name}' set to: #{condition}"
32+
end
33+
end
34+
end
35+
end
36+
end

0 commit comments

Comments
 (0)