selenium-webdriver 3.141.0 → 3.142.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +125 -0
  3. data/Gemfile +2 -0
  4. data/LICENSE +1 -1
  5. data/lib/selenium-webdriver.rb +2 -0
  6. data/lib/selenium/server.rb +9 -7
  7. data/lib/selenium/webdriver.rb +3 -1
  8. data/lib/selenium/webdriver/atoms.rb +20 -1
  9. data/lib/selenium/webdriver/atoms/getAttribute.js +6 -7
  10. data/lib/selenium/webdriver/atoms/isDisplayed.js +60 -59
  11. data/lib/selenium/webdriver/chrome.rb +10 -4
  12. data/lib/selenium/webdriver/chrome/bridge.rb +5 -3
  13. data/lib/selenium/webdriver/chrome/driver.rb +10 -13
  14. data/lib/selenium/webdriver/chrome/options.rb +4 -4
  15. data/lib/selenium/webdriver/chrome/profile.rb +4 -3
  16. data/lib/selenium/webdriver/chrome/service.rb +13 -13
  17. data/lib/selenium/webdriver/common.rb +4 -2
  18. data/lib/selenium/webdriver/common/action_builder.rb +2 -0
  19. data/lib/selenium/webdriver/common/alert.rb +2 -0
  20. data/lib/selenium/webdriver/common/bridge_helper.rb +8 -5
  21. data/lib/selenium/webdriver/common/driver.rb +22 -7
  22. data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +2 -0
  23. data/lib/selenium/webdriver/common/driver_extensions/has_addons.rb +2 -0
  24. data/lib/selenium/webdriver/common/driver_extensions/has_debugger.rb +2 -0
  25. data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +3 -3
  26. data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +2 -0
  27. data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +3 -1
  28. data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +2 -0
  29. data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +2 -0
  30. data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +2 -0
  31. data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +2 -0
  32. data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +2 -0
  33. data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +3 -1
  34. data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +2 -0
  35. data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +3 -3
  36. data/lib/selenium/webdriver/common/element.rb +3 -1
  37. data/lib/selenium/webdriver/common/error.rb +74 -18
  38. data/lib/selenium/webdriver/common/file_reaper.rb +3 -3
  39. data/lib/selenium/webdriver/common/html5/local_storage.rb +2 -0
  40. data/lib/selenium/webdriver/common/html5/session_storage.rb +2 -0
  41. data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +4 -1
  42. data/lib/selenium/webdriver/common/interactions/input_device.rb +3 -0
  43. data/lib/selenium/webdriver/common/interactions/interaction.rb +3 -0
  44. data/lib/selenium/webdriver/common/interactions/interactions.rb +3 -1
  45. data/lib/selenium/webdriver/common/interactions/key_actions.rb +2 -0
  46. data/lib/selenium/webdriver/common/interactions/key_input.rb +4 -0
  47. data/lib/selenium/webdriver/common/interactions/none_input.rb +3 -0
  48. data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +2 -0
  49. data/lib/selenium/webdriver/common/interactions/pointer_input.rb +7 -0
  50. data/lib/selenium/webdriver/common/keyboard.rb +4 -1
  51. data/lib/selenium/webdriver/common/keys.rb +3 -0
  52. data/lib/selenium/webdriver/common/log_entry.rb +4 -2
  53. data/lib/selenium/webdriver/common/logger.rb +15 -40
  54. data/lib/selenium/webdriver/common/logs.rb +2 -0
  55. data/lib/selenium/webdriver/common/{options.rb → manager.rb} +27 -1
  56. data/lib/selenium/webdriver/common/mouse.rb +3 -0
  57. data/lib/selenium/webdriver/common/navigation.rb +2 -0
  58. data/lib/selenium/webdriver/common/platform.rb +26 -30
  59. data/lib/selenium/webdriver/common/port_prober.rb +6 -19
  60. data/lib/selenium/webdriver/common/profile_helper.rb +2 -0
  61. data/lib/selenium/webdriver/common/proxy.rb +13 -5
  62. data/lib/selenium/webdriver/common/search_context.rb +6 -8
  63. data/lib/selenium/webdriver/common/service.rb +87 -29
  64. data/lib/selenium/webdriver/common/socket_lock.rb +10 -3
  65. data/lib/selenium/webdriver/common/socket_poller.rb +26 -18
  66. data/lib/selenium/webdriver/common/target_locator.rb +6 -4
  67. data/lib/selenium/webdriver/common/timeouts.rb +2 -0
  68. data/lib/selenium/webdriver/common/touch_action_builder.rb +5 -6
  69. data/lib/selenium/webdriver/common/touch_screen.rb +4 -1
  70. data/lib/selenium/webdriver/common/w3c_action_builder.rb +3 -0
  71. data/lib/selenium/webdriver/common/{w3c_options.rb → w3c_manager.rb} +3 -1
  72. data/lib/selenium/webdriver/common/wait.rb +13 -5
  73. data/lib/selenium/webdriver/common/window.rb +2 -0
  74. data/lib/selenium/webdriver/common/zipper.rb +3 -3
  75. data/lib/selenium/webdriver/edge.rb +11 -5
  76. data/lib/selenium/webdriver/edge/bridge.rb +2 -0
  77. data/lib/selenium/webdriver/edge/driver.rb +5 -12
  78. data/lib/selenium/webdriver/edge/options.rb +3 -0
  79. data/lib/selenium/webdriver/edge/service.rb +8 -12
  80. data/lib/selenium/webdriver/firefox.rb +10 -4
  81. data/lib/selenium/webdriver/firefox/binary.rb +7 -6
  82. data/lib/selenium/webdriver/firefox/bridge.rb +47 -0
  83. data/lib/selenium/webdriver/firefox/driver.rb +2 -0
  84. data/lib/selenium/webdriver/firefox/extension.rb +4 -4
  85. data/lib/selenium/webdriver/firefox/launcher.rb +3 -0
  86. data/lib/selenium/webdriver/firefox/legacy/driver.rb +7 -3
  87. data/lib/selenium/webdriver/firefox/marionette/bridge.rb +4 -2
  88. data/lib/selenium/webdriver/firefox/marionette/driver.rb +5 -11
  89. data/lib/selenium/webdriver/firefox/options.rb +20 -7
  90. data/lib/selenium/webdriver/firefox/profile.rb +7 -8
  91. data/lib/selenium/webdriver/firefox/profiles_ini.rb +3 -0
  92. data/lib/selenium/webdriver/firefox/service.rb +8 -19
  93. data/lib/selenium/webdriver/firefox/util.rb +2 -0
  94. data/lib/selenium/webdriver/ie.rb +10 -4
  95. data/lib/selenium/webdriver/ie/driver.rb +4 -10
  96. data/lib/selenium/webdriver/ie/options.rb +4 -2
  97. data/lib/selenium/webdriver/ie/service.rb +8 -12
  98. data/lib/selenium/webdriver/remote.rb +2 -0
  99. data/lib/selenium/webdriver/remote/bridge.rb +6 -4
  100. data/lib/selenium/webdriver/remote/capabilities.rb +23 -10
  101. data/lib/selenium/webdriver/remote/commands.rb +156 -0
  102. data/lib/selenium/webdriver/remote/driver.rb +2 -0
  103. data/lib/selenium/webdriver/remote/http/common.rb +11 -4
  104. data/lib/selenium/webdriver/remote/http/curb.rb +4 -2
  105. data/lib/selenium/webdriver/remote/http/default.rb +31 -25
  106. data/lib/selenium/webdriver/remote/http/persistent.rb +3 -1
  107. data/lib/selenium/webdriver/remote/oss/bridge.rb +5 -2
  108. data/lib/selenium/webdriver/remote/oss/commands.rb +106 -104
  109. data/lib/selenium/webdriver/remote/response.rb +11 -3
  110. data/lib/selenium/webdriver/remote/server_error.rb +2 -0
  111. data/lib/selenium/webdriver/remote/w3c/bridge.rb +28 -13
  112. data/lib/selenium/webdriver/remote/w3c/capabilities.rb +37 -21
  113. data/lib/selenium/webdriver/remote/w3c/commands.rb +61 -58
  114. data/lib/selenium/webdriver/safari.rb +11 -4
  115. data/lib/selenium/webdriver/safari/bridge.rb +5 -3
  116. data/lib/selenium/webdriver/safari/driver.rb +8 -10
  117. data/lib/selenium/webdriver/safari/options.rb +2 -0
  118. data/lib/selenium/webdriver/safari/service.rb +6 -25
  119. data/lib/selenium/webdriver/support.rb +2 -0
  120. data/lib/selenium/webdriver/support/abstract_event_listener.rb +2 -0
  121. data/lib/selenium/webdriver/support/block_event_listener.rb +3 -1
  122. data/lib/selenium/webdriver/support/color.rb +11 -9
  123. data/lib/selenium/webdriver/support/escaper.rb +2 -0
  124. data/lib/selenium/webdriver/support/event_firing_bridge.rb +3 -1
  125. data/lib/selenium/webdriver/support/select.rb +19 -18
  126. data/lib/selenium/webdriver/version.rb +3 -1
  127. data/selenium-webdriver.gemspec +14 -7
  128. metadata +89 -23
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Licensed to the Software Freedom Conservancy (SFC) under one
2
4
  # or more contributor license agreements. See the NOTICE file
3
5
  # distributed with this work for additional information
@@ -29,7 +31,7 @@ module Selenium
29
31
 
30
32
  class Capabilities
31
33
 
32
- EXTENSION_CAPABILITY_PATTERN = /\A[\w-]+:.*\z/
34
+ EXTENSION_CAPABILITY_PATTERN = /\A[\w-]+:.*\z/.freeze
33
35
 
34
36
  KNOWN = [
35
37
  :browser_name,
@@ -41,18 +43,19 @@ module Selenium
41
43
  :set_window_rect,
42
44
  :timeouts,
43
45
  :unhandled_prompt_behavior,
46
+ :strict_file_interactability,
44
47
 
45
48
  # remote-specific
46
49
  :remote_session_id,
47
50
 
48
- # TODO (alex): deprecate in favor of Firefox::Options?
51
+ # TODO: (alex) deprecate in favor of Firefox::Options?
49
52
  :accessibility_checks,
50
53
  :device,
51
54
 
52
- # TODO (alex): deprecate compatibility with OSS-capabilities
55
+ # TODO: (alex) deprecate compatibility with OSS-capabilities
53
56
  :implicit_timeout,
54
57
  :page_load_timeout,
55
- :script_timeout,
58
+ :script_timeout
56
59
  ].freeze
57
60
 
58
61
  KNOWN.each do |key|
@@ -61,7 +64,14 @@ module Selenium
61
64
  end
62
65
 
63
66
  next if key == :proxy
67
+
64
68
  define_method "#{key}=" do |value|
69
+ case key
70
+ when :accessibility_checks
71
+ WebDriver.logger.deprecate(":accessibility_checks capability")
72
+ when :device
73
+ WebDriver.logger.deprecate(":device capability")
74
+ end
65
75
  @capabilities[key] = value
66
76
  end
67
77
  end
@@ -81,20 +91,15 @@ module Selenium
81
91
 
82
92
  class << self
83
93
  def edge(opts = {})
84
- new({
85
- browser_name: 'MicrosoftEdge',
86
- platform: :windows
87
- }.merge(opts))
94
+ WebDriver.logger.deprecate('Selenium::WebDriver::Remote::W3C::Capabilities.edge',
95
+ 'Selenium::WebDriver::Remote::Capabilities.edge')
96
+ Remote::Capabilities.edge(opts)
88
97
  end
89
98
 
90
99
  def firefox(opts = {})
91
- opts[:browser_version] = opts.delete(:version) if opts.key?(:version)
92
- opts[:platform_name] = opts.delete(:platform) if opts.key?(:platform)
93
- opts[:timeouts] = {}
94
- opts[:timeouts]['implicit'] = opts.delete(:implicit_timeout) if opts.key?(:implicit_timeout)
95
- opts[:timeouts]['pageLoad'] = opts.delete(:page_load_timeout) if opts.key?(:page_load_timeout)
96
- opts[:timeouts]['script'] = opts.delete(:script_timeout) if opts.key?(:script_timeout)
97
- new({browser_name: 'firefox', marionette: true}.merge(opts))
100
+ WebDriver.logger.deprecate('Selenium::WebDriver::Remote::W3C::Capabilities.firefox',
101
+ 'Selenium::WebDriver::Remote::Capabilities.firefox')
102
+ Remote::Capabilities.firefox(opts)
98
103
  end
99
104
 
100
105
  alias_method :ff, :firefox
@@ -140,10 +145,10 @@ module Selenium
140
145
  # @param oss_capabilities [Hash, Remote::Capabilities]
141
146
  #
142
147
 
143
- def from_oss(oss_capabilities)
148
+ def from_oss(oss_capabilities) # rubocop:disable Metrics/MethodLength
144
149
  w3c_capabilities = new
145
150
 
146
- # TODO (alex): make capabilities enumerable?
151
+ # TODO: (alex) make capabilities enumerable?
147
152
  oss_capabilities = oss_capabilities.__send__(:capabilities) unless oss_capabilities.is_a?(Hash)
148
153
  oss_capabilities.each do |name, value|
149
154
  next if value.nil?
@@ -163,11 +168,23 @@ module Selenium
163
168
 
164
169
  # User can pass :firefox_options or :firefox_profile.
165
170
  #
166
- # TODO (alex): Refactor this whole method into converter class.
171
+ # TODO: (alex) Refactor this whole method into converter class.
167
172
  firefox_options = oss_capabilities['firefoxOptions'] || oss_capabilities['firefox_options'] || oss_capabilities[:firefox_options]
168
173
  firefox_profile = oss_capabilities['firefox_profile'] || oss_capabilities[:firefox_profile]
169
174
  firefox_binary = oss_capabilities['firefox_binary'] || oss_capabilities[:firefox_binary]
170
175
 
176
+ if firefox_options
177
+ WebDriver.logger.deprecate(':firefox_options capabilitiy', 'Selenium::WebDriver::Firefox::Options')
178
+ end
179
+
180
+ if firefox_profile
181
+ WebDriver.logger.deprecate(':firefox_profile capabilitiy', 'Selenium::WebDriver::Firefox::Options#profile')
182
+ end
183
+
184
+ if firefox_binary
185
+ WebDriver.logger.deprecate(':firefox_binary capabilitiy', 'Selenium::WebDriver::Firefox::Options#binary')
186
+ end
187
+
171
188
  if firefox_profile && firefox_options
172
189
  second_profile = firefox_options['profile'] || firefox_options[:profile]
173
190
  if second_profile && firefox_profile != second_profile
@@ -250,9 +267,7 @@ module Selenium
250
267
  if value
251
268
  hash['proxy'] = value.as_json
252
269
  hash['proxy']['proxyType'] &&= hash['proxy']['proxyType'].downcase
253
- if hash['proxy']['noProxy'].is_a?(String)
254
- hash['proxy']['noProxy'] = hash['proxy']['noProxy'].split(', ')
255
- end
270
+ hash['proxy']['noProxy'] = hash['proxy']['noProxy'].split(', ') if hash['proxy']['noProxy'].is_a?(String)
256
271
  end
257
272
  when String, :firefox_binary
258
273
  hash[key.to_s] = value
@@ -272,6 +287,7 @@ module Selenium
272
287
 
273
288
  def ==(other)
274
289
  return false unless other.is_a? self.class
290
+
275
291
  as_json == other.as_json
276
292
  end
277
293
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Licensed to the Software Freedom Conservancy (SFC) under one
2
4
  # or more contributor license agreements. See the NOTICE file
3
5
  # distributed with this work for additional information
@@ -32,119 +34,120 @@ module Selenium
32
34
  # session handling
33
35
  #
34
36
 
35
- new_session: [:post, 'session'.freeze],
36
- delete_session: [:delete, 'session/:session_id'.freeze],
37
+ new_session: [:post, 'session'],
38
+ delete_session: [:delete, 'session/:session_id'],
37
39
 
38
40
  #
39
41
  # basic driver
40
42
  #
41
43
 
42
- get: [:post, 'session/:session_id/url'.freeze],
43
- get_current_url: [:get, 'session/:session_id/url'.freeze],
44
- back: [:post, 'session/:session_id/back'.freeze],
45
- forward: [:post, 'session/:session_id/forward'.freeze],
46
- refresh: [:post, 'session/:session_id/refresh'.freeze],
47
- get_title: [:get, 'session/:session_id/title'.freeze],
44
+ get: [:post, 'session/:session_id/url'],
45
+ get_current_url: [:get, 'session/:session_id/url'],
46
+ back: [:post, 'session/:session_id/back'],
47
+ forward: [:post, 'session/:session_id/forward'],
48
+ refresh: [:post, 'session/:session_id/refresh'],
49
+ get_title: [:get, 'session/:session_id/title'],
48
50
 
49
51
  #
50
52
  # window and Frame handling
51
53
  #
52
54
 
53
- get_window_handle: [:get, 'session/:session_id/window'.freeze],
54
- close_window: [:delete, 'session/:session_id/window'.freeze],
55
- switch_to_window: [:post, 'session/:session_id/window'.freeze],
56
- get_window_handles: [:get, 'session/:session_id/window/handles'.freeze],
57
- fullscreen_window: [:post, 'session/:session_id/window/fullscreen'.freeze],
58
- minimize_window: [:post, 'session/:session_id/window/minimize'.freeze],
59
- maximize_window: [:post, 'session/:session_id/window/maximize'.freeze],
60
- set_window_size: [:post, 'session/:session_id/window/size'.freeze],
61
- get_window_size: [:get, 'session/:session_id/window/size'.freeze],
62
- set_window_position: [:post, 'session/:session_id/window/position'.freeze],
63
- get_window_position: [:get, 'session/:session_id/window/position'.freeze],
64
- set_window_rect: [:post, 'session/:session_id/window/rect'.freeze],
65
- get_window_rect: [:get, 'session/:session_id/window/rect'.freeze],
66
- switch_to_frame: [:post, 'session/:session_id/frame'.freeze],
67
- switch_to_parent_frame: [:post, 'session/:session_id/frame/parent'.freeze],
55
+ get_window_handle: [:get, 'session/:session_id/window'],
56
+ new_window: [:post, 'session/:session_id/window/new'],
57
+ close_window: [:delete, 'session/:session_id/window'],
58
+ switch_to_window: [:post, 'session/:session_id/window'],
59
+ get_window_handles: [:get, 'session/:session_id/window/handles'],
60
+ fullscreen_window: [:post, 'session/:session_id/window/fullscreen'],
61
+ minimize_window: [:post, 'session/:session_id/window/minimize'],
62
+ maximize_window: [:post, 'session/:session_id/window/maximize'],
63
+ set_window_size: [:post, 'session/:session_id/window/size'],
64
+ get_window_size: [:get, 'session/:session_id/window/size'],
65
+ set_window_position: [:post, 'session/:session_id/window/position'],
66
+ get_window_position: [:get, 'session/:session_id/window/position'],
67
+ set_window_rect: [:post, 'session/:session_id/window/rect'],
68
+ get_window_rect: [:get, 'session/:session_id/window/rect'],
69
+ switch_to_frame: [:post, 'session/:session_id/frame'],
70
+ switch_to_parent_frame: [:post, 'session/:session_id/frame/parent'],
68
71
 
69
72
  #
70
73
  # element
71
74
  #
72
75
 
73
- find_element: [:post, 'session/:session_id/element'.freeze],
74
- find_elements: [:post, 'session/:session_id/elements'.freeze],
75
- find_child_element: [:post, 'session/:session_id/element/:id/element'.freeze],
76
- find_child_elements: [:post, 'session/:session_id/element/:id/elements'.freeze],
77
- get_active_element: [:get, 'session/:session_id/element/active'.freeze],
78
- is_element_selected: [:get, 'session/:session_id/element/:id/selected'.freeze],
79
- get_element_attribute: [:get, 'session/:session_id/element/:id/attribute/:name'.freeze],
80
- get_element_property: [:get, 'session/:session_id/element/:id/property/:name'.freeze],
81
- get_element_css_value: [:get, 'session/:session_id/element/:id/css/:property_name'.freeze],
82
- get_element_text: [:get, 'session/:session_id/element/:id/text'.freeze],
83
- get_element_tag_name: [:get, 'session/:session_id/element/:id/name'.freeze],
84
- get_element_rect: [:get, 'session/:session_id/element/:id/rect'.freeze],
85
- is_element_enabled: [:get, 'session/:session_id/element/:id/enabled'.freeze],
76
+ find_element: [:post, 'session/:session_id/element'],
77
+ find_elements: [:post, 'session/:session_id/elements'],
78
+ find_child_element: [:post, 'session/:session_id/element/:id/element'],
79
+ find_child_elements: [:post, 'session/:session_id/element/:id/elements'],
80
+ get_active_element: [:get, 'session/:session_id/element/active'],
81
+ is_element_selected: [:get, 'session/:session_id/element/:id/selected'],
82
+ get_element_attribute: [:get, 'session/:session_id/element/:id/attribute/:name'],
83
+ get_element_property: [:get, 'session/:session_id/element/:id/property/:name'],
84
+ get_element_css_value: [:get, 'session/:session_id/element/:id/css/:property_name'],
85
+ get_element_text: [:get, 'session/:session_id/element/:id/text'],
86
+ get_element_tag_name: [:get, 'session/:session_id/element/:id/name'],
87
+ get_element_rect: [:get, 'session/:session_id/element/:id/rect'],
88
+ is_element_enabled: [:get, 'session/:session_id/element/:id/enabled'],
86
89
 
87
90
  #
88
91
  # document handling
89
92
  #
90
93
 
91
- get_page_source: [:get, 'session/:session_id/source'.freeze],
92
- execute_script: [:post, 'session/:session_id/execute/sync'.freeze],
93
- execute_async_script: [:post, 'session/:session_id/execute/async'.freeze],
94
+ get_page_source: [:get, 'session/:session_id/source'],
95
+ execute_script: [:post, 'session/:session_id/execute/sync'],
96
+ execute_async_script: [:post, 'session/:session_id/execute/async'],
94
97
 
95
98
  #
96
99
  # cookies
97
100
  #
98
101
 
99
- get_all_cookies: [:get, 'session/:session_id/cookie'.freeze],
100
- get_cookie: [:get, 'session/:session_id/cookie/:name'.freeze],
101
- add_cookie: [:post, 'session/:session_id/cookie'.freeze],
102
- delete_cookie: [:delete, 'session/:session_id/cookie/:name'.freeze],
103
- delete_all_cookies: [:delete, 'session/:session_id/cookie'.freeze],
102
+ get_all_cookies: [:get, 'session/:session_id/cookie'],
103
+ get_cookie: [:get, 'session/:session_id/cookie/:name'],
104
+ add_cookie: [:post, 'session/:session_id/cookie'],
105
+ delete_cookie: [:delete, 'session/:session_id/cookie/:name'],
106
+ delete_all_cookies: [:delete, 'session/:session_id/cookie'],
104
107
 
105
108
  #
106
109
  # timeouts
107
110
  #
108
111
 
109
- set_timeout: [:post, 'session/:session_id/timeouts'.freeze],
112
+ set_timeout: [:post, 'session/:session_id/timeouts'],
110
113
 
111
114
  #
112
115
  # actions
113
116
  #
114
117
 
115
- actions: [:post, 'session/:session_id/actions'.freeze],
116
- release_actions: [:delete, 'session/:session_id/actions'.freeze],
118
+ actions: [:post, 'session/:session_id/actions'],
119
+ release_actions: [:delete, 'session/:session_id/actions'],
117
120
 
118
121
  #
119
122
  # Element Operations
120
123
  #
121
124
 
122
- element_click: [:post, 'session/:session_id/element/:id/click'.freeze],
123
- element_tap: [:post, 'session/:session_id/element/:id/tap'.freeze],
124
- element_clear: [:post, 'session/:session_id/element/:id/clear'.freeze],
125
- element_send_keys: [:post, 'session/:session_id/element/:id/value'.freeze],
125
+ element_click: [:post, 'session/:session_id/element/:id/click'],
126
+ element_tap: [:post, 'session/:session_id/element/:id/tap'],
127
+ element_clear: [:post, 'session/:session_id/element/:id/clear'],
128
+ element_send_keys: [:post, 'session/:session_id/element/:id/value'],
126
129
 
127
130
  #
128
131
  # alerts
129
132
  #
130
133
 
131
- dismiss_alert: [:post, 'session/:session_id/alert/dismiss'.freeze],
132
- accept_alert: [:post, 'session/:session_id/alert/accept'.freeze],
133
- get_alert_text: [:get, 'session/:session_id/alert/text'.freeze],
134
- send_alert_text: [:post, 'session/:session_id/alert/text'.freeze],
134
+ dismiss_alert: [:post, 'session/:session_id/alert/dismiss'],
135
+ accept_alert: [:post, 'session/:session_id/alert/accept'],
136
+ get_alert_text: [:get, 'session/:session_id/alert/text'],
137
+ send_alert_text: [:post, 'session/:session_id/alert/text'],
135
138
 
136
139
  #
137
140
  # screenshot
138
141
  #
139
142
 
140
- take_screenshot: [:get, 'session/:session_id/screenshot'.freeze],
141
- take_element_screenshot: [:get, 'session/:session_id/element/:id/screenshot'.freeze],
143
+ take_screenshot: [:get, 'session/:session_id/screenshot'],
144
+ take_element_screenshot: [:get, 'session/:session_id/element/:id/screenshot'],
142
145
 
143
146
  #
144
147
  # server extensions
145
148
  #
146
149
 
147
- upload_file: [:post, 'session/:session_id/se/file'.freeze]
150
+ upload_file: [:post, 'session/:session_id/se/file']
148
151
  }.freeze
149
152
 
150
153
  end # Bridge
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Licensed to the Software Freedom Conservancy (SFC) under one
2
4
  # or more contributor license agreements. See the NOTICE file
3
5
  # distributed with this work for additional information
@@ -18,7 +20,6 @@
18
20
  require 'selenium/webdriver/safari/bridge'
19
21
  require 'selenium/webdriver/safari/driver'
20
22
  require 'selenium/webdriver/safari/options'
21
- require 'selenium/webdriver/safari/service'
22
23
 
23
24
  module Selenium
24
25
  module WebDriver
@@ -41,18 +42,24 @@ module Selenium
41
42
  @path ||= '/Applications/Safari.app/Contents/MacOS/Safari'
42
43
  return @path if File.file?(@path) && File.executable?(@path)
43
44
  raise Error::WebDriverError, 'Safari is only supported on Mac' unless Platform.os.mac?
45
+
44
46
  raise Error::WebDriverError, 'Unable to find Safari'
45
47
  end
46
48
 
47
49
  def driver_path=(path)
48
- Platform.assert_executable path
49
- @driver_path = path
50
+ WebDriver.logger.deprecate 'Selenium::WebDriver::Safari#driver_path=',
51
+ 'Selenium::WebDriver::Safari::Service#driver_path='
52
+ Selenium::WebDriver::Safari::Service.driver_path = path
50
53
  end
51
54
 
52
55
  def driver_path
53
- @driver_path ||= nil
56
+ WebDriver.logger.deprecate 'Selenium::WebDriver::Safari#driver_path',
57
+ 'Selenium::WebDriver::Safari::Service#driver_path'
58
+ Selenium::WebDriver::Safari::Service.driver_path
54
59
  end
55
60
  end
56
61
  end # Safari
57
62
  end # WebDriver
58
63
  end # Selenium
64
+
65
+ require 'selenium/webdriver/safari/service'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Licensed to the Software Freedom Conservancy (SFC) under one
2
4
  # or more contributor license agreements. See the NOTICE file
3
5
  # distributed with this work for additional information
@@ -22,9 +24,9 @@ module Selenium
22
24
 
23
25
  # https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/WebDriverEndpointDoc/Commands/Commands.html
24
26
  COMMANDS = {
25
- get_permissions: [:get, '/session/:session_id/apple/permissions'.freeze],
26
- set_permissions: [:post, '/session/:session_id/apple/permissions'.freeze],
27
- attach_debugger: [:post, '/session/:session_id/apple/attach_debugger'.freeze]
27
+ get_permissions: [:get, 'session/:session_id/apple/permissions'],
28
+ set_permissions: [:post, 'session/:session_id/apple/permissions'],
29
+ attach_debugger: [:post, 'session/:session_id/apple/attach_debugger']
28
30
  }.freeze
29
31
 
30
32
  def commands(command)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Licensed to the Software Freedom Conservancy (SFC) under one
2
4
  # or more contributor license agreements. See the NOTICE file
3
5
  # distributed with this work for additional information
@@ -32,15 +34,7 @@ module Selenium
32
34
  def initialize(opts = {})
33
35
  opts[:desired_capabilities] = create_capabilities(opts)
34
36
 
35
- unless opts.key?(:url)
36
- driver_path = opts.delete(:driver_path) || Safari.driver_path
37
- driver_opts = opts.delete(:driver_opts) || {}
38
- port = opts.delete(:port) || Service::DEFAULT_PORT
39
-
40
- @service = Service.new(driver_path, port, driver_opts)
41
- @service.start
42
- opts[:url] = @service.uri
43
- end
37
+ opts[:url] ||= service_url(opts)
44
38
 
45
39
  listener = opts.delete(:listener)
46
40
  @bridge = Remote::Bridge.handshake(opts)
@@ -49,10 +43,14 @@ module Selenium
49
43
  super(@bridge, listener: listener)
50
44
  end
51
45
 
46
+ def browser
47
+ :safari
48
+ end
49
+
52
50
  def quit
53
51
  super
54
52
  ensure
55
- @service.stop if @service
53
+ @service&.stop
56
54
  end
57
55
 
58
56
  private
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Licensed to the Software Freedom Conservancy (SFC) under one
2
4
  # or more contributor license agreements. See the NOTICE file
3
5
  # distributed with this work for additional information
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Licensed to the Software Freedom Conservancy (SFC) under one
2
4
  # or more contributor license agreements. See the NOTICE file
3
5
  # distributed with this work for additional information
@@ -23,34 +25,13 @@ module Selenium
23
25
  #
24
26
 
25
27
  class Service < WebDriver::Service
26
- DEFAULT_PORT = 7050
27
- @executable = '/usr/bin/safaridriver'.freeze
28
- @missing_text = <<-ERROR.gsub(/\n +| {2,}/, ' ').freeze
28
+ @default_port = 7050
29
+ @executable = 'safaridriver'
30
+ @missing_text = <<~ERROR
29
31
  Unable to find Apple's safaridriver which comes with Safari 10.
30
32
  More info at https://webkit.org/blog/6900/webdriver-support-in-safari-10/
31
33
  ERROR
32
-
33
- def stop
34
- stop_process
35
- end
36
-
37
- private
38
-
39
- def binary_path(path)
40
- path = self.class.executable if path.nil?
41
- raise Error::WebDriverError, self.class.missing_text unless path
42
- Platform.assert_executable path
43
- path
44
- end
45
-
46
- def start_process
47
- @process = build_process(@executable_path, "--port=#{@port}", *@extra_args)
48
- @process.start
49
- end
50
-
51
- def cannot_connect_error_text
52
- "unable to connect to safaridriver #{@host}:#{@port}"
53
- end
34
+ @shutdown_supported = false
54
35
  end # Service
55
36
  end # Safari
56
37
  end # WebDriver