selenium-webdriver 2.53.3 → 3.142.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES +665 -8
  3. data/Gemfile +2 -0
  4. data/LICENSE +1 -1
  5. data/README.md +2 -3
  6. data/lib/selenium/server.rb +76 -73
  7. data/lib/selenium/webdriver/atoms/getAttribute.js +7 -0
  8. data/lib/selenium/webdriver/atoms/isDisplayed.js +102 -0
  9. data/lib/selenium/webdriver/{phantomjs.rb → atoms.rb} +10 -14
  10. data/lib/selenium/webdriver/chrome/bridge.rb +30 -101
  11. data/lib/selenium/webdriver/chrome/driver.rb +127 -0
  12. data/lib/selenium/webdriver/chrome/options.rb +190 -0
  13. data/lib/selenium/webdriver/chrome/profile.rb +21 -20
  14. data/lib/selenium/webdriver/chrome/service.rb +26 -93
  15. data/lib/selenium/webdriver/chrome.rb +15 -6
  16. data/lib/selenium/webdriver/common/action_builder.rb +52 -58
  17. data/lib/selenium/webdriver/common/alert.rb +7 -15
  18. data/lib/selenium/webdriver/common/bridge_helper.rb +18 -22
  19. data/lib/selenium/webdriver/common/driver.rb +72 -72
  20. data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +45 -0
  21. data/lib/selenium/webdriver/common/driver_extensions/has_addons.rb +50 -0
  22. data/lib/selenium/webdriver/common/driver_extensions/{has_input_devices.rb → has_debugger.rb} +11 -27
  23. data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +6 -10
  24. data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +51 -0
  25. data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +7 -8
  26. data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +51 -0
  27. data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +2 -4
  28. data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +2 -4
  29. data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +3 -5
  30. data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +2 -5
  31. data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +6 -9
  32. data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +9 -7
  33. data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +3 -8
  34. data/lib/selenium/webdriver/common/element.rb +59 -39
  35. data/lib/selenium/webdriver/common/error.rb +259 -104
  36. data/lib/selenium/webdriver/common/file_reaper.rb +6 -14
  37. data/lib/selenium/webdriver/common/html5/local_storage.rb +8 -10
  38. data/lib/selenium/webdriver/common/html5/session_storage.rb +8 -10
  39. data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +8 -16
  40. data/lib/selenium/webdriver/common/interactions/input_device.rb +54 -0
  41. data/lib/selenium/webdriver/common/interactions/interaction.rb +53 -0
  42. data/lib/selenium/webdriver/{safari/browser.rb → common/interactions/interactions.rb} +17 -14
  43. data/lib/selenium/webdriver/common/interactions/key_actions.rb +145 -0
  44. data/lib/selenium/webdriver/common/interactions/key_input.rb +66 -0
  45. data/lib/selenium/webdriver/{android.rb → common/interactions/none_input.rb} +14 -6
  46. data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +363 -0
  47. data/lib/selenium/webdriver/common/interactions/pointer_input.rb +139 -0
  48. data/lib/selenium/webdriver/common/keyboard.rb +10 -14
  49. data/lib/selenium/webdriver/common/keys.rb +102 -82
  50. data/lib/selenium/webdriver/common/log_entry.rb +7 -8
  51. data/lib/selenium/webdriver/common/logger.rb +115 -0
  52. data/lib/selenium/webdriver/common/logs.rb +4 -6
  53. data/lib/selenium/webdriver/common/manager.rb +177 -0
  54. data/lib/selenium/webdriver/common/mouse.rb +12 -14
  55. data/lib/selenium/webdriver/common/navigation.rb +4 -6
  56. data/lib/selenium/webdriver/common/options.rb +26 -127
  57. data/lib/selenium/webdriver/common/platform.rb +75 -101
  58. data/lib/selenium/webdriver/common/port_prober.rb +7 -19
  59. data/lib/selenium/webdriver/common/profile_helper.rb +8 -11
  60. data/lib/selenium/webdriver/common/proxy.rb +68 -74
  61. data/lib/selenium/webdriver/common/search_context.rb +28 -37
  62. data/lib/selenium/webdriver/common/service.rb +219 -0
  63. data/lib/selenium/webdriver/common/socket_lock.rb +15 -16
  64. data/lib/selenium/webdriver/common/socket_poller.rb +30 -28
  65. data/lib/selenium/webdriver/common/target_locator.rb +16 -18
  66. data/lib/selenium/webdriver/common/timeouts.rb +6 -8
  67. data/lib/selenium/webdriver/common/touch_action_builder.rb +5 -10
  68. data/lib/selenium/webdriver/common/touch_screen.rb +22 -23
  69. data/lib/selenium/webdriver/common/w3c_action_builder.rb +212 -0
  70. data/lib/selenium/webdriver/common/w3c_manager.rb +45 -0
  71. data/lib/selenium/webdriver/common/wait.rb +17 -16
  72. data/lib/selenium/webdriver/common/window.rb +50 -17
  73. data/lib/selenium/webdriver/common/zipper.rb +9 -13
  74. data/lib/selenium/webdriver/common.rb +21 -7
  75. data/lib/selenium/webdriver/edge/bridge.rb +34 -63
  76. data/lib/selenium/webdriver/edge/driver.rb +66 -0
  77. data/lib/selenium/webdriver/edge/options.rb +80 -0
  78. data/lib/selenium/webdriver/edge/service.rb +23 -95
  79. data/lib/selenium/webdriver/edge.rb +13 -13
  80. data/lib/selenium/webdriver/firefox/binary.rb +45 -60
  81. data/lib/selenium/webdriver/firefox/driver.rb +50 -0
  82. data/lib/selenium/webdriver/firefox/extension/prefs.json +3 -12
  83. data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
  84. data/lib/selenium/webdriver/firefox/extension.rb +20 -10
  85. data/lib/selenium/webdriver/firefox/launcher.rb +16 -22
  86. data/lib/selenium/webdriver/firefox/legacy/driver.rb +83 -0
  87. data/lib/selenium/webdriver/firefox/marionette/bridge.rb +49 -0
  88. data/lib/selenium/webdriver/firefox/marionette/driver.rb +90 -0
  89. data/lib/selenium/webdriver/firefox/options.rb +162 -0
  90. data/lib/selenium/webdriver/firefox/profile.rb +47 -48
  91. data/lib/selenium/webdriver/firefox/profiles_ini.rb +11 -18
  92. data/lib/selenium/webdriver/firefox/service.rb +24 -95
  93. data/lib/selenium/webdriver/firefox/util.rb +2 -4
  94. data/lib/selenium/webdriver/firefox.rb +27 -12
  95. data/lib/selenium/webdriver/ie/driver.rb +85 -0
  96. data/lib/selenium/webdriver/ie/options.rb +138 -0
  97. data/lib/selenium/webdriver/ie/service.rb +54 -0
  98. data/lib/selenium/webdriver/ie.rb +12 -10
  99. data/lib/selenium/webdriver/remote/bridge.rb +100 -564
  100. data/lib/selenium/webdriver/remote/capabilities.rb +98 -100
  101. data/lib/selenium/webdriver/remote/driver.rb +51 -0
  102. data/lib/selenium/webdriver/remote/http/common.rb +34 -22
  103. data/lib/selenium/webdriver/remote/http/curb.rb +13 -14
  104. data/lib/selenium/webdriver/remote/http/default.rb +62 -43
  105. data/lib/selenium/webdriver/remote/http/persistent.rb +12 -9
  106. data/lib/selenium/webdriver/remote/oss/bridge.rb +594 -0
  107. data/lib/selenium/webdriver/remote/oss/commands.rb +223 -0
  108. data/lib/selenium/webdriver/remote/response.rb +48 -28
  109. data/lib/selenium/webdriver/remote/server_error.rb +3 -5
  110. data/lib/selenium/webdriver/remote/w3c/bridge.rb +605 -0
  111. data/lib/selenium/webdriver/remote/w3c/capabilities.rb +310 -0
  112. data/lib/selenium/webdriver/remote/w3c/commands.rb +157 -0
  113. data/lib/selenium/webdriver/remote.rb +10 -16
  114. data/lib/selenium/webdriver/safari/bridge.rb +17 -101
  115. data/lib/selenium/webdriver/{firefox/w3c_bridge.rb → safari/driver.rb} +27 -25
  116. data/lib/selenium/webdriver/safari/options.rb +29 -31
  117. data/lib/selenium/webdriver/safari/service.rb +38 -0
  118. data/lib/selenium/webdriver/safari.rb +27 -27
  119. data/lib/selenium/webdriver/support/abstract_event_listener.rb +19 -4
  120. data/lib/selenium/webdriver/support/block_event_listener.rb +3 -5
  121. data/lib/selenium/webdriver/support/color.rb +60 -43
  122. data/lib/selenium/webdriver/support/escaper.rb +43 -0
  123. data/lib/selenium/webdriver/support/event_firing_bridge.rb +39 -41
  124. data/lib/selenium/webdriver/support/select.rb +45 -97
  125. data/lib/selenium/webdriver/support.rb +3 -2
  126. data/lib/selenium/webdriver/{iphone.rb → version.rb} +3 -7
  127. data/lib/selenium/webdriver.rb +36 -23
  128. data/lib/selenium-webdriver.rb +2 -2
  129. data/selenium-webdriver.gemspec +42 -29
  130. metadata +331 -262
  131. data/lib/selenium/client/base.rb +0 -151
  132. data/lib/selenium/client/driver.rb +0 -29
  133. data/lib/selenium/client/errors.rb +0 -28
  134. data/lib/selenium/client/extensions.rb +0 -132
  135. data/lib/selenium/client/idiomatic.rb +0 -507
  136. data/lib/selenium/client/javascript_expression_builder.rb +0 -135
  137. data/lib/selenium/client/javascript_frameworks/jquery.rb +0 -32
  138. data/lib/selenium/client/javascript_frameworks/prototype.rb +0 -32
  139. data/lib/selenium/client/legacy_driver.rb +0 -1722
  140. data/lib/selenium/client/protocol.rb +0 -123
  141. data/lib/selenium/client/selenium_helper.rb +0 -49
  142. data/lib/selenium/client.rb +0 -57
  143. data/lib/selenium/rake/server_task.rb +0 -176
  144. data/lib/selenium/webdriver/android/bridge.rb +0 -68
  145. data/lib/selenium/webdriver/common/core_ext/base64.rb +0 -28
  146. data/lib/selenium/webdriver/common/core_ext/dir.rb +0 -61
  147. data/lib/selenium/webdriver/common/html5/location.rb +0 -19
  148. data/lib/selenium/webdriver/common/w3c_error.rb +0 -194
  149. data/lib/selenium/webdriver/edge/legacy_support.rb +0 -117
  150. data/lib/selenium/webdriver/firefox/bridge.rb +0 -89
  151. data/lib/selenium/webdriver/ie/bridge.rb +0 -88
  152. data/lib/selenium/webdriver/ie/server.rb +0 -133
  153. data/lib/selenium/webdriver/iphone/bridge.rb +0 -64
  154. data/lib/selenium/webdriver/phantomjs/bridge.rb +0 -78
  155. data/lib/selenium/webdriver/phantomjs/service.rb +0 -130
  156. data/lib/selenium/webdriver/remote/commands.rb +0 -211
  157. data/lib/selenium/webdriver/remote/w3c_bridge.rb +0 -668
  158. data/lib/selenium/webdriver/remote/w3c_capabilities.rb +0 -236
  159. data/lib/selenium/webdriver/remote/w3c_commands.rb +0 -132
  160. data/lib/selenium/webdriver/safari/resources/client.js +0 -7255
  161. data/lib/selenium/webdriver/safari/server.rb +0 -187
  162. data/lib/selenium-client.rb +0 -21
@@ -1,5 +1,5 @@
1
- # encoding: utf-8
2
- #
1
+ # frozen_string_literal: true
2
+
3
3
  # Licensed to the Software Freedom Conservancy (SFC) under one
4
4
  # or more contributor license agreements. See the NOTICE file
5
5
  # distributed with this work for additional information
@@ -20,7 +20,6 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  class Wait
23
-
24
23
  DEFAULT_TIMEOUT = 5
25
24
  DEFAULT_INTERVAL = 0.2
26
25
 
@@ -41,19 +40,18 @@ module Selenium
41
40
  @ignored = Array(opts[:ignore] || Error::NoSuchElementError)
42
41
  end
43
42
 
44
-
45
43
  #
46
44
  # Wait until the given block returns a true value.
47
45
  #
48
- # @raise [Error::TimeOutError]
46
+ # @raise [Error::TimeoutError]
49
47
  # @return [Object] the result of the block
50
48
  #
51
49
 
52
- def until(&blk)
53
- end_time = Time.now + @timeout
50
+ def until
51
+ end_time = current_time + @timeout
54
52
  last_error = nil
55
53
 
56
- until Time.now > end_time
54
+ until current_time > end_time
57
55
  begin
58
56
  result = yield
59
57
  return result if result
@@ -64,19 +62,22 @@ module Selenium
64
62
  sleep @interval
65
63
  end
66
64
 
67
-
68
- if @message
69
- msg = @message.dup
70
- else
71
- msg = "timed out after #{@timeout} seconds"
72
- end
65
+ msg = if @message
66
+ @message.dup
67
+ else
68
+ +"timed out after #{@timeout} seconds"
69
+ end
73
70
 
74
71
  msg << " (#{last_error.message})" if last_error
75
72
 
76
- raise Error::TimeOutError, msg
73
+ raise Error::TimeoutError, msg
77
74
  end
78
75
 
76
+ private
77
+
78
+ def current_time
79
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
80
+ end
79
81
  end # Wait
80
82
  end # WebDriver
81
83
  end # Selenium
82
-
@@ -1,5 +1,5 @@
1
- # encoding: utf-8
2
- #
1
+ # frozen_string_literal: true
2
+
3
3
  # Licensed to the Software Freedom Conservancy (SFC) under one
4
4
  # or more contributor license agreements. See the NOTICE file
5
5
  # distributed with this work for additional information
@@ -19,13 +19,11 @@
19
19
 
20
20
  module Selenium
21
21
  module WebDriver
22
-
23
22
  #
24
23
  # @api beta This API may be changed or removed in a future release.
25
24
  #
26
25
 
27
26
  class Window
28
-
29
27
  #
30
28
  # @api private
31
29
  #
@@ -42,11 +40,11 @@ module Selenium
42
40
 
43
41
  def size=(dimension)
44
42
  unless dimension.respond_to?(:width) && dimension.respond_to?(:height)
45
- raise ArgumentError, "expected #{dimension.inspect}:#{dimension.class}" +
46
- " to respond to #width and #height"
43
+ raise ArgumentError, "expected #{dimension.inspect}:#{dimension.class}" \
44
+ ' to respond to #width and #height'
47
45
  end
48
46
 
49
- @bridge.setWindowSize dimension.width, dimension.height
47
+ @bridge.resize_window dimension.width, dimension.height
50
48
  end
51
49
 
52
50
  #
@@ -56,7 +54,7 @@ module Selenium
56
54
  #
57
55
 
58
56
  def size
59
- @bridge.getWindowSize
57
+ @bridge.window_size
60
58
  end
61
59
 
62
60
  #
@@ -67,11 +65,11 @@ module Selenium
67
65
 
68
66
  def position=(point)
69
67
  unless point.respond_to?(:x) && point.respond_to?(:y)
70
- raise ArgumentError, "expected #{point.inspect}:#{point.class}" +
71
- " to respond to #x and #y"
68
+ raise ArgumentError, "expected #{point.inspect}:#{point.class}" \
69
+ ' to respond to #x and #y'
72
70
  end
73
71
 
74
- @bridge.setWindowPosition point.x, point.y
72
+ @bridge.reposition_window point.x, point.y
75
73
  end
76
74
 
77
75
  #
@@ -81,7 +79,35 @@ module Selenium
81
79
  #
82
80
 
83
81
  def position
84
- @bridge.getWindowPosition
82
+ @bridge.window_position
83
+ end
84
+
85
+ #
86
+ # Sets the current window rect to the given point and position.
87
+ #
88
+ # @param [Selenium::WebDriver::Rectangle, #x, #y, #width, #height] rectangle The new rect.
89
+ #
90
+
91
+ def rect=(rectangle)
92
+ unless %w[x y width height].all? { |val| rectangle.respond_to? val }
93
+ raise ArgumentError, "expected #{rectangle.inspect}:#{rectangle.class}" \
94
+ ' to respond to #x, #y, #width, and #height'
95
+ end
96
+
97
+ @bridge.set_window_rect(x: rectangle.x,
98
+ y: rectangle.y,
99
+ width: rectangle.width,
100
+ height: rectangle.height)
101
+ end
102
+
103
+ #
104
+ # Get the rect of the current window.
105
+ #
106
+ # @return [Selenium::WebDriver::Rectangle] The rectangle.
107
+ #
108
+
109
+ def rect
110
+ @bridge.window_rect
85
111
  end
86
112
 
87
113
  #
@@ -94,7 +120,7 @@ module Selenium
94
120
  #
95
121
 
96
122
  def resize_to(width, height)
97
- @bridge.setWindowSize Integer(width), Integer(height)
123
+ @bridge.resize_window Integer(width), Integer(height)
98
124
  end
99
125
 
100
126
  #
@@ -106,7 +132,7 @@ module Selenium
106
132
  #
107
133
 
108
134
  def move_to(x, y)
109
- @bridge.setWindowPosition Integer(x), Integer(y)
135
+ @bridge.reposition_window Integer(x), Integer(y)
110
136
  end
111
137
 
112
138
  #
@@ -114,7 +140,15 @@ module Selenium
114
140
  #
115
141
 
116
142
  def maximize
117
- @bridge.maximizeWindow
143
+ @bridge.maximize_window
144
+ end
145
+
146
+ #
147
+ # Minimize the current window
148
+ #
149
+
150
+ def minimize
151
+ @bridge.minimize_window
118
152
  end
119
153
 
120
154
  #
@@ -122,9 +156,8 @@ module Selenium
122
156
  #
123
157
 
124
158
  def full_screen
125
- @bridge.fullscreenWindow
159
+ @bridge.full_screen_window
126
160
  end
127
-
128
161
  end # Window
129
162
  end # WebDriver
130
163
  end # Selenium
@@ -1,5 +1,5 @@
1
- # encoding: utf-8
2
- #
1
+ # frozen_string_literal: true
2
+
3
3
  # Licensed to the Software Freedom Conservancy (SFC) under one
4
4
  # or more contributor license agreements. See the NOTICE file
5
5
  # distributed with this work for additional information
@@ -20,6 +20,7 @@
20
20
  require 'zip'
21
21
  require 'tempfile'
22
22
  require 'find'
23
+ require 'base64'
23
24
 
24
25
  module Selenium
25
26
  module WebDriver
@@ -28,13 +29,11 @@ module Selenium
28
29
  #
29
30
 
30
31
  module Zipper
31
-
32
- EXTENSIONS = %w[.zip .xpi]
32
+ EXTENSIONS = %w[.zip .xpi].freeze
33
33
 
34
34
  class << self
35
-
36
35
  def unzip(path)
37
- destination = Dir.mktmpdir("webdriver-unzip")
36
+ destination = Dir.mktmpdir('webdriver-unzip')
38
37
  FileReaper << destination
39
38
 
40
39
  Zip::File.open(path) do |zip|
@@ -53,13 +52,11 @@ module Selenium
53
52
  def zip(path)
54
53
  with_tmp_zip do |zip|
55
54
  ::Find.find(path) do |file|
56
- unless File.directory?(file)
57
- add_zip_entry zip, file, file.sub("#{path}/", '')
58
- end
55
+ add_zip_entry zip, file, file.sub("#{path}/", '') unless File.directory?(file)
59
56
  end
60
57
 
61
58
  zip.commit
62
- File.open(zip.name, "rb") { |io| Base64.strict_encode64 io.read }
59
+ File.open(zip.name, 'rb') { |io| Base64.strict_encode64 io.read }
63
60
  end
64
61
  end
65
62
 
@@ -68,7 +65,7 @@ module Selenium
68
65
  add_zip_entry zip, path, File.basename(path)
69
66
 
70
67
  zip.commit
71
- File.open(zip.name, "rb") { |io| Base64.strict_encode64 io.read }
68
+ File.open(zip.name, 'rb') { |io| Base64.strict_encode64 io.read }
72
69
  end
73
70
  end
74
71
 
@@ -78,7 +75,7 @@ module Selenium
78
75
  # can't use Tempfile here since it doesn't support File::BINARY mode on 1.8
79
76
  # can't use Dir.mktmpdir(&blk) because of http://jira.codehaus.org/browse/JRUBY-4082
80
77
  tmp_dir = Dir.mktmpdir
81
- zip_path = File.join(tmp_dir, "webdriver-zip")
78
+ zip_path = File.join(tmp_dir, 'webdriver-zip')
82
79
 
83
80
  begin
84
81
  Zip::File.open(zip_path, Zip::File::CREATE, &blk)
@@ -94,7 +91,6 @@ module Selenium
94
91
 
95
92
  zip.add entry, file
96
93
  end
97
-
98
94
  end
99
95
  end # Zipper
100
96
  end # WebDriver
@@ -1,5 +1,5 @@
1
- # encoding: utf-8
2
- #
1
+ # frozen_string_literal: true
2
+
3
3
  # Licensed to the Software Freedom Conservancy (SFC) under one
4
4
  # or more contributor license agreements. See the NOTICE file
5
5
  # distributed with this work for additional information
@@ -17,14 +17,12 @@
17
17
  # specific language governing permissions and limitations
18
18
  # under the License.
19
19
 
20
- require 'selenium/webdriver/common/core_ext/dir'
21
- require 'selenium/webdriver/common/core_ext/base64'
22
- require 'selenium/webdriver/common/w3c_error'
23
20
  require 'selenium/webdriver/common/error'
24
21
  require 'selenium/webdriver/common/platform'
25
22
  require 'selenium/webdriver/common/proxy'
26
23
  require 'selenium/webdriver/common/log_entry'
27
24
  require 'selenium/webdriver/common/file_reaper'
25
+ require 'selenium/webdriver/common/service'
28
26
  require 'selenium/webdriver/common/socket_lock'
29
27
  require 'selenium/webdriver/common/socket_poller'
30
28
  require 'selenium/webdriver/common/port_prober'
@@ -38,26 +36,42 @@ require 'selenium/webdriver/common/target_locator'
38
36
  require 'selenium/webdriver/common/navigation'
39
37
  require 'selenium/webdriver/common/timeouts'
40
38
  require 'selenium/webdriver/common/window'
39
+ require 'selenium/webdriver/common/logger'
41
40
  require 'selenium/webdriver/common/logs'
42
- require 'selenium/webdriver/common/options'
41
+ require 'selenium/webdriver/common/manager'
42
+ require 'selenium/webdriver/common/w3c_manager'
43
43
  require 'selenium/webdriver/common/search_context'
44
44
  require 'selenium/webdriver/common/action_builder'
45
+ require 'selenium/webdriver/common/interactions/key_actions'
46
+ require 'selenium/webdriver/common/interactions/pointer_actions'
47
+ require 'selenium/webdriver/common/w3c_action_builder'
45
48
  require 'selenium/webdriver/common/touch_action_builder'
46
49
  require 'selenium/webdriver/common/html5/shared_web_storage'
47
50
  require 'selenium/webdriver/common/html5/local_storage'
48
51
  require 'selenium/webdriver/common/html5/session_storage'
49
52
  require 'selenium/webdriver/common/driver_extensions/takes_screenshot'
50
53
  require 'selenium/webdriver/common/driver_extensions/rotatable'
51
- require 'selenium/webdriver/common/driver_extensions/has_input_devices'
52
54
  require 'selenium/webdriver/common/driver_extensions/has_web_storage'
55
+ require 'selenium/webdriver/common/driver_extensions/downloads_files'
53
56
  require 'selenium/webdriver/common/driver_extensions/has_location'
54
57
  require 'selenium/webdriver/common/driver_extensions/has_session_id'
55
58
  require 'selenium/webdriver/common/driver_extensions/has_touch_screen'
56
59
  require 'selenium/webdriver/common/driver_extensions/has_remote_status'
60
+ require 'selenium/webdriver/common/driver_extensions/has_network_conditions'
57
61
  require 'selenium/webdriver/common/driver_extensions/has_network_connection'
62
+ require 'selenium/webdriver/common/driver_extensions/has_permissions'
63
+ require 'selenium/webdriver/common/driver_extensions/has_debugger'
58
64
  require 'selenium/webdriver/common/driver_extensions/uploads_files'
65
+ require 'selenium/webdriver/common/driver_extensions/has_addons'
66
+ require 'selenium/webdriver/common/interactions/interactions'
67
+ require 'selenium/webdriver/common/interactions/input_device'
68
+ require 'selenium/webdriver/common/interactions/interaction'
69
+ require 'selenium/webdriver/common/interactions/none_input'
70
+ require 'selenium/webdriver/common/interactions/key_input'
71
+ require 'selenium/webdriver/common/interactions/pointer_input'
59
72
  require 'selenium/webdriver/common/keys'
60
73
  require 'selenium/webdriver/common/bridge_helper'
61
74
  require 'selenium/webdriver/common/profile_helper'
75
+ require 'selenium/webdriver/common/options'
62
76
  require 'selenium/webdriver/common/driver'
63
77
  require 'selenium/webdriver/common/element'
@@ -1,5 +1,5 @@
1
- # encoding: utf-8
2
- #
1
+ # frozen_string_literal: true
2
+
3
3
  # Licensed to the Software Freedom Conservancy (SFC) under one
4
4
  # or more contributor license agreements. See the NOTICE file
5
5
  # distributed with this work for additional information
@@ -20,83 +20,54 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module Edge
23
-
24
- # @api private
25
- class Bridge < Remote::W3CBridge
26
-
27
- def initialize(opts = {})
28
-
29
- http_client = opts.delete(:http_client)
30
-
31
- if opts.has_key?(:url)
32
- url = opts.delete(:url)
23
+ module Bridge
24
+
25
+ def commands(command)
26
+ unsupported = %i[execute_script execute_async_script submit_element double_click
27
+ mouse_down mouse_up mouse_move_to click
28
+ send_keys_to_active_element get_window_handles get_current_window_handle
29
+ get_window_size set_window_size get_window_position set_window_position
30
+ maximize_window get_alert_text accept_alert dismiss_alert]
31
+ if unsupported.include? command
32
+ Remote::OSS::Bridge::COMMANDS[command]
33
33
  else
34
- @service = Service.default_service(*extract_service_args(opts))
35
-
36
- if @service.instance_variable_get("@host") == "127.0.0.1"
37
- @service.instance_variable_set("@host", 'localhost')
38
- end
39
-
40
- @service.start
41
-
42
- url = @service.uri
34
+ super
43
35
  end
44
-
45
- caps = create_capabilities(opts)
46
-
47
- remote_opts = {
48
- :url => url,
49
- :desired_capabilities => caps
50
- }
51
-
52
- remote_opts.merge!(:http_client => http_client) if http_client
53
- super(remote_opts)
54
36
  end
55
37
 
56
- def browser
57
- :edge
38
+ def send_keys_to_active_element(key)
39
+ execute :send_keys_to_active_element, {}, {value: key}
58
40
  end
59
41
 
60
- def driver_extensions
61
- [
62
- DriverExtensions::TakesScreenshot,
63
- DriverExtensions::HasInputDevices
64
- ]
42
+ def window_handle
43
+ execute :get_current_window_handle
65
44
  end
66
45
 
67
- def capabilities
68
- @capabilities ||= Remote::Capabilities.edge
69
- end
46
+ def window_size(handle = :current)
47
+ data = execute :get_window_size, window_handle: handle
70
48
 
71
- def quit
72
- super
73
- ensure
74
- @service.stop if @service
49
+ Dimension.new data['width'], data['height']
75
50
  end
76
51
 
77
- private
78
-
79
- def create_capabilities(opts)
80
- caps = opts.delete(:desired_capabilities) { Remote::W3CCapabilities.edge }
81
- page_load_strategy = opts.delete(:page_load_strategy) || "normal"
82
-
83
- unless opts.empty?
84
- raise ArgumentError, "unknown option#{'s' if opts.size != 1}: #{opts.inspect}"
85
- end
52
+ def resize_window(width, height, handle = :current)
53
+ execute :set_window_size, {window_handle: handle},
54
+ {width: width,
55
+ height: height}
56
+ end
86
57
 
87
- caps['page_load_strategy'] = page_load_strategy
58
+ def window_position(handle = :current)
59
+ data = execute :get_window_position, window_handle: handle
88
60
 
89
- caps
61
+ Point.new data['x'], data['y']
90
62
  end
91
63
 
92
- def extract_service_args(opts)
93
- args = []
94
-
95
- if opts.has_key?(:service_log_path)
96
- args << "--log-path=#{opts.delete(:service_log_path)}"
97
- end
64
+ def reposition_window(x, y, handle = :current)
65
+ execute :set_window_position, {window_handle: handle},
66
+ {x: x, y: y}
67
+ end
98
68
 
99
- args
69
+ def maximize_window(handle = :current)
70
+ execute :maximize_window, window_handle: handle
100
71
  end
101
72
 
102
73
  end # Bridge
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Licensed to the Software Freedom Conservancy (SFC) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The SFC licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+
20
+ module Selenium
21
+ module WebDriver
22
+ module Edge
23
+
24
+ #
25
+ # Driver implementation for Microsoft Edge.
26
+ # @api private
27
+ #
28
+
29
+ class Driver < WebDriver::Driver
30
+ include DriverExtensions::TakesScreenshot
31
+
32
+ def initialize(opts = {})
33
+ opts[:desired_capabilities] ||= Remote::Capabilities.edge
34
+
35
+ opts[:url] ||= service_url(opts)
36
+
37
+ listener = opts.delete(:listener)
38
+
39
+ # Edge is mostly using W3C dialect, but a request to
40
+ # create session responds with OSS-like body,
41
+ # so we need to force W3C implementation.
42
+ desired_capabilities = opts.delete(:desired_capabilities)
43
+ bridge = Remote::Bridge.new(opts)
44
+ capabilities = bridge.create_session(desired_capabilities)
45
+
46
+ WebDriver.logger.info 'Forcing W3C dialect.'
47
+ @bridge = Remote::W3C::Bridge.new(capabilities, bridge.session_id, **opts)
48
+ @bridge.extend Edge::Bridge
49
+
50
+ super(@bridge, listener: listener)
51
+ end
52
+
53
+ def browser
54
+ :edge
55
+ end
56
+
57
+ def quit
58
+ super
59
+ ensure
60
+ @service&.stop
61
+ end
62
+
63
+ end # Driver
64
+ end # Edge
65
+ end # WebDriver
66
+ end # Selenium
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Licensed to the Software Freedom Conservancy (SFC) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The SFC licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+
20
+ module Selenium
21
+ module WebDriver
22
+ module Edge
23
+ class Options
24
+ attr_accessor :in_private, :start_page
25
+ attr_reader :extension_paths
26
+
27
+ #
28
+ # Create a new Options instance for Edge.
29
+ #
30
+ # @example
31
+ # options = Selenium::WebDriver::Edge::Options.new(in_private: true)
32
+ # driver = Selenium::WebDriver.for :edge, options: options
33
+ #
34
+ # @param [Hash] opts the pre-defined options to create the Edge::Options with
35
+ # @option opts [Boolean] :in_private Start in private mode. Default is false
36
+ # @option opts [Array<String>] :extension_paths A list of full paths to extensions to install on startup
37
+ # @option opts [String] :start_page Default page to start with
38
+ #
39
+ # @see https://docs.microsoft.com/en-us/microsoft-edge/webdriver
40
+ #
41
+
42
+ def initialize(**opts)
43
+ @in_private = opts.delete(:in_private) || false
44
+ @extension_paths = opts.delete(:extension_paths) || []
45
+ @start_page = opts.delete(:start_page)
46
+ end
47
+
48
+ #
49
+ # Add an extension by local path.
50
+ #
51
+ # @example
52
+ # options = Selenium::WebDriver::Edge::Options.new
53
+ # options.add_extension_path('C:\path\to\extension')
54
+ #
55
+ # @param [String] path The local path to the extension folder
56
+ #
57
+
58
+ def add_extension_path(path)
59
+ raise Error::WebDriverError, "could not find extension at #{path.inspect}" unless File.directory?(path)
60
+
61
+ @extension_paths << path
62
+ end
63
+
64
+ #
65
+ # @api private
66
+ #
67
+
68
+ def as_json(*)
69
+ opts = {}
70
+
71
+ opts['ms:inPrivate'] = true if @in_private
72
+ opts['ms:extensionPaths'] = @extension_paths if @extension_paths.any?
73
+ opts['ms:startPage'] = @start_page if @start_page
74
+
75
+ opts
76
+ end
77
+ end # Options
78
+ end # Edge
79
+ end # WebDriver
80
+ end # Selenium