selenium-webdriver 3.141.0 → 3.142.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +150 -0
  3. data/Gemfile +2 -0
  4. data/LICENSE +1 -1
  5. data/lib/selenium/server.rb +9 -7
  6. data/lib/selenium/webdriver/atoms/getAttribute.js +6 -7
  7. data/lib/selenium/webdriver/atoms/isDisplayed.js +60 -59
  8. data/lib/selenium/webdriver/atoms.rb +20 -1
  9. data/lib/selenium/webdriver/chrome/bridge.rb +23 -3
  10. data/lib/selenium/webdriver/chrome/driver.rb +30 -20
  11. data/lib/selenium/webdriver/chrome/options.rb +11 -7
  12. data/lib/selenium/webdriver/chrome/profile.rb +6 -5
  13. data/lib/selenium/webdriver/chrome/service.rb +13 -13
  14. data/lib/selenium/webdriver/chrome.rb +10 -4
  15. data/lib/selenium/webdriver/common/action_builder.rb +2 -0
  16. data/lib/selenium/webdriver/common/alert.rb +2 -0
  17. data/lib/selenium/webdriver/common/bridge_helper.rb +8 -5
  18. data/lib/selenium/webdriver/common/driver.rb +22 -7
  19. data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +2 -0
  20. data/lib/selenium/webdriver/common/driver_extensions/has_addons.rb +2 -0
  21. data/lib/selenium/webdriver/common/driver_extensions/has_debugger.rb +2 -0
  22. data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +3 -3
  23. data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +2 -0
  24. data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +3 -1
  25. data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +2 -0
  26. data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +2 -0
  27. data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +2 -0
  28. data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +2 -0
  29. data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +2 -0
  30. data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +3 -1
  31. data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +2 -0
  32. data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +3 -3
  33. data/lib/selenium/webdriver/common/element.rb +3 -1
  34. data/lib/selenium/webdriver/common/error.rb +74 -18
  35. data/lib/selenium/webdriver/common/file_reaper.rb +3 -3
  36. data/lib/selenium/webdriver/common/html5/local_storage.rb +2 -0
  37. data/lib/selenium/webdriver/common/html5/session_storage.rb +2 -0
  38. data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +4 -1
  39. data/lib/selenium/webdriver/common/interactions/input_device.rb +3 -0
  40. data/lib/selenium/webdriver/common/interactions/interaction.rb +3 -0
  41. data/lib/selenium/webdriver/common/interactions/interactions.rb +3 -1
  42. data/lib/selenium/webdriver/common/interactions/key_actions.rb +2 -0
  43. data/lib/selenium/webdriver/common/interactions/key_input.rb +4 -0
  44. data/lib/selenium/webdriver/common/interactions/none_input.rb +3 -0
  45. data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +2 -0
  46. data/lib/selenium/webdriver/common/interactions/pointer_input.rb +7 -0
  47. data/lib/selenium/webdriver/common/keyboard.rb +4 -1
  48. data/lib/selenium/webdriver/common/keys.rb +3 -0
  49. data/lib/selenium/webdriver/common/log_entry.rb +4 -2
  50. data/lib/selenium/webdriver/common/logger.rb +15 -40
  51. data/lib/selenium/webdriver/common/logs.rb +2 -0
  52. data/lib/selenium/webdriver/common/manager.rb +177 -0
  53. data/lib/selenium/webdriver/common/mouse.rb +3 -0
  54. data/lib/selenium/webdriver/common/navigation.rb +2 -0
  55. data/lib/selenium/webdriver/common/options.rb +28 -126
  56. data/lib/selenium/webdriver/common/platform.rb +26 -30
  57. data/lib/selenium/webdriver/common/port_prober.rb +6 -19
  58. data/lib/selenium/webdriver/common/profile_helper.rb +2 -0
  59. data/lib/selenium/webdriver/common/proxy.rb +13 -5
  60. data/lib/selenium/webdriver/common/search_context.rb +6 -8
  61. data/lib/selenium/webdriver/common/service.rb +87 -29
  62. data/lib/selenium/webdriver/common/socket_lock.rb +10 -3
  63. data/lib/selenium/webdriver/common/socket_poller.rb +26 -18
  64. data/lib/selenium/webdriver/common/target_locator.rb +6 -4
  65. data/lib/selenium/webdriver/common/timeouts.rb +2 -0
  66. data/lib/selenium/webdriver/common/touch_action_builder.rb +5 -6
  67. data/lib/selenium/webdriver/common/touch_screen.rb +4 -1
  68. data/lib/selenium/webdriver/common/w3c_action_builder.rb +3 -0
  69. data/lib/selenium/webdriver/common/{w3c_options.rb → w3c_manager.rb} +3 -1
  70. data/lib/selenium/webdriver/common/wait.rb +13 -5
  71. data/lib/selenium/webdriver/common/window.rb +2 -0
  72. data/lib/selenium/webdriver/common/zipper.rb +3 -3
  73. data/lib/selenium/webdriver/common.rb +5 -2
  74. data/lib/selenium/webdriver/edge/bridge.rb +2 -0
  75. data/lib/selenium/webdriver/edge/driver.rb +6 -13
  76. data/lib/selenium/webdriver/edge/options.rb +3 -0
  77. data/lib/selenium/webdriver/edge/service.rb +8 -12
  78. data/lib/selenium/webdriver/edge.rb +11 -5
  79. data/lib/selenium/webdriver/firefox/binary.rb +9 -8
  80. data/lib/selenium/webdriver/firefox/driver.rb +2 -0
  81. data/lib/selenium/webdriver/firefox/extension.rb +4 -4
  82. data/lib/selenium/webdriver/firefox/launcher.rb +3 -0
  83. data/lib/selenium/webdriver/firefox/legacy/driver.rb +7 -3
  84. data/lib/selenium/webdriver/firefox/marionette/bridge.rb +4 -2
  85. data/lib/selenium/webdriver/firefox/marionette/driver.rb +6 -12
  86. data/lib/selenium/webdriver/firefox/options.rb +22 -9
  87. data/lib/selenium/webdriver/firefox/profile.rb +7 -8
  88. data/lib/selenium/webdriver/firefox/profiles_ini.rb +3 -0
  89. data/lib/selenium/webdriver/firefox/service.rb +8 -19
  90. data/lib/selenium/webdriver/firefox/util.rb +2 -0
  91. data/lib/selenium/webdriver/firefox.rb +10 -4
  92. data/lib/selenium/webdriver/ie/driver.rb +5 -11
  93. data/lib/selenium/webdriver/ie/options.rb +6 -4
  94. data/lib/selenium/webdriver/ie/service.rb +8 -12
  95. data/lib/selenium/webdriver/ie.rb +10 -4
  96. data/lib/selenium/webdriver/remote/bridge.rb +8 -6
  97. data/lib/selenium/webdriver/remote/capabilities.rb +23 -10
  98. data/lib/selenium/webdriver/remote/driver.rb +2 -0
  99. data/lib/selenium/webdriver/remote/http/common.rb +11 -4
  100. data/lib/selenium/webdriver/remote/http/curb.rb +4 -2
  101. data/lib/selenium/webdriver/remote/http/default.rb +31 -25
  102. data/lib/selenium/webdriver/remote/http/persistent.rb +3 -1
  103. data/lib/selenium/webdriver/remote/oss/bridge.rb +5 -2
  104. data/lib/selenium/webdriver/remote/oss/commands.rb +106 -104
  105. data/lib/selenium/webdriver/remote/response.rb +11 -3
  106. data/lib/selenium/webdriver/remote/server_error.rb +2 -0
  107. data/lib/selenium/webdriver/remote/w3c/bridge.rb +28 -13
  108. data/lib/selenium/webdriver/remote/w3c/capabilities.rb +37 -21
  109. data/lib/selenium/webdriver/remote/w3c/commands.rb +61 -58
  110. data/lib/selenium/webdriver/remote.rb +2 -0
  111. data/lib/selenium/webdriver/safari/bridge.rb +5 -3
  112. data/lib/selenium/webdriver/safari/driver.rb +9 -11
  113. data/lib/selenium/webdriver/safari/options.rb +2 -0
  114. data/lib/selenium/webdriver/safari/service.rb +6 -25
  115. data/lib/selenium/webdriver/safari.rb +11 -4
  116. data/lib/selenium/webdriver/support/abstract_event_listener.rb +2 -0
  117. data/lib/selenium/webdriver/support/block_event_listener.rb +3 -1
  118. data/lib/selenium/webdriver/support/color.rb +11 -9
  119. data/lib/selenium/webdriver/support/escaper.rb +2 -0
  120. data/lib/selenium/webdriver/support/event_firing_bridge.rb +3 -1
  121. data/lib/selenium/webdriver/support/select.rb +19 -18
  122. data/lib/selenium/webdriver/support.rb +2 -0
  123. data/lib/selenium/webdriver/version.rb +3 -1
  124. data/lib/selenium/webdriver.rb +3 -1
  125. data/lib/selenium-webdriver.rb +2 -0
  126. data/selenium-webdriver.gemspec +15 -8
  127. metadata +86 -27
@@ -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
@@ -28,190 +30,190 @@ module Selenium
28
30
  class Bridge
29
31
 
30
32
  COMMANDS = {
31
- get_capabilities: [:get, 'session/:session_id'.freeze],
32
- status: [:get, 'status'.freeze],
33
+ get_capabilities: [:get, 'session/:session_id'],
34
+ status: [:get, 'status'],
33
35
 
34
36
  #
35
37
  # basic driver
36
38
  #
37
39
 
38
- get_current_url: [:get, 'session/:session_id/url'.freeze],
39
- get: [:post, 'session/:session_id/url'.freeze],
40
- go_forward: [:post, 'session/:session_id/forward'.freeze],
41
- go_back: [:post, 'session/:session_id/back'.freeze],
42
- refresh: [:post, 'session/:session_id/refresh'.freeze],
43
- quit: [:delete, 'session/:session_id'.freeze],
44
- close: [:delete, 'session/:session_id/window'.freeze],
45
- get_page_source: [:get, 'session/:session_id/source'.freeze],
46
- get_title: [:get, 'session/:session_id/title'.freeze],
47
- find_element: [:post, 'session/:session_id/element'.freeze],
48
- find_elements: [:post, 'session/:session_id/elements'.freeze],
49
- get_active_element: [:post, 'session/:session_id/element/active'.freeze],
40
+ get_current_url: [:get, 'session/:session_id/url'],
41
+ get: [:post, 'session/:session_id/url'],
42
+ go_forward: [:post, 'session/:session_id/forward'],
43
+ go_back: [:post, 'session/:session_id/back'],
44
+ refresh: [:post, 'session/:session_id/refresh'],
45
+ quit: [:delete, 'session/:session_id'],
46
+ close: [:delete, 'session/:session_id/window'],
47
+ get_page_source: [:get, 'session/:session_id/source'],
48
+ get_title: [:get, 'session/:session_id/title'],
49
+ find_element: [:post, 'session/:session_id/element'],
50
+ find_elements: [:post, 'session/:session_id/elements'],
51
+ get_active_element: [:post, 'session/:session_id/element/active'],
50
52
 
51
53
  #
52
54
  # window handling
53
55
  #
54
56
 
55
- get_current_window_handle: [:get, 'session/:session_id/window_handle'.freeze],
56
- get_window_handles: [:get, 'session/:session_id/window_handles'.freeze],
57
- set_window_size: [:post, 'session/:session_id/window/:window_handle/size'.freeze],
58
- set_window_position: [:post, 'session/:session_id/window/:window_handle/position'.freeze],
59
- get_window_size: [:get, 'session/:session_id/window/:window_handle/size'.freeze],
60
- get_window_position: [:get, 'session/:session_id/window/:window_handle/position'.freeze],
61
- maximize_window: [:post, 'session/:session_id/window/:window_handle/maximize'.freeze],
57
+ get_current_window_handle: [:get, 'session/:session_id/window_handle'],
58
+ get_window_handles: [:get, 'session/:session_id/window_handles'],
59
+ set_window_size: [:post, 'session/:session_id/window/:window_handle/size'],
60
+ set_window_position: [:post, 'session/:session_id/window/:window_handle/position'],
61
+ get_window_size: [:get, 'session/:session_id/window/:window_handle/size'],
62
+ get_window_position: [:get, 'session/:session_id/window/:window_handle/position'],
63
+ maximize_window: [:post, 'session/:session_id/window/:window_handle/maximize'],
62
64
 
63
65
  #
64
66
  # script execution
65
67
  #
66
68
 
67
- execute_script: [:post, 'session/:session_id/execute'.freeze],
68
- execute_async_script: [:post, 'session/:session_id/execute_async'.freeze],
69
+ execute_script: [:post, 'session/:session_id/execute'],
70
+ execute_async_script: [:post, 'session/:session_id/execute_async'],
69
71
 
70
72
  #
71
73
  # screenshot
72
74
  #
73
75
 
74
- screenshot: [:get, 'session/:session_id/screenshot'.freeze],
76
+ screenshot: [:get, 'session/:session_id/screenshot'],
75
77
 
76
78
  #
77
79
  # alerts
78
80
  #
79
81
 
80
- dismiss_alert: [:post, 'session/:session_id/dismiss_alert'.freeze],
81
- accept_alert: [:post, 'session/:session_id/accept_alert'.freeze],
82
- get_alert_text: [:get, 'session/:session_id/alert_text'.freeze],
83
- set_alert_value: [:post, 'session/:session_id/alert_text'.freeze],
84
- set_authentication: [:post, 'session/:session_id/alert/credentials'.freeze],
82
+ dismiss_alert: [:post, 'session/:session_id/dismiss_alert'],
83
+ accept_alert: [:post, 'session/:session_id/accept_alert'],
84
+ get_alert_text: [:get, 'session/:session_id/alert_text'],
85
+ set_alert_value: [:post, 'session/:session_id/alert_text'],
86
+ set_authentication: [:post, 'session/:session_id/alert/credentials'],
85
87
 
86
88
  #
87
89
  # target locator
88
90
  #
89
91
 
90
- switch_to_frame: [:post, 'session/:session_id/frame'.freeze],
91
- switch_to_parent_frame: [:post, 'session/:session_id/frame/parent'.freeze],
92
- switch_to_window: [:post, 'session/:session_id/window'.freeze],
92
+ switch_to_frame: [:post, 'session/:session_id/frame'],
93
+ switch_to_parent_frame: [:post, 'session/:session_id/frame/parent'],
94
+ switch_to_window: [:post, 'session/:session_id/window'],
93
95
 
94
96
  #
95
97
  # options
96
98
  #
97
99
 
98
- get_cookies: [:get, 'session/:session_id/cookie'.freeze],
99
- add_cookie: [:post, 'session/:session_id/cookie'.freeze],
100
- delete_all_cookies: [:delete, 'session/:session_id/cookie'.freeze],
101
- delete_cookie: [:delete, 'session/:session_id/cookie/:name'.freeze],
100
+ get_cookies: [:get, 'session/:session_id/cookie'],
101
+ add_cookie: [:post, 'session/:session_id/cookie'],
102
+ delete_all_cookies: [:delete, 'session/:session_id/cookie'],
103
+ delete_cookie: [:delete, 'session/:session_id/cookie/:name'],
102
104
 
103
105
  #
104
106
  # timeouts
105
107
  #
106
108
 
107
- implicitly_wait: [:post, 'session/:session_id/timeouts/implicit_wait'.freeze],
108
- set_script_timeout: [:post, 'session/:session_id/timeouts/async_script'.freeze],
109
- set_timeout: [:post, 'session/:session_id/timeouts'.freeze],
109
+ implicitly_wait: [:post, 'session/:session_id/timeouts/implicit_wait'],
110
+ set_script_timeout: [:post, 'session/:session_id/timeouts/async_script'],
111
+ set_timeout: [:post, 'session/:session_id/timeouts'],
110
112
 
111
113
  #
112
114
  # element
113
115
  #
114
116
 
115
- describe_element: [:get, 'session/:session_id/element/:id'.freeze],
116
- find_child_element: [:post, 'session/:session_id/element/:id/element'.freeze],
117
- find_child_elements: [:post, 'session/:session_id/element/:id/elements'.freeze],
118
- click_element: [:post, 'session/:session_id/element/:id/click'.freeze],
119
- submit_element: [:post, 'session/:session_id/element/:id/submit'.freeze],
120
- get_element_value: [:get, 'session/:session_id/element/:id/value'.freeze],
121
- send_keys_to_element: [:post, 'session/:session_id/element/:id/value'.freeze],
122
- upload_file: [:post, 'session/:session_id/file'.freeze],
123
- get_element_tag_name: [:get, 'session/:session_id/element/:id/name'.freeze],
124
- clear_element: [:post, 'session/:session_id/element/:id/clear'.freeze],
125
- is_element_selected: [:get, 'session/:session_id/element/:id/selected'.freeze],
126
- is_element_enabled: [:get, 'session/:session_id/element/:id/enabled'.freeze],
127
- get_element_attribute: [:get, 'session/:session_id/element/:id/attribute/:name'.freeze],
128
- element_equals: [:get, 'session/:session_id/element/:id/equals/:other'.freeze],
129
- is_element_displayed: [:get, 'session/:session_id/element/:id/displayed'.freeze],
130
- get_element_location: [:get, 'session/:session_id/element/:id/location'.freeze],
131
- get_element_location_once_scrolled_into_view: [:get, 'session/:session_id/element/:id/location_in_view'.freeze],
132
- get_element_size: [:get, 'session/:session_id/element/:id/size'.freeze],
133
- drag_element: [:post, 'session/:session_id/element/:id/drag'.freeze],
134
- get_element_value_of_css_property: [:get, 'session/:session_id/element/:id/css/:property_name'.freeze],
135
- get_element_text: [:get, 'session/:session_id/element/:id/text'.freeze],
117
+ describe_element: [:get, 'session/:session_id/element/:id'],
118
+ find_child_element: [:post, 'session/:session_id/element/:id/element'],
119
+ find_child_elements: [:post, 'session/:session_id/element/:id/elements'],
120
+ click_element: [:post, 'session/:session_id/element/:id/click'],
121
+ submit_element: [:post, 'session/:session_id/element/:id/submit'],
122
+ get_element_value: [:get, 'session/:session_id/element/:id/value'],
123
+ send_keys_to_element: [:post, 'session/:session_id/element/:id/value'],
124
+ upload_file: [:post, 'session/:session_id/file'],
125
+ get_element_tag_name: [:get, 'session/:session_id/element/:id/name'],
126
+ clear_element: [:post, 'session/:session_id/element/:id/clear'],
127
+ is_element_selected: [:get, 'session/:session_id/element/:id/selected'],
128
+ is_element_enabled: [:get, 'session/:session_id/element/:id/enabled'],
129
+ get_element_attribute: [:get, 'session/:session_id/element/:id/attribute/:name'],
130
+ element_equals: [:get, 'session/:session_id/element/:id/equals/:other'],
131
+ is_element_displayed: [:get, 'session/:session_id/element/:id/displayed'],
132
+ get_element_location: [:get, 'session/:session_id/element/:id/location'],
133
+ get_element_location_once_scrolled_into_view: [:get, 'session/:session_id/element/:id/location_in_view'],
134
+ get_element_size: [:get, 'session/:session_id/element/:id/size'],
135
+ drag_element: [:post, 'session/:session_id/element/:id/drag'],
136
+ get_element_value_of_css_property: [:get, 'session/:session_id/element/:id/css/:property_name'],
137
+ get_element_text: [:get, 'session/:session_id/element/:id/text'],
136
138
 
137
139
  #
138
140
  # rotatable
139
141
  #
140
142
 
141
- get_screen_orientation: [:get, 'session/:session_id/orientation'.freeze],
142
- set_screen_orientation: [:post, 'session/:session_id/orientation'.freeze],
143
+ get_screen_orientation: [:get, 'session/:session_id/orientation'],
144
+ set_screen_orientation: [:post, 'session/:session_id/orientation'],
143
145
 
144
146
  #
145
147
  # interactions API
146
148
  #
147
149
 
148
- click: [:post, 'session/:session_id/click'.freeze],
149
- double_click: [:post, 'session/:session_id/doubleclick'.freeze],
150
- mouse_down: [:post, 'session/:session_id/buttondown'.freeze],
151
- mouse_up: [:post, 'session/:session_id/buttonup'.freeze],
152
- mouse_move_to: [:post, 'session/:session_id/moveto'.freeze],
153
- send_modifier_key_to_active_element: [:post, 'session/:session_id/modifier'.freeze],
154
- send_keys_to_active_element: [:post, 'session/:session_id/keys'.freeze],
150
+ click: [:post, 'session/:session_id/click'],
151
+ double_click: [:post, 'session/:session_id/doubleclick'],
152
+ mouse_down: [:post, 'session/:session_id/buttondown'],
153
+ mouse_up: [:post, 'session/:session_id/buttonup'],
154
+ mouse_move_to: [:post, 'session/:session_id/moveto'],
155
+ send_modifier_key_to_active_element: [:post, 'session/:session_id/modifier'],
156
+ send_keys_to_active_element: [:post, 'session/:session_id/keys'],
155
157
 
156
158
  #
157
159
  # html 5
158
160
  #
159
161
 
160
- execute_sql: [:post, 'session/:session_id/execute_sql'.freeze],
162
+ execute_sql: [:post, 'session/:session_id/execute_sql'],
161
163
 
162
- get_location: [:get, 'session/:session_id/location'.freeze],
163
- set_location: [:post, 'session/:session_id/location'.freeze],
164
+ get_location: [:get, 'session/:session_id/location'],
165
+ set_location: [:post, 'session/:session_id/location'],
164
166
 
165
- get_app_cache: [:get, 'session/:session_id/application_cache'.freeze],
166
- get_app_cache_status: [:get, 'session/:session_id/application_cache/status'.freeze],
167
- clear_app_cache: [:delete, 'session/:session_id/application_cache/clear'.freeze],
167
+ get_app_cache: [:get, 'session/:session_id/application_cache'],
168
+ get_app_cache_status: [:get, 'session/:session_id/application_cache/status'],
169
+ clear_app_cache: [:delete, 'session/:session_id/application_cache/clear'],
168
170
 
169
- get_network_connection: [:get, 'session/:session_id/network_connection'.freeze],
170
- set_network_connection: [:post, 'session/:session_id/network_connection'.freeze],
171
+ get_network_connection: [:get, 'session/:session_id/network_connection'],
172
+ set_network_connection: [:post, 'session/:session_id/network_connection'],
171
173
 
172
- get_local_storage_item: [:get, 'session/:session_id/local_storage/key/:key'.freeze],
173
- remove_local_storage_item: [:delete, 'session/:session_id/local_storage/key/:key'.freeze],
174
- get_local_storage_keys: [:get, 'session/:session_id/local_storage'.freeze],
175
- set_local_storage_item: [:post, 'session/:session_id/local_storage'.freeze],
176
- clear_local_storage: [:delete, 'session/:session_id/local_storage'.freeze],
177
- get_local_storage_size: [:get, 'session/:session_id/local_storage/size'.freeze],
174
+ get_local_storage_item: [:get, 'session/:session_id/local_storage/key/:key'],
175
+ remove_local_storage_item: [:delete, 'session/:session_id/local_storage/key/:key'],
176
+ get_local_storage_keys: [:get, 'session/:session_id/local_storage'],
177
+ set_local_storage_item: [:post, 'session/:session_id/local_storage'],
178
+ clear_local_storage: [:delete, 'session/:session_id/local_storage'],
179
+ get_local_storage_size: [:get, 'session/:session_id/local_storage/size'],
178
180
 
179
- get_session_storage_item: [:get, 'session/:session_id/session_storage/key/:key'.freeze],
180
- remove_session_storage_item: [:delete, 'session/:session_id/session_storage/key/:key'.freeze],
181
- get_session_storage_keys: [:get, 'session/:session_id/session_storage'.freeze],
182
- set_session_storage_item: [:post, 'session/:session_id/session_storage'.freeze],
183
- clear_session_storage: [:delete, 'session/:session_id/session_storage'.freeze],
184
- get_session_storage_size: [:get, 'session/:session_id/session_storage/size'.freeze],
181
+ get_session_storage_item: [:get, 'session/:session_id/session_storage/key/:key'],
182
+ remove_session_storage_item: [:delete, 'session/:session_id/session_storage/key/:key'],
183
+ get_session_storage_keys: [:get, 'session/:session_id/session_storage'],
184
+ set_session_storage_item: [:post, 'session/:session_id/session_storage'],
185
+ clear_session_storage: [:delete, 'session/:session_id/session_storage'],
186
+ get_session_storage_size: [:get, 'session/:session_id/session_storage/size'],
185
187
 
186
188
  #
187
189
  # ime
188
190
  #
189
191
 
190
- ime_get_available_engines: [:get, 'session/:session_id/ime/available_engines'.freeze],
191
- ime_get_active_engine: [:get, 'session/:session_id/ime/active_engine'.freeze],
192
- ime_is_activated: [:get, 'session/:session_id/ime/activated'.freeze],
193
- ime_deactivate: [:post, 'session/:session_id/ime/deactivate'.freeze],
194
- ime_activate_engine: [:post, 'session/:session_id/ime/activate'.freeze],
192
+ ime_get_available_engines: [:get, 'session/:session_id/ime/available_engines'],
193
+ ime_get_active_engine: [:get, 'session/:session_id/ime/active_engine'],
194
+ ime_is_activated: [:get, 'session/:session_id/ime/activated'],
195
+ ime_deactivate: [:post, 'session/:session_id/ime/deactivate'],
196
+ ime_activate_engine: [:post, 'session/:session_id/ime/activate'],
195
197
 
196
198
  #
197
199
  # touch
198
200
  #
199
201
 
200
- touch_single_tap: [:post, 'session/:session_id/touch/click'.freeze],
201
- touch_double_tap: [:post, 'session/:session_id/touch/doubleclick'.freeze],
202
- touch_long_press: [:post, 'session/:session_id/touch/longclick'.freeze],
203
- touch_down: [:post, 'session/:session_id/touch/down'.freeze],
204
- touch_up: [:post, 'session/:session_id/touch/up'.freeze],
205
- touch_move: [:post, 'session/:session_id/touch/move'.freeze],
206
- touch_scroll: [:post, 'session/:session_id/touch/scroll'.freeze],
207
- touch_flick: [:post, 'session/:session_id/touch/flick'.freeze],
202
+ touch_single_tap: [:post, 'session/:session_id/touch/click'],
203
+ touch_double_tap: [:post, 'session/:session_id/touch/doubleclick'],
204
+ touch_long_press: [:post, 'session/:session_id/touch/longclick'],
205
+ touch_down: [:post, 'session/:session_id/touch/down'],
206
+ touch_up: [:post, 'session/:session_id/touch/up'],
207
+ touch_move: [:post, 'session/:session_id/touch/move'],
208
+ touch_scroll: [:post, 'session/:session_id/touch/scroll'],
209
+ touch_flick: [:post, 'session/:session_id/touch/flick'],
208
210
 
209
211
  #
210
212
  # logs
211
213
  #
212
214
 
213
- get_available_log_types: [:get, 'session/:session_id/log/types'.freeze],
214
- get_log: [:post, 'session/:session_id/log'.freeze]
215
+ get_available_log_types: [:get, 'session/:session_id/log/types'],
216
+ get_log: [:post, 'session/:session_id/log']
215
217
  }.freeze
216
218
 
217
219
  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
@@ -20,7 +22,7 @@ module Selenium
20
22
  module Remote
21
23
  # @api private
22
24
  class Response
23
- STACKTRACE_KEY = 'stackTrace'.freeze
25
+ STACKTRACE_KEY = 'stackTrace'
24
26
 
25
27
  attr_reader :code, :payload
26
28
  attr_writer :payload
@@ -49,6 +51,7 @@ module Selenium
49
51
  when Hash
50
52
  msg = val['message']
51
53
  return 'unknown error' unless msg
54
+
52
55
  msg << ": #{val['alert']['text'].inspect}" if val['alert'].is_a?(Hash) && val['alert']['text']
53
56
  msg << " (#{val['class']})" if val['class']
54
57
  msg
@@ -69,12 +72,15 @@ module Selenium
69
72
  e = error
70
73
  raise e if e
71
74
  return unless @code.nil? || @code >= 400
75
+
72
76
  raise Error::ServerError, self
73
77
  end
74
78
 
75
79
  def add_backtrace(ex)
76
80
  return unless error_payload.is_a?(Hash)
77
81
 
82
+ # Legacy Firefox returns String in ['value'], while we expect Hash.
83
+ # Use #dig when Firefox legacy is removed (4.0).
78
84
  server_trace = error_payload[STACKTRACE_KEY] ||
79
85
  error_payload[STACKTRACE_KEY.downcase] ||
80
86
  (error_payload['value'] && error_payload['value'][STACKTRACE_KEY])
@@ -91,7 +97,7 @@ module Selenium
91
97
  end
92
98
 
93
99
  def backtrace_from_remote(server_trace)
94
- server_trace.map do |frame|
100
+ server_trace.map { |frame|
95
101
  next unless frame.is_a?(Hash)
96
102
 
97
103
  file = frame['fileName']
@@ -104,7 +110,7 @@ module Selenium
104
110
  meth = 'unknown' if meth.nil? || meth.empty?
105
111
 
106
112
  "[remote server] #{file}:#{line}:in `#{meth}'"
107
- end.compact
113
+ }.compact
108
114
  end
109
115
 
110
116
  def error_payload
@@ -115,11 +121,13 @@ module Selenium
115
121
 
116
122
  def status
117
123
  return unless error_payload.is_a? Hash
124
+
118
125
  @status ||= error_payload['status'] || error_payload['error']
119
126
  end
120
127
 
121
128
  def value
122
129
  return unless error_payload.is_a? Hash
130
+
123
131
  @value ||= error_payload['value'] || error_payload['message']
124
132
  end
125
133
  end # Response
@@ -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
@@ -116,6 +118,20 @@ module Selenium
116
118
  'return source;')
117
119
  end
118
120
 
121
+ #
122
+ # Create a new top-level browsing context
123
+ # https://w3c.github.io/webdriver/#new-window
124
+ # @param type [String] Supports two values: 'tab' and 'window'.
125
+ # Use 'tab' if you'd like the new window to share an OS-level window
126
+ # with the current browsing context.
127
+ # Use 'window' otherwise
128
+ # @return [Hash] Containing 'handle' with the value of the window handle
129
+ # and 'type' with the value of the created window type
130
+ #
131
+ def new_window(type)
132
+ execute :new_window, {}, {type: type}
133
+ end
134
+
119
135
  def switch_to_window(name)
120
136
  execute :switch_to_window, {}, {handle: name}
121
137
  end
@@ -162,16 +178,14 @@ module Selenium
162
178
  end
163
179
 
164
180
  def resize_window(width, height, handle = :current)
165
- unless handle == :current
166
- raise Error::WebDriverError, 'Switch to desired window before changing its size'
167
- end
181
+ raise Error::WebDriverError, 'Switch to desired window before changing its size' unless handle == :current
182
+
168
183
  set_window_rect(width: width, height: height)
169
184
  end
170
185
 
171
186
  def window_size(handle = :current)
172
- unless handle == :current
173
- raise Error::UnsupportedOperationError, 'Switch to desired window before getting its size'
174
- end
187
+ raise Error::UnsupportedOperationError, 'Switch to desired window before getting its size' unless handle == :current
188
+
175
189
  data = execute :get_window_rect
176
190
 
177
191
  Dimension.new data['width'], data['height']
@@ -182,9 +196,8 @@ module Selenium
182
196
  end
183
197
 
184
198
  def maximize_window(handle = :current)
185
- unless handle == :current
186
- raise Error::UnsupportedOperationError, 'Switch to desired window before changing its size'
187
- end
199
+ raise Error::UnsupportedOperationError, 'Switch to desired window before changing its size' unless handle == :current
200
+
188
201
  execute :maximize_window
189
202
  end
190
203
 
@@ -203,7 +216,7 @@ module Selenium
203
216
 
204
217
  def set_window_rect(x: nil, y: nil, width: nil, height: nil)
205
218
  params = {x: x, y: y, width: width, height: height}
206
- params.update(params) { |k, v| Integer(v) unless v.nil? }
219
+ params.update(params) { |_k, v| Integer(v) unless v.nil? }
207
220
  execute :set_window_rect, {}, params
208
221
  end
209
222
 
@@ -302,8 +315,8 @@ module Selenium
302
315
  # cookies
303
316
  #
304
317
 
305
- def options
306
- @options ||= WebDriver::W3COptions.new(self)
318
+ def manage
319
+ @manage ||= WebDriver::W3CManager.new(self)
307
320
  end
308
321
 
309
322
  def add_cookie(cookie)
@@ -459,6 +472,7 @@ module Selenium
459
472
  end
460
473
 
461
474
  def element_attribute(element, name)
475
+ WebDriver.logger.info "Using script for :getAttribute of #{name}"
462
476
  execute_atom :getAttribute, element, name
463
477
  end
464
478
 
@@ -506,6 +520,7 @@ module Selenium
506
520
  end
507
521
 
508
522
  def element_displayed?(element)
523
+ WebDriver.logger.info 'Using script for :isDisplayed'
509
524
  execute_atom :isDisplayed, element
510
525
  end
511
526
 
@@ -569,7 +584,7 @@ module Selenium
569
584
  [how, what]
570
585
  end
571
586
 
572
- ESCAPE_CSS_REGEXP = /(['"\\#.:;,!?+<>=~*^$|%&@`{}\-\[\]\(\)])/
587
+ ESCAPE_CSS_REGEXP = /(['"\\#.:;,!?+<>=~*^$|%&@`{}\-\[\]\(\)])/.freeze
573
588
  UNICODE_CODE_POINT = 30
574
589
 
575
590
  # Escapes invalid characters in CSS selector.
@@ -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