selenium-webdriver 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. data/CHANGES +17 -0
  2. data/lib/selenium/webdriver/chrome.rb +13 -13
  3. data/lib/selenium/webdriver/chrome/bridge.rb +4 -3
  4. data/lib/selenium/webdriver/chrome/service.rb +6 -4
  5. data/lib/selenium/webdriver/common.rb +1 -0
  6. data/lib/selenium/webdriver/common/driver.rb +1 -1
  7. data/lib/selenium/webdriver/common/element.rb +14 -0
  8. data/lib/selenium/webdriver/common/options.rb +12 -10
  9. data/lib/selenium/webdriver/common/port_prober.rb +2 -1
  10. data/lib/selenium/webdriver/common/service.rb +23 -8
  11. data/lib/selenium/webdriver/common/w3c_options.rb +45 -0
  12. data/lib/selenium/webdriver/edge.rb +13 -13
  13. data/lib/selenium/webdriver/edge/bridge.rb +98 -1
  14. data/lib/selenium/webdriver/edge/service.rb +6 -4
  15. data/lib/selenium/webdriver/firefox.rb +13 -13
  16. data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
  17. data/lib/selenium/webdriver/firefox/service.rb +10 -4
  18. data/lib/selenium/webdriver/firefox/w3c_bridge.rb +2 -1
  19. data/lib/selenium/webdriver/ie.rb +13 -13
  20. data/lib/selenium/webdriver/ie/bridge.rb +3 -1
  21. data/lib/selenium/webdriver/ie/service.rb +6 -4
  22. data/lib/selenium/webdriver/phantomjs.rb +13 -9
  23. data/lib/selenium/webdriver/phantomjs/bridge.rb +2 -1
  24. data/lib/selenium/webdriver/phantomjs/service.rb +2 -4
  25. data/lib/selenium/webdriver/remote/bridge.rb +102 -108
  26. data/lib/selenium/webdriver/remote/commands.rb +188 -185
  27. data/lib/selenium/webdriver/remote/w3c_bridge.rb +75 -94
  28. data/lib/selenium/webdriver/remote/w3c_capabilities.rb +3 -3
  29. data/lib/selenium/webdriver/remote/w3c_commands.rb +108 -104
  30. data/lib/selenium/webdriver/safari.rb +14 -13
  31. data/lib/selenium/webdriver/safari/bridge.rb +2 -1
  32. data/lib/selenium/webdriver/safari/service.rb +16 -4
  33. data/selenium-webdriver.gemspec +1 -1
  34. metadata +3 -4
  35. data/Gemfile.lock +0 -53
  36. data/lib/selenium/webdriver/edge/legacy_support.rb +0 -117
@@ -25,191 +25,194 @@ module Selenium
25
25
  # https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#command-reference
26
26
  #
27
27
 
28
- command :newSession, :post, 'session'
29
- command :getCapabilities, :get, 'session/:session_id'
30
- command :status, :get, 'status'
31
-
32
- #
33
- # basic driver
34
- #
35
-
36
- command :getCurrentUrl, :get, 'session/:session_id/url'
37
- command :get, :post, 'session/:session_id/url'
38
- command :goForward, :post, 'session/:session_id/forward'
39
- command :goBack, :post, 'session/:session_id/back'
40
- command :refresh, :post, 'session/:session_id/refresh'
41
- command :quit, :delete, 'session/:session_id'
42
- command :close, :delete, 'session/:session_id/window'
43
- command :getPageSource, :get, 'session/:session_id/source'
44
- command :getTitle, :get, 'session/:session_id/title'
45
- command :findElement, :post, 'session/:session_id/element'
46
- command :findElements, :post, 'session/:session_id/elements'
47
- command :getActiveElement, :post, 'session/:session_id/element/active'
48
-
49
- #
50
- # window handling
51
- #
52
-
53
- command :getCurrentWindowHandle, :get, 'session/:session_id/window_handle'
54
- command :getWindowHandles, :get, 'session/:session_id/window_handles'
55
- command :setWindowSize, :post, 'session/:session_id/window/:window_handle/size'
56
- command :setWindowPosition, :post, 'session/:session_id/window/:window_handle/position'
57
- command :getWindowSize, :get, 'session/:session_id/window/:window_handle/size'
58
- command :getWindowPosition, :get, 'session/:session_id/window/:window_handle/position'
59
- command :maximizeWindow, :post, 'session/:session_id/window/:window_handle/maximize'
60
-
61
- #
62
- # script execution
63
- #
64
-
65
- command :executeScript, :post, 'session/:session_id/execute'
66
- command :executeAsyncScript, :post, 'session/:session_id/execute_async'
67
-
68
- #
69
- # screenshot
70
- #
71
-
72
- command :screenshot, :get, 'session/:session_id/screenshot'
73
-
74
- #
75
- # alerts
76
- #
77
-
78
- command :dismissAlert, :post, 'session/:session_id/dismiss_alert'
79
- command :acceptAlert, :post, 'session/:session_id/accept_alert'
80
- command :getAlertText, :get, 'session/:session_id/alert_text'
81
- command :setAlertValue, :post, 'session/:session_id/alert_text'
82
- command :setAuthentication, :post, 'session/:session_id/alert/credentials'
83
-
84
- #
85
- # target locator
86
- #
87
-
88
- command :switchToFrame, :post, 'session/:session_id/frame'
89
- command :switchToParentFrame, :post, 'session/:session_id/frame/parent'
90
- command :switchToWindow, :post, 'session/:session_id/window'
91
-
92
- #
93
- # options
94
- #
95
-
96
- command :getCookies, :get, 'session/:session_id/cookie'
97
- command :addCookie, :post, 'session/:session_id/cookie'
98
- command :deleteAllCookies, :delete, 'session/:session_id/cookie'
99
- command :deleteCookie, :delete, 'session/:session_id/cookie/:name'
100
-
101
- #
102
- # timeouts
103
- #
104
-
105
- command :implicitlyWait, :post, 'session/:session_id/timeouts/implicit_wait'
106
- command :setScriptTimeout, :post, 'session/:session_id/timeouts/async_script'
107
- command :setTimeout, :post, 'session/:session_id/timeouts'
108
-
109
- #
110
- # element
111
- #
112
-
113
- command :describeElement, :get, 'session/:session_id/element/:id'
114
- command :findChildElement, :post, 'session/:session_id/element/:id/element'
115
- command :findChildElements, :post, 'session/:session_id/element/:id/elements'
116
- command :clickElement, :post, 'session/:session_id/element/:id/click'
117
- command :submitElement, :post, 'session/:session_id/element/:id/submit'
118
- command :getElementValue, :get, 'session/:session_id/element/:id/value'
119
- command :sendKeysToElement, :post, 'session/:session_id/element/:id/value'
120
- command :uploadFile, :post, 'session/:session_id/file'
121
- command :getElementTagName, :get, 'session/:session_id/element/:id/name'
122
- command :clearElement, :post, 'session/:session_id/element/:id/clear'
123
- command :isElementSelected, :get, 'session/:session_id/element/:id/selected'
124
- command :isElementEnabled, :get, 'session/:session_id/element/:id/enabled'
125
- command :getElementAttribute, :get, 'session/:session_id/element/:id/attribute/:name'
126
- command :elementEquals, :get, 'session/:session_id/element/:id/equals/:other'
127
- command :isElementDisplayed, :get, 'session/:session_id/element/:id/displayed'
128
- command :getElementLocation, :get, 'session/:session_id/element/:id/location'
129
- command :getElementLocationOnceScrolledIntoView, :get, 'session/:session_id/element/:id/location_in_view'
130
- command :getElementSize, :get, 'session/:session_id/element/:id/size'
131
- command :dragElement, :post, 'session/:session_id/element/:id/drag'
132
- command :getElementValueOfCssProperty, :get, 'session/:session_id/element/:id/css/:property_name'
133
- command :getElementText, :get, 'session/:session_id/element/:id/text'
134
-
135
- #
136
- # rotatable
137
- #
138
-
139
- command :getScreenOrientation, :get, 'session/:session_id/orientation'
140
- command :setScreenOrientation, :post, 'session/:session_id/orientation'
141
-
142
- #
143
- # interactions API
144
- #
145
-
146
- command :click, :post, 'session/:session_id/click'
147
- command :doubleClick, :post, 'session/:session_id/doubleclick'
148
- command :mouseDown, :post, 'session/:session_id/buttondown'
149
- command :mouseUp, :post, 'session/:session_id/buttonup'
150
- command :mouseMoveTo, :post, 'session/:session_id/moveto'
151
- command :sendModifierKeyToActiveElement, :post, 'session/:session_id/modifier'
152
- command :sendKeysToActiveElement, :post, 'session/:session_id/keys'
153
-
154
- #
155
- # html 5
156
- #
157
-
158
- command :executeSql, :post, 'session/:session_id/execute_sql'
159
-
160
- command :getLocation, :get, 'session/:session_id/location'
161
- command :setLocation, :post, 'session/:session_id/location'
162
-
163
- command :getAppCache, :get, 'session/:session_id/application_cache'
164
- command :getAppCacheStatus, :get, 'session/:session_id/application_cache/status'
165
- command :clearAppCache, :delete, 'session/:session_id/application_cache/clear'
166
-
167
- command :getNetworkConnection, :get, 'session/:session_id/network_connection'
168
- command :setNetworkConnection, :post, 'session/:session_id/network_connection'
169
-
170
- command :getLocalStorageItem, :get, 'session/:session_id/local_storage/key/:key'
171
- command :removeLocalStorageItem, :delete, 'session/:session_id/local_storage/key/:key'
172
- command :getLocalStorageKeys, :get, 'session/:session_id/local_storage'
173
- command :setLocalStorageItem, :post, 'session/:session_id/local_storage'
174
- command :clearLocalStorage, :delete, 'session/:session_id/local_storage'
175
- command :getLocalStorageSize, :get, 'session/:session_id/local_storage/size'
176
-
177
- command :getSessionStorageItem, :get, 'session/:session_id/session_storage/key/:key'
178
- command :removeSessionStorageItem, :delete, 'session/:session_id/session_storage/key/:key'
179
- command :getSessionStorageKeys, :get, 'session/:session_id/session_storage'
180
- command :setSessionStorageItem, :post, 'session/:session_id/session_storage'
181
- command :clearSessionStorage, :delete, 'session/:session_id/session_storage'
182
- command :getSessionStorageSize, :get, 'session/:session_id/session_storage/size'
183
-
184
- #
185
- # ime
186
- #
187
-
188
- command :imeGetAvailableEngines, :get, 'session/:session_id/ime/available_engines'
189
- command :imeGetActiveEngine, :get, 'session/:session_id/ime/active_engine'
190
- command :imeIsActivated, :get, 'session/:session_id/ime/activated'
191
- command :imeDeactivate, :post, 'session/:session_id/ime/deactivate'
192
- command :imeActivateEngine, :post, 'session/:session_id/ime/activate'
193
-
194
- #
195
- # touch
196
- #
197
-
198
- command :touchSingleTap, :post, 'session/:session_id/touch/click'
199
- command :touchDoubleTap, :post, 'session/:session_id/touch/doubleclick'
200
- command :touchLongPress, :post, 'session/:session_id/touch/longclick'
201
- command :touchDown, :post, 'session/:session_id/touch/down'
202
- command :touchUp, :post, 'session/:session_id/touch/up'
203
- command :touchMove, :post, 'session/:session_id/touch/move'
204
- command :touchScroll, :post, 'session/:session_id/touch/scroll'
205
- command :touchFlick, :post, 'session/:session_id/touch/flick'
206
-
207
- #
208
- # logs
209
- #
210
-
211
- command :getAvailableLogTypes, :get, 'session/:session_id/log/types'
212
- command :getLog, :post, 'session/:session_id/log'
28
+ COMMANDS = {
29
+
30
+ new_session: [:post, 'session'.freeze],
31
+ get_capabilities: [:get, 'session/:session_id'.freeze],
32
+ status: [:get, 'status'.freeze],
33
+
34
+ #
35
+ # basic driver
36
+ #
37
+
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],
50
+
51
+ #
52
+ # window handling
53
+ #
54
+
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],
62
+
63
+ #
64
+ # script execution
65
+ #
66
+
67
+ execute_script: [:post, 'session/:session_id/execute'.freeze],
68
+ execute_async_script: [:post, 'session/:session_id/execute_async'.freeze],
69
+
70
+ #
71
+ # screenshot
72
+ #
73
+
74
+ screenshot: [:get, 'session/:session_id/screenshot'.freeze],
75
+
76
+ #
77
+ # alerts
78
+ #
79
+
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],
85
+
86
+ #
87
+ # target locator
88
+ #
89
+
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],
93
+
94
+ #
95
+ # options
96
+ #
97
+
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],
102
+
103
+ #
104
+ # timeouts
105
+ #
106
+
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],
110
+
111
+ #
112
+ # element
113
+ #
114
+
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],
136
+
137
+ #
138
+ # rotatable
139
+ #
140
+
141
+ get_screen_orientation: [:get, 'session/:session_id/orientation'.freeze],
142
+ set_screen_orientation: [:post, 'session/:session_id/orientation'.freeze],
143
+
144
+ #
145
+ # interactions API
146
+ #
147
+
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],
155
+
156
+ #
157
+ # html 5
158
+ #
159
+
160
+ execute_sql: [:post, 'session/:session_id/execute_sql'.freeze],
161
+
162
+ get_location: [:get, 'session/:session_id/location'.freeze],
163
+ set_location: [:post, 'session/:session_id/location'.freeze],
164
+
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],
168
+
169
+ get_network_connection: [:get, 'session/:session_id/network_connection'.freeze],
170
+ set_network_connection: [:post, 'session/:session_id/network_connection'.freeze],
171
+
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],
178
+
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],
185
+
186
+ #
187
+ # ime
188
+ #
189
+
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],
195
+
196
+ #
197
+ # touch
198
+ #
199
+
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],
208
+
209
+ #
210
+ # logs
211
+ #
212
+
213
+ get_available_log_types: [:get, 'session/:session_id/log/types'.freeze],
214
+ get_log: [:post, 'session/:session_id/log'.freeze]
215
+ }.freeze
213
216
  end
214
217
  end # Remote
215
218
  end # WebDriver
@@ -32,25 +32,6 @@ module Selenium
32
32
  include BridgeHelper
33
33
  include Atoms
34
34
 
35
- # TODO: constant shouldn't be modified in class
36
- COMMANDS = {}
37
-
38
- #
39
- # Defines a wrapper method for a command, which ultimately calls #execute.
40
- #
41
- # @param name [Symbol]
42
- # name of the resulting method
43
- # @param verb [Symbol]
44
- # the appropriate http verb, such as :get, :post, or :delete
45
- # @param url [String]
46
- # a URL template, which can include some arguments, much like the definitions on the server.
47
- # the :session_id parameter is implicitly handled, but the remainder will become required method arguments.
48
- #
49
-
50
- def self.command(name, verb, url)
51
- COMMANDS[name] = [verb, url.freeze]
52
- end
53
-
54
35
  attr_accessor :context, :http, :file_detector
55
36
  attr_reader :capabilities
56
37
 
@@ -63,7 +44,6 @@ module Selenium
63
44
  #
64
45
 
65
46
  def initialize(opts = {})
66
- edge_check(opts)
67
47
 
68
48
  opts = opts.dup
69
49
 
@@ -97,13 +77,6 @@ module Selenium
97
77
  )
98
78
  end
99
79
 
100
- def edge_check(opts)
101
- caps = opts[:desired_capabilities]
102
- return unless caps && caps[:browser_name] && caps[:browser_name] == 'MicrosoftEdge'
103
- require_relative '../edge/legacy_support'
104
- extend Edge::LegacySupport
105
- end
106
-
107
80
  def driver_extensions
108
81
  [
109
82
  DriverExtensions::HasInputDevices,
@@ -117,6 +90,15 @@ module Selenium
117
90
  ]
118
91
  end
119
92
 
93
+ def commands(command)
94
+ case command
95
+ when :status, :is_element_displayed
96
+ Bridge::COMMANDS[command]
97
+ else
98
+ COMMANDS[command]
99
+ end
100
+ end
101
+
120
102
  #
121
103
  # Returns the current session ID.
122
104
  #
@@ -129,7 +111,7 @@ module Selenium
129
111
  # TODO - Remove this when Mozilla fixes bug
130
112
  desired_capabilities[:browser_name] = 'firefox' if desired_capabilities[:browser_name] == 'Firefox'
131
113
 
132
- resp = raw_execute :newSession, {}, {desiredCapabilities: desired_capabilities}
114
+ resp = raw_execute :new_session, {}, {desiredCapabilities: desired_capabilities}
133
115
  @session_id = resp['sessionId']
134
116
  return W3CCapabilities.json_create resp['value'] if @session_id
135
117
 
@@ -137,8 +119,6 @@ module Selenium
137
119
  end
138
120
 
139
121
  def status
140
- jwp = Selenium::WebDriver::Remote::Bridge::COMMANDS[:status]
141
- self.class.command(:status, jwp.first, jwp.last)
142
122
  execute :status
143
123
  end
144
124
 
@@ -155,7 +135,7 @@ module Selenium
155
135
  end
156
136
 
157
137
  def timeout(type, milliseconds)
158
- execute :setTimeout, {}, {type: type, ms: milliseconds}
138
+ execute :set_timeout, {}, {type: type, ms: milliseconds}
159
139
  end
160
140
 
161
141
  #
@@ -163,19 +143,19 @@ module Selenium
163
143
  #
164
144
 
165
145
  def accept_alert
166
- execute :acceptAlert
146
+ execute :accept_alert
167
147
  end
168
148
 
169
149
  def dismiss_alert
170
- execute :dismissAlert
150
+ execute :dismiss_alert
171
151
  end
172
152
 
173
153
  def alert=(keys)
174
- execute :sendAlertText, {}, {handler: 'prompt', text: keys}
154
+ execute :send_alert_text, {}, {handler: 'prompt', text: keys}
175
155
  end
176
156
 
177
157
  def alert_text
178
- execute :getAlertText
158
+ execute :get_alert_text
179
159
  end
180
160
 
181
161
  #
@@ -191,11 +171,11 @@ module Selenium
191
171
  end
192
172
 
193
173
  def url
194
- execute :getCurrentUrl
174
+ execute :get_current_url
195
175
  end
196
176
 
197
177
  def title
198
- execute :getTitle
178
+ execute :get_title
199
179
  end
200
180
 
201
181
  def page_source
@@ -205,16 +185,16 @@ module Selenium
205
185
  end
206
186
 
207
187
  def switch_to_window(name)
208
- execute :switchToWindow, {}, {handle: name}
188
+ execute :switch_to_window, {}, {handle: name}
209
189
  end
210
190
 
211
191
  def switch_to_frame(id)
212
192
  id = find_element_by('id', id) if id.is_a? String
213
- execute :switchToFrame, {}, {id: id}
193
+ execute :switch_to_frame, {}, {id: id}
214
194
  end
215
195
 
216
196
  def switch_to_parent_frame
217
- execute :switchToParentFrame
197
+ execute :switch_to_parent_frame
218
198
  end
219
199
 
220
200
  def switch_to_default_content
@@ -224,13 +204,13 @@ module Selenium
224
204
  QUIT_ERRORS = [IOError].freeze
225
205
 
226
206
  def quit
227
- execute :deleteSession
207
+ execute :delete_session
228
208
  http.close
229
209
  rescue *QUIT_ERRORS
230
210
  end
231
211
 
232
212
  def close
233
- execute :closeWindow
213
+ execute :close_window
234
214
  end
235
215
 
236
216
  def refresh
@@ -242,18 +222,18 @@ module Selenium
242
222
  #
243
223
 
244
224
  def window_handles
245
- execute :getWindowHandles
225
+ execute :get_window_handles
246
226
  end
247
227
 
248
228
  def window_handle
249
- execute :getWindowHandle
229
+ execute :get_window_handle
250
230
  end
251
231
 
252
232
  def resize_window(width, height, handle = :current)
253
233
  unless handle == :current
254
234
  raise Error::WebDriverError, 'Switch to desired window before changing its size'
255
235
  end
256
- execute :setWindowSize, {}, {width: width,
236
+ execute :set_window_size, {}, {width: width,
257
237
  height: height}
258
238
  end
259
239
 
@@ -261,18 +241,18 @@ module Selenium
261
241
  unless handle == :current
262
242
  raise Error::UnsupportedOperationError, 'Switch to desired window before changing its size'
263
243
  end
264
- execute :maximizeWindow
244
+ execute :maximize_window
265
245
  end
266
246
 
267
247
  def full_screen_window
268
- execute :fullscreenWindow
248
+ execute :fullscreen_window
269
249
  end
270
250
 
271
251
  def window_size(handle = :current)
272
252
  unless handle == :current
273
253
  raise Error::UnsupportedOperationError, 'Switch to desired window before getting its size'
274
254
  end
275
- data = execute :getWindowSize
255
+ data = execute :get_window_size
276
256
 
277
257
  Dimension.new data['width'], data['height']
278
258
  end
@@ -286,7 +266,7 @@ module Selenium
286
266
  end
287
267
 
288
268
  def screenshot
289
- execute :takeScreenshot
269
+ execute :take_screenshot
290
270
  end
291
271
 
292
272
  #
@@ -362,12 +342,12 @@ module Selenium
362
342
  #
363
343
 
364
344
  def execute_script(script, *args)
365
- result = execute :executeScript, {}, {script: script, args: args}
345
+ result = execute :execute_script, {}, {script: script, args: args}
366
346
  unwrap_script_result result
367
347
  end
368
348
 
369
349
  def execute_async_script(script, *args)
370
- result = execute :executeAsyncScript, {}, {script: script, args: args}
350
+ result = execute :execute_async_script, {}, {script: script, args: args}
371
351
  unwrap_script_result result
372
352
  end
373
353
 
@@ -375,25 +355,28 @@ module Selenium
375
355
  # cookies
376
356
  #
377
357
 
358
+ def options
359
+ @options ||= WebDriver::W3COptions.new(self)
360
+ end
361
+
378
362
  def add_cookie(cookie)
379
- execute :addCookie, {}, {cookie: cookie}
363
+ execute :add_cookie, {}, {cookie: cookie}
380
364
  end
381
365
 
382
366
  def delete_cookie(name)
383
- execute :deleteCookie, name: name
367
+ execute :delete_cookie, name: name
384
368
  end
385
369
 
386
- # TODO: - write specs
387
370
  def cookie(name)
388
- execute :getCookie, name: name
371
+ execute :get_cookie, name: name
389
372
  end
390
373
 
391
374
  def cookies
392
- execute :getAllCookies
375
+ execute :get_all_cookies
393
376
  end
394
377
 
395
378
  def delete_all_cookies
396
- cookies.each { |cookie| delete_cookie(cookie['name']) }
379
+ execute :delete_all_cookies
397
380
  end
398
381
 
399
382
  #
@@ -401,7 +384,7 @@ module Selenium
401
384
  #
402
385
 
403
386
  def click_element(element)
404
- execute :elementClick, id: element.values.first
387
+ execute :element_click, id: element.values.first
405
388
  end
406
389
 
407
390
  def click
@@ -409,7 +392,7 @@ module Selenium
409
392
  end
410
393
 
411
394
  def double_click
412
- execute :doubleClick
395
+ execute :double_click
413
396
  end
414
397
 
415
398
  def context_click
@@ -417,11 +400,11 @@ module Selenium
417
400
  end
418
401
 
419
402
  def mouse_down
420
- execute :mouseDown
403
+ execute :mouse_down
421
404
  end
422
405
 
423
406
  def mouse_up
424
- execute :mouseUp
407
+ execute :mouse_up
425
408
  end
426
409
 
427
410
  def mouse_move_to(element, x = nil, y = nil)
@@ -432,7 +415,7 @@ module Selenium
432
415
  params[:yoffset] = y
433
416
  end
434
417
 
435
- execute :mouseMoveTo, {}, params
418
+ execute :mouse_move_to, {}, params
436
419
  end
437
420
 
438
421
  def send_keys_to_active_element(keys)
@@ -441,11 +424,11 @@ module Selenium
441
424
 
442
425
  # TODO: - Implement file verification
443
426
  def send_keys_to_element(element, keys)
444
- execute :elementSendKeys, {id: element.values.first}, {value: keys.join('').split(//)}
427
+ execute :element_send_keys, {id: element.values.first}, {value: keys.join('').split(//)}
445
428
  end
446
429
 
447
430
  def clear_element(element)
448
- execute :elementClear, id: element.values.first
431
+ execute :element_clear, id: element.values.first
449
432
  end
450
433
 
451
434
  def submit_element(element)
@@ -456,60 +439,60 @@ module Selenium
456
439
  end
457
440
 
458
441
  def drag_element(element, right_by, down_by)
459
- execute :dragElement, {id: element.values.first}, {x: right_by, y: down_by}
442
+ execute :drag_element, {id: element.values.first}, {x: right_by, y: down_by}
460
443
  end
461
444
 
462
445
  def touch_single_tap(element)
463
- execute :touchSingleTap, {}, {element: element}
446
+ execute :touch_single_tap, {}, {element: element}
464
447
  end
465
448
 
466
449
  def touch_double_tap(element)
467
- execute :touchDoubleTap, {}, {element: element}
450
+ execute :touch_double_tap, {}, {element: element}
468
451
  end
469
452
 
470
453
  def touch_long_press(element)
471
- execute :touchLongPress, {}, {element: element}
454
+ execute :touch_long_press, {}, {element: element}
472
455
  end
473
456
 
474
457
  def touch_down(x, y)
475
- execute :touchDown, {}, {x: x, y: y}
458
+ execute :touch_down, {}, {x: x, y: y}
476
459
  end
477
460
 
478
461
  def touch_up(x, y)
479
- execute :touchUp, {}, {x: x, y: y}
462
+ execute :touch_up, {}, {x: x, y: y}
480
463
  end
481
464
 
482
465
  def touch_move(x, y)
483
- execute :touchMove, {}, {x: x, y: y}
466
+ execute :touch_move, {}, {x: x, y: y}
484
467
  end
485
468
 
486
469
  def touch_scroll(element, x, y)
487
470
  if element
488
- execute :touchScroll, {}, {element: element,
471
+ execute :touch_scroll, {}, {element: element,
489
472
  xoffset: x,
490
473
  yoffset: y}
491
474
  else
492
- execute :touchScroll, {}, {xoffset: x, yoffset: y}
475
+ execute :touch_scroll, {}, {xoffset: x, yoffset: y}
493
476
  end
494
477
  end
495
478
 
496
479
  def touch_flick(xspeed, yspeed)
497
- execute :touchFlick, {}, {xspeed: xspeed, yspeed: yspeed}
480
+ execute :touch_flick, {}, {xspeed: xspeed, yspeed: yspeed}
498
481
  end
499
482
 
500
483
  def touch_element_flick(element, right_by, down_by, speed)
501
- execute :touchFlick, {}, {element: element,
484
+ execute :touch_flick, {}, {element: element,
502
485
  xoffset: right_by,
503
486
  yoffset: down_by,
504
487
  speed: speed}
505
488
  end
506
489
 
507
490
  def screen_orientation=(orientation)
508
- execute :setScreenOrientation, {}, {orientation: orientation}
491
+ execute :set_screen_orientation, {}, {orientation: orientation}
509
492
  end
510
493
 
511
494
  def screen_orientation
512
- execute :getScreenOrientation
495
+ execute :get_screen_orientation
513
496
  end
514
497
 
515
498
  #
@@ -517,7 +500,7 @@ module Selenium
517
500
  #
518
501
 
519
502
  def element_tag_name(element)
520
- execute :getElementTagName, id: element.values.first
503
+ execute :get_element_tag_name, id: element.values.first
521
504
  end
522
505
 
523
506
  def element_attribute(element, name)
@@ -525,7 +508,7 @@ module Selenium
525
508
  end
526
509
 
527
510
  def element_property(element, name)
528
- execute :getElementProperty, id: element.values.first, name: name
511
+ execute :get_element_property, id: element.ref.values.first, name: name
529
512
  end
530
513
 
531
514
  def element_value(element)
@@ -533,11 +516,11 @@ module Selenium
533
516
  end
534
517
 
535
518
  def element_text(element)
536
- execute :getElementText, id: element.values.first
519
+ execute :get_element_text, id: element.values.first
537
520
  end
538
521
 
539
522
  def element_location(element)
540
- data = execute :getElementRect, id: element.values.first
523
+ data = execute :get_element_rect, id: element.values.first
541
524
 
542
525
  Point.new data['x'], data['y']
543
526
  end
@@ -548,27 +531,25 @@ module Selenium
548
531
  end
549
532
 
550
533
  def element_size(element)
551
- data = execute :getElementRect, id: element.values.first
534
+ data = execute :get_element_rect, id: element.values.first
552
535
 
553
536
  Dimension.new data['width'], data['height']
554
537
  end
555
538
 
556
539
  def element_enabled?(element)
557
- execute :isElementEnabled, id: element.values.first
540
+ execute :is_element_enabled, id: element.values.first
558
541
  end
559
542
 
560
543
  def element_selected?(element)
561
- execute :isElementSelected, id: element.values.first
544
+ execute :is_element_selected, id: element.values.first
562
545
  end
563
546
 
564
547
  def element_displayed?(element)
565
- jwp = Selenium::WebDriver::Remote::Bridge::COMMANDS[:isElementDisplayed]
566
- self.class.command(:isElementDisplayed, jwp.first, jwp.last)
567
- execute :isElementDisplayed, id: element.values.first
548
+ execute :is_element_displayed, id: element.values.first
568
549
  end
569
550
 
570
551
  def element_value_of_css_property(element, prop)
571
- execute :getElementCssValue, id: element.values.first, property_name: prop
552
+ execute :get_element_css_value, id: element.values.first, property_name: prop
572
553
  end
573
554
 
574
555
  #
@@ -576,7 +557,7 @@ module Selenium
576
557
  #
577
558
 
578
559
  def active_element
579
- Element.new self, execute(:getActiveElement)
560
+ Element.new self, execute(:get_active_element)
580
561
  end
581
562
 
582
563
  alias_method :switch_to_active_element, :active_element
@@ -585,9 +566,9 @@ module Selenium
585
566
  how, what = convert_locators(how, what)
586
567
 
587
568
  id = if parent
588
- execute :findChildElement, {id: parent.values.first}, {using: how, value: what}
569
+ execute :find_child_element, {id: parent.values.first}, {using: how, value: what}
589
570
  else
590
- execute :findElement, {}, {using: how, value: what}
571
+ execute :find_element, {}, {using: how, value: what}
591
572
  end
592
573
  Element.new self, id
593
574
  end
@@ -596,9 +577,9 @@ module Selenium
596
577
  how, what = convert_locators(how, what)
597
578
 
598
579
  ids = if parent
599
- execute :findChildElements, {id: parent.values.first}, {using: how, value: what}
580
+ execute :find_child_elements, {id: parent.values.first}, {using: how, value: what}
600
581
  else
601
- execute :findElements, {}, {using: how, value: what}
582
+ execute :find_elements, {}, {using: how, value: what}
602
583
  end
603
584
 
604
585
  ids.map { |id| Element.new self, id }
@@ -642,7 +623,7 @@ module Selenium
642
623
  #
643
624
 
644
625
  def raw_execute(command, opts = {}, command_hash = nil)
645
- verb, path = COMMANDS[command] || raise(ArgumentError, "unknown command: #{command.inspect}")
626
+ verb, path = commands(command) || raise(ArgumentError, "unknown command: #{command.inspect}")
646
627
  path = path.dup
647
628
 
648
629
  path[':session_id'] = @session_id if path.include?(':session_id')