Skip to content

Commit caa2fbe

Browse files
committed
[rb] allow creating subclass instances of Options from class method on super class, similar to Service class
1 parent 16d6469 commit caa2fbe

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

rb/lib/selenium/webdriver/common/options.rb

+27-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,33 @@ class Options
2323
W3C_OPTIONS = %i[browser_name browser_version platform_name accept_insecure_certs page_load_strategy proxy
2424
set_window_rect timeouts unhandled_prompt_behavior strict_file_interactability].freeze
2525

26-
def self.set_capabilities
27-
(W3C_OPTIONS + self::CAPABILITIES.keys).each do |key|
28-
next if method_defined? key
26+
class << self
27+
attr_reader :driver_path
28+
29+
def chrome(**opts)
30+
Chrome::Options.new(**opts)
31+
end
32+
33+
def firefox(**opts)
34+
Firefox::Options.new(**opts)
35+
end
36+
37+
def ie(**opts)
38+
IE::Options.new(**opts)
39+
end
40+
alias_method :internet_explorer, :ie
41+
42+
def edge(**opts)
43+
Edge::Options.new(**opts)
44+
end
45+
46+
def safari(**opts)
47+
Safari::Options.new(**opts)
48+
end
49+
50+
def set_capabilities
51+
(W3C_OPTIONS + self::CAPABILITIES.keys).each do |key|
52+
next if method_defined? key
2953

3054
define_method key do
3155
@options[key]

0 commit comments

Comments
 (0)