browserstack-webdriver 0.0.1
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.
- checksums.yaml +7 -0
- data/CHANGES +791 -0
- data/README.md +31 -0
- data/build.desc +334 -0
- data/lib/selenium-client.rb +2 -0
- data/lib/selenium-webdriver.rb +1 -0
- data/lib/selenium/client.rb +37 -0
- data/lib/selenium/client/base.rb +132 -0
- data/lib/selenium/client/driver.rb +10 -0
- data/lib/selenium/client/errors.rb +9 -0
- data/lib/selenium/client/extensions.rb +118 -0
- data/lib/selenium/client/idiomatic.rb +488 -0
- data/lib/selenium/client/javascript_expression_builder.rb +116 -0
- data/lib/selenium/client/javascript_frameworks/jquery.rb +13 -0
- data/lib/selenium/client/javascript_frameworks/prototype.rb +13 -0
- data/lib/selenium/client/legacy_driver.rb +1720 -0
- data/lib/selenium/client/protocol.rb +104 -0
- data/lib/selenium/client/selenium_helper.rb +34 -0
- data/lib/selenium/rake/server_task.rb +157 -0
- data/lib/selenium/server.rb +248 -0
- data/lib/selenium/webdriver.rb +71 -0
- data/lib/selenium/webdriver/android.rb +9 -0
- data/lib/selenium/webdriver/android/bridge.rb +47 -0
- data/lib/selenium/webdriver/chrome.rb +26 -0
- data/lib/selenium/webdriver/chrome/bridge.rb +120 -0
- data/lib/selenium/webdriver/chrome/profile.rb +90 -0
- data/lib/selenium/webdriver/chrome/service.rb +75 -0
- data/lib/selenium/webdriver/common.rb +44 -0
- data/lib/selenium/webdriver/common/action_builder.rb +352 -0
- data/lib/selenium/webdriver/common/alert.rb +30 -0
- data/lib/selenium/webdriver/common/bridge_helper.rb +67 -0
- data/lib/selenium/webdriver/common/core_ext/base64.rb +9 -0
- data/lib/selenium/webdriver/common/core_ext/dir.rb +42 -0
- data/lib/selenium/webdriver/common/core_ext/string.rb +5 -0
- data/lib/selenium/webdriver/common/driver.rb +301 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_browser_connection.rb +17 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_input_devices.rb +39 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +25 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +13 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +22 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +19 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +22 -0
- data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +45 -0
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +43 -0
- data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +46 -0
- data/lib/selenium/webdriver/common/element.rb +293 -0
- data/lib/selenium/webdriver/common/error.rb +207 -0
- data/lib/selenium/webdriver/common/file_reaper.rb +47 -0
- data/lib/selenium/webdriver/common/html5/local_storage.rb +42 -0
- data/lib/selenium/webdriver/common/html5/location.rb +0 -0
- data/lib/selenium/webdriver/common/html5/session_storage.rb +44 -0
- data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +42 -0
- data/lib/selenium/webdriver/common/json_helper.rb +34 -0
- data/lib/selenium/webdriver/common/keyboard.rb +55 -0
- data/lib/selenium/webdriver/common/keys.rb +109 -0
- data/lib/selenium/webdriver/common/log_entry.rb +29 -0
- data/lib/selenium/webdriver/common/logs.rb +23 -0
- data/lib/selenium/webdriver/common/mouse.rb +72 -0
- data/lib/selenium/webdriver/common/navigation.rb +43 -0
- data/lib/selenium/webdriver/common/options.rb +136 -0
- data/lib/selenium/webdriver/common/platform.rb +218 -0
- data/lib/selenium/webdriver/common/port_prober.rb +42 -0
- data/lib/selenium/webdriver/common/profile_helper.rb +67 -0
- data/lib/selenium/webdriver/common/proxy.rb +149 -0
- data/lib/selenium/webdriver/common/search_context.rb +92 -0
- data/lib/selenium/webdriver/common/socket_poller.rb +105 -0
- data/lib/selenium/webdriver/common/target_locator.rb +81 -0
- data/lib/selenium/webdriver/common/timeouts.rb +38 -0
- data/lib/selenium/webdriver/common/touch_action_builder.rb +64 -0
- data/lib/selenium/webdriver/common/touch_screen.rb +105 -0
- data/lib/selenium/webdriver/common/wait.rb +63 -0
- data/lib/selenium/webdriver/common/window.rb +104 -0
- data/lib/selenium/webdriver/common/zipper.rb +82 -0
- data/lib/selenium/webdriver/firefox.rb +37 -0
- data/lib/selenium/webdriver/firefox/binary.rb +158 -0
- data/lib/selenium/webdriver/firefox/bridge.rb +70 -0
- data/lib/selenium/webdriver/firefox/extension.rb +52 -0
- data/lib/selenium/webdriver/firefox/launcher.rb +106 -0
- data/lib/selenium/webdriver/firefox/profile.rb +263 -0
- data/lib/selenium/webdriver/firefox/profiles_ini.rb +62 -0
- data/lib/selenium/webdriver/firefox/socket_lock.rb +61 -0
- data/lib/selenium/webdriver/firefox/util.rb +29 -0
- data/lib/selenium/webdriver/ie.rb +19 -0
- data/lib/selenium/webdriver/ie/bridge.rb +68 -0
- data/lib/selenium/webdriver/ie/server.rb +86 -0
- data/lib/selenium/webdriver/iphone.rb +9 -0
- data/lib/selenium/webdriver/iphone/bridge.rb +45 -0
- data/lib/selenium/webdriver/opera.rb +24 -0
- data/lib/selenium/webdriver/opera/bridge.rb +112 -0
- data/lib/selenium/webdriver/opera/service.rb +49 -0
- data/lib/selenium/webdriver/phantomjs.rb +22 -0
- data/lib/selenium/webdriver/phantomjs/bridge.rb +59 -0
- data/lib/selenium/webdriver/phantomjs/service.rb +90 -0
- data/lib/selenium/webdriver/remote.rb +22 -0
- data/lib/selenium/webdriver/remote/bridge.rb +644 -0
- data/lib/selenium/webdriver/remote/capabilities.rb +267 -0
- data/lib/selenium/webdriver/remote/commands.rb +193 -0
- data/lib/selenium/webdriver/remote/http/common.rb +74 -0
- data/lib/selenium/webdriver/remote/http/curb.rb +79 -0
- data/lib/selenium/webdriver/remote/http/default.rb +139 -0
- data/lib/selenium/webdriver/remote/http/persistent.rb +38 -0
- data/lib/selenium/webdriver/remote/response.rb +97 -0
- data/lib/selenium/webdriver/remote/server_error.rb +17 -0
- data/lib/selenium/webdriver/safari.rb +46 -0
- data/lib/selenium/webdriver/safari/bridge.rb +110 -0
- data/lib/selenium/webdriver/safari/browser.rb +20 -0
- data/lib/selenium/webdriver/safari/extension.rb +120 -0
- data/lib/selenium/webdriver/safari/server.rb +145 -0
- data/lib/selenium/webdriver/support.rb +5 -0
- data/lib/selenium/webdriver/support/abstract_event_listener.rb +28 -0
- data/lib/selenium/webdriver/support/block_event_listener.rb +17 -0
- data/lib/selenium/webdriver/support/color.rb +110 -0
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +112 -0
- data/lib/selenium/webdriver/support/select.rb +293 -0
- data/ruby.iml +13 -0
- data/spec/integration/selenium/client/api/backward_compatible_api_spec.rb +22 -0
- data/spec/integration/selenium/client/api/browser_xpath_library_spec.rb +17 -0
- data/spec/integration/selenium/client/api/click_spec.rb +39 -0
- data/spec/integration/selenium/client/api/cookie_spec.rb +39 -0
- data/spec/integration/selenium/client/api/element_spec.rb +14 -0
- data/spec/integration/selenium/client/api/highlight_located_element_spec.rb +19 -0
- data/spec/integration/selenium/client/api/retrieve_last_remote_control_logs_spec.rb +33 -0
- data/spec/integration/selenium/client/api/screenshot_spec.rb +31 -0
- data/spec/integration/selenium/client/api/select_window_spec.rb +46 -0
- data/spec/integration/selenium/client/api/start_stop_spec.rb +9 -0
- data/spec/integration/selenium/client/api/wait_for_ajax_spec.rb +27 -0
- data/spec/integration/selenium/client/api/wait_for_element_spec.rb +56 -0
- data/spec/integration/selenium/client/api/wait_for_field_value_spec.rb +52 -0
- data/spec/integration/selenium/client/api/wait_for_text_spec.rb +98 -0
- data/spec/integration/selenium/client/api/webdriver_backed_spec.rb +21 -0
- data/spec/integration/selenium/client/sample-app/public/jquery-1.3.2.js +4376 -0
- data/spec/integration/selenium/client/sample-app/public/jquery.html +55 -0
- data/spec/integration/selenium/client/sample-app/public/prototype-1.6.0.3.js +4320 -0
- data/spec/integration/selenium/client/sample-app/public/prototype.html +59 -0
- data/spec/integration/selenium/client/sample-app/sample_app.rb +32 -0
- data/spec/integration/selenium/client/spec_helper.rb +139 -0
- data/spec/integration/selenium/webdriver/app_cache_spec.rb +47 -0
- data/spec/integration/selenium/webdriver/browser_connection_spec.rb +20 -0
- data/spec/integration/selenium/webdriver/chrome/driver_spec.rb +28 -0
- data/spec/integration/selenium/webdriver/chrome/profile_spec.rb +63 -0
- data/spec/integration/selenium/webdriver/driver_spec.rb +266 -0
- data/spec/integration/selenium/webdriver/element_spec.rb +191 -0
- data/spec/integration/selenium/webdriver/error_spec.rb +30 -0
- data/spec/integration/selenium/webdriver/firefox/driver_spec.rb +21 -0
- data/spec/integration/selenium/webdriver/firefox/profile_spec.rb +141 -0
- data/spec/integration/selenium/webdriver/keyboard_spec.rb +57 -0
- data/spec/integration/selenium/webdriver/location_spec.rb +29 -0
- data/spec/integration/selenium/webdriver/mouse_spec.rb +57 -0
- data/spec/integration/selenium/webdriver/navigation_spec.rb +46 -0
- data/spec/integration/selenium/webdriver/opera/driver_spec.rb +47 -0
- data/spec/integration/selenium/webdriver/options_spec.rb +77 -0
- data/spec/integration/selenium/webdriver/remote/driver_spec.rb +19 -0
- data/spec/integration/selenium/webdriver/remote/element_spec.rb +26 -0
- data/spec/integration/selenium/webdriver/spec_helper.rb +36 -0
- data/spec/integration/selenium/webdriver/spec_support.rb +12 -0
- data/spec/integration/selenium/webdriver/spec_support/guards.rb +110 -0
- data/spec/integration/selenium/webdriver/spec_support/helpers.rb +51 -0
- data/spec/integration/selenium/webdriver/spec_support/rack_server.rb +123 -0
- data/spec/integration/selenium/webdriver/spec_support/test_environment.rb +239 -0
- data/spec/integration/selenium/webdriver/sql_database_spec.rb +59 -0
- data/spec/integration/selenium/webdriver/storage_spec.rb +96 -0
- data/spec/integration/selenium/webdriver/target_locator_spec.rb +186 -0
- data/spec/integration/selenium/webdriver/timeout_spec.rb +69 -0
- data/spec/integration/selenium/webdriver/touch_spec.rb +176 -0
- data/spec/integration/selenium/webdriver/window_spec.rb +70 -0
- data/spec/integration/selenium/webdriver/zipper_spec.rb +66 -0
- data/spec/unit/selenium/client/base_spec.rb +239 -0
- data/spec/unit/selenium/client/extensions_spec.rb +174 -0
- data/spec/unit/selenium/client/idiomatic_spec.rb +500 -0
- data/spec/unit/selenium/client/javascript_expression_builder_spec.rb +79 -0
- data/spec/unit/selenium/client/javascript_frameworks/jquery_spec.rb +10 -0
- data/spec/unit/selenium/client/javascript_frameworks/prototype_spec.rb +10 -0
- data/spec/unit/selenium/client/protocol_spec.rb +124 -0
- data/spec/unit/selenium/client/selenium_helper_spec.rb +56 -0
- data/spec/unit/selenium/client/spec_helper.rb +24 -0
- data/spec/unit/selenium/rake/task_spec.rb +79 -0
- data/spec/unit/selenium/server_spec.rb +150 -0
- data/spec/unit/selenium/webdriver/action_builder_spec.rb +97 -0
- data/spec/unit/selenium/webdriver/android/bridge_spec.rb +43 -0
- data/spec/unit/selenium/webdriver/chrome/bridge_spec.rb +137 -0
- data/spec/unit/selenium/webdriver/chrome/profile_spec.rb +57 -0
- data/spec/unit/selenium/webdriver/chrome/service_spec.rb +44 -0
- data/spec/unit/selenium/webdriver/error_spec.rb +41 -0
- data/spec/unit/selenium/webdriver/firefox/bridge_spec.rb +47 -0
- data/spec/unit/selenium/webdriver/ie/bridge_spec.rb +91 -0
- data/spec/unit/selenium/webdriver/iphone/bridge_spec.rb +42 -0
- data/spec/unit/selenium/webdriver/log_entry_spec.rb +11 -0
- data/spec/unit/selenium/webdriver/opera/bridge_spec.rb +44 -0
- data/spec/unit/selenium/webdriver/phantomjs/bridge_spec.rb +55 -0
- data/spec/unit/selenium/webdriver/proxy_spec.rb +106 -0
- data/spec/unit/selenium/webdriver/remote/bridge_spec.rb +16 -0
- data/spec/unit/selenium/webdriver/remote/capabilities_spec.rb +115 -0
- data/spec/unit/selenium/webdriver/remote/http/common_spec.rb +24 -0
- data/spec/unit/selenium/webdriver/remote/http/default_spec.rb +124 -0
- data/spec/unit/selenium/webdriver/search_context_spec.rb +61 -0
- data/spec/unit/selenium/webdriver/socket_poller_spec.rb +68 -0
- data/spec/unit/selenium/webdriver/spec_helper.rb +27 -0
- data/spec/unit/selenium/webdriver/support/color_spec.rb +119 -0
- data/spec/unit/selenium/webdriver/support/event_firing_spec.rb +111 -0
- data/spec/unit/selenium/webdriver/support/select_spec.rb +290 -0
- data/spec/unit/selenium/webdriver/wait_spec.rb +49 -0
- metadata +370 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Selenium
|
|
2
|
+
module WebDriver
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# @api private
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
module DriverExtensions
|
|
9
|
+
module HasSessionId
|
|
10
|
+
|
|
11
|
+
#
|
|
12
|
+
# @return [String] the session id
|
|
13
|
+
# @api public
|
|
14
|
+
#
|
|
15
|
+
|
|
16
|
+
def session_id
|
|
17
|
+
@bridge.session_id
|
|
18
|
+
end
|
|
19
|
+
end # HasSessionId
|
|
20
|
+
end # DriverExtensions
|
|
21
|
+
end # WebDriver
|
|
22
|
+
end # Selenium
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Selenium
|
|
2
|
+
module WebDriver
|
|
3
|
+
module DriverExtensions
|
|
4
|
+
|
|
5
|
+
module HasTouchScreen
|
|
6
|
+
def touch
|
|
7
|
+
TouchActionBuilder.new mouse, keyboard, touch_screen
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
def touch_screen
|
|
13
|
+
TouchScreen.new @bridge
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Selenium
|
|
2
|
+
module WebDriver
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# @api private
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
module DriverExtensions
|
|
9
|
+
module HasWebStorage
|
|
10
|
+
|
|
11
|
+
def local_storage
|
|
12
|
+
HTML5::LocalStorage.new @bridge
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def session_storage
|
|
16
|
+
HTML5::SessionStorage.new @bridge
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end # HasWebStorage
|
|
20
|
+
end # DriverExtensions
|
|
21
|
+
end # WebDriver
|
|
22
|
+
end # Selenium
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module Selenium
|
|
2
|
+
module WebDriver
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# @api private
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
module DriverExtensions
|
|
9
|
+
module Rotatable
|
|
10
|
+
|
|
11
|
+
ORIENTATIONS = [:landscape, :portrait]
|
|
12
|
+
|
|
13
|
+
#
|
|
14
|
+
# Change the screen orientation
|
|
15
|
+
#
|
|
16
|
+
# @param [:landscape, :portrait] Orientation
|
|
17
|
+
#
|
|
18
|
+
# @api public
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
def rotation=(orientation)
|
|
22
|
+
unless ORIENTATIONS.include?(orientation)
|
|
23
|
+
raise ArgumentError, "expected #{ORIENTATIONS.inspect}, got #{orientation.inspect}"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
bridge.setScreenOrientation(orientation.to_s.upcase)
|
|
27
|
+
end
|
|
28
|
+
alias_method :rotate, :rotation=
|
|
29
|
+
|
|
30
|
+
#
|
|
31
|
+
# Get the current screen orientation
|
|
32
|
+
#
|
|
33
|
+
# @return [:landscape, :portrait] orientation
|
|
34
|
+
#
|
|
35
|
+
# @api public
|
|
36
|
+
#
|
|
37
|
+
|
|
38
|
+
def orientation
|
|
39
|
+
bridge.getScreenOrientation.to_sym.downcase
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end # Rotatable
|
|
43
|
+
end # DriverExtensions
|
|
44
|
+
end # WebDriver
|
|
45
|
+
end # Selenium
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module Selenium
|
|
2
|
+
module WebDriver
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# @api private
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
module DriverExtensions
|
|
9
|
+
module TakesScreenshot
|
|
10
|
+
|
|
11
|
+
#
|
|
12
|
+
# Save a PNG screenshot to the given path
|
|
13
|
+
#
|
|
14
|
+
# @api public
|
|
15
|
+
#
|
|
16
|
+
|
|
17
|
+
def save_screenshot(png_path)
|
|
18
|
+
File.open(png_path, 'wb') { |f| f << screenshot_as(:png) }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
#
|
|
22
|
+
# Return a PNG screenshot in the given format as a string
|
|
23
|
+
#
|
|
24
|
+
# @param [:base64, :png] format
|
|
25
|
+
# @return String screenshot
|
|
26
|
+
#
|
|
27
|
+
# @api public
|
|
28
|
+
|
|
29
|
+
def screenshot_as(format)
|
|
30
|
+
case format
|
|
31
|
+
when :base64
|
|
32
|
+
bridge.getScreenshot
|
|
33
|
+
when :png
|
|
34
|
+
bridge.getScreenshot.unpack("m")[0]
|
|
35
|
+
else
|
|
36
|
+
raise Error::UnsupportedOperationError, "unsupported format: #{format.inspect}"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end # TakesScreenshot
|
|
41
|
+
end # DriverExtensions
|
|
42
|
+
end # WebDriver
|
|
43
|
+
end # Selenium
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
module Selenium
|
|
2
|
+
module WebDriver
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# @api private
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
module DriverExtensions
|
|
9
|
+
module UploadsFiles
|
|
10
|
+
|
|
11
|
+
#
|
|
12
|
+
# Set the file detector to pass local files to a remote WebDriver.
|
|
13
|
+
#
|
|
14
|
+
# The detector is an object that responds to #call, and when called
|
|
15
|
+
# will determine if the given string represents a file. If it does,
|
|
16
|
+
# the path to the file on the local file system should be returned,
|
|
17
|
+
# otherwise nil or false.
|
|
18
|
+
#
|
|
19
|
+
# Example:
|
|
20
|
+
#
|
|
21
|
+
# driver = Selenium::WebDriver.for :remote
|
|
22
|
+
# driver.file_detector = lambda do |args|
|
|
23
|
+
# # args => ["/path/to/file"]
|
|
24
|
+
# str = args.first.to_s
|
|
25
|
+
# str if File.exist?(str)
|
|
26
|
+
# end
|
|
27
|
+
#
|
|
28
|
+
# driver.find_element(:id => "upload").send_keys "/path/to/file"
|
|
29
|
+
#
|
|
30
|
+
# By default, no file detection is performed.
|
|
31
|
+
#
|
|
32
|
+
# @api public
|
|
33
|
+
#
|
|
34
|
+
|
|
35
|
+
def file_detector=(detector)
|
|
36
|
+
unless detector.nil? or detector.respond_to? :call
|
|
37
|
+
raise ArgumentError, "detector must respond to #call"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
bridge.file_detector = detector
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end # UploadsFiles
|
|
44
|
+
end # DriverExtensions
|
|
45
|
+
end # WebDriver
|
|
46
|
+
end # Selenium
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
module Selenium
|
|
2
|
+
module WebDriver
|
|
3
|
+
class Element
|
|
4
|
+
include SearchContext
|
|
5
|
+
|
|
6
|
+
#
|
|
7
|
+
# Creates a new Element
|
|
8
|
+
#
|
|
9
|
+
# @api private
|
|
10
|
+
#
|
|
11
|
+
|
|
12
|
+
def initialize(bridge, id)
|
|
13
|
+
@bridge, @id = bridge, id
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def inspect
|
|
17
|
+
'#<%s:0x%x id=%s>' % [self.class, hash*2, @id.inspect]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def ==(other)
|
|
21
|
+
other.kind_of?(self.class) && bridge.elementEquals(self, other)
|
|
22
|
+
end
|
|
23
|
+
alias_method :eql?, :==
|
|
24
|
+
|
|
25
|
+
def hash
|
|
26
|
+
@id.hash ^ @bridge.hash
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
#
|
|
30
|
+
# Click this element. If this causes a new page to load, this method will
|
|
31
|
+
# attempt to block until the page has loaded. At this point, you should
|
|
32
|
+
# discard all references to this element and any further operations
|
|
33
|
+
# performed on this element will raise a StaleElementReferenceError
|
|
34
|
+
# unless you know that the element and the page will still be present. If
|
|
35
|
+
# click() causes a new page to be loaded via an event or is done by
|
|
36
|
+
# sending a native event then the method will *not* wait for it to be
|
|
37
|
+
# loaded and the caller should verify that a new page has been loaded.
|
|
38
|
+
#
|
|
39
|
+
# There are some preconditions for an element to be clicked. The element
|
|
40
|
+
# must be visible and it must have a height and width greater then 0.
|
|
41
|
+
#
|
|
42
|
+
# Equivalent to:
|
|
43
|
+
# driver.action.click(element)
|
|
44
|
+
#
|
|
45
|
+
# @example Click on a button
|
|
46
|
+
#
|
|
47
|
+
# driver.find_element(:tag_name, "button").click
|
|
48
|
+
#
|
|
49
|
+
# @raise [StaleElementReferenceError] if the element no longer exists as
|
|
50
|
+
# defined
|
|
51
|
+
#
|
|
52
|
+
|
|
53
|
+
def click
|
|
54
|
+
bridge.clickElement @id
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
#
|
|
58
|
+
# Get the tag name of the element.
|
|
59
|
+
#
|
|
60
|
+
# @example Get the tagname of an INPUT element(returns "input")
|
|
61
|
+
#
|
|
62
|
+
# driver.find_element(:xpath, "//input").tag_name
|
|
63
|
+
#
|
|
64
|
+
# @return [String] The tag name of this element.
|
|
65
|
+
#
|
|
66
|
+
|
|
67
|
+
def tag_name
|
|
68
|
+
bridge.getElementTagName @id
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
#
|
|
72
|
+
# Get the value of a the given attribute of the element. Will return the current value, even if
|
|
73
|
+
# this has been modified after the page has been loaded. More exactly, this method will return
|
|
74
|
+
# the value of the given attribute, unless that attribute is not present, in which case the
|
|
75
|
+
# value of the property with the same name is returned. If neither value is set, nil is
|
|
76
|
+
# returned. The "style" attribute is converted as best can be to a text representation with a
|
|
77
|
+
# trailing semi-colon. The following are deemed to be "boolean" attributes, and will
|
|
78
|
+
# return either "true" or "false":
|
|
79
|
+
#
|
|
80
|
+
# async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked,
|
|
81
|
+
# defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate,
|
|
82
|
+
# iscontenteditable, ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, novalidate,
|
|
83
|
+
# nowrap, open, paused, pubdate, readonly, required, reversed, scoped, seamless, seeking,
|
|
84
|
+
# selected, spellcheck, truespeed, willvalidate
|
|
85
|
+
#
|
|
86
|
+
# Finally, the following commonly mis-capitalized attribute/property names are evaluated as
|
|
87
|
+
# expected:
|
|
88
|
+
#
|
|
89
|
+
# class, readonly
|
|
90
|
+
#
|
|
91
|
+
# @param [String]
|
|
92
|
+
# attribute name
|
|
93
|
+
# @return [String,nil]
|
|
94
|
+
# attribute value
|
|
95
|
+
#
|
|
96
|
+
|
|
97
|
+
def attribute(name)
|
|
98
|
+
bridge.getElementAttribute @id, name
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
#
|
|
102
|
+
# Get the text content of this element
|
|
103
|
+
#
|
|
104
|
+
# @return [String]
|
|
105
|
+
#
|
|
106
|
+
|
|
107
|
+
def text
|
|
108
|
+
bridge.getElementText @id
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
#
|
|
112
|
+
# Send keystrokes to this element
|
|
113
|
+
#
|
|
114
|
+
# @param [String, Symbol, Array]
|
|
115
|
+
#
|
|
116
|
+
# Examples:
|
|
117
|
+
#
|
|
118
|
+
# element.send_keys "foo" #=> value: 'foo'
|
|
119
|
+
# element.send_keys "tet", :arrow_left, "s" #=> value: 'test'
|
|
120
|
+
# element.send_keys [:control, 'a'], :space #=> value: ' '
|
|
121
|
+
#
|
|
122
|
+
# @see Keys::KEYS
|
|
123
|
+
#
|
|
124
|
+
|
|
125
|
+
def send_keys(*args)
|
|
126
|
+
bridge.sendKeysToElement @id, Keys.encode(args)
|
|
127
|
+
end
|
|
128
|
+
alias_method :send_key, :send_keys
|
|
129
|
+
|
|
130
|
+
#
|
|
131
|
+
# If this element is a text entry element, this will clear the value. Has no effect on other
|
|
132
|
+
# elements. Text entry elements are INPUT and TEXTAREA elements.
|
|
133
|
+
#
|
|
134
|
+
# Note that the events fired by this event may not be as you'd expect. In particular, we don't
|
|
135
|
+
# fire any keyboard or mouse events. If you want to ensure keyboard events are
|
|
136
|
+
# fired, consider using #send_keys with the backspace key. To ensure you get a change event,
|
|
137
|
+
# consider following with a call to #send_keys with the tab key.
|
|
138
|
+
#
|
|
139
|
+
|
|
140
|
+
def clear
|
|
141
|
+
bridge.clearElement @id
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
#
|
|
145
|
+
# Is the element enabled?
|
|
146
|
+
#
|
|
147
|
+
# @return [Boolean]
|
|
148
|
+
#
|
|
149
|
+
|
|
150
|
+
def enabled?
|
|
151
|
+
bridge.isElementEnabled @id
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
#
|
|
155
|
+
# Is the element selected?
|
|
156
|
+
#
|
|
157
|
+
# @return [Boolean]
|
|
158
|
+
#
|
|
159
|
+
|
|
160
|
+
def selected?
|
|
161
|
+
bridge.isElementSelected @id
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
#
|
|
165
|
+
# Is the element displayed?
|
|
166
|
+
#
|
|
167
|
+
# @return [Boolean]
|
|
168
|
+
#
|
|
169
|
+
|
|
170
|
+
def displayed?
|
|
171
|
+
bridge.isElementDisplayed @id
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
#
|
|
175
|
+
# Submit this element
|
|
176
|
+
#
|
|
177
|
+
|
|
178
|
+
def submit
|
|
179
|
+
bridge.submitElement @id
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
#
|
|
183
|
+
# Get the value of the given CSS property
|
|
184
|
+
#
|
|
185
|
+
# Note that shorthand CSS properties (e.g. background, font, border, border-top, margin,
|
|
186
|
+
# margin-top, padding, padding-top, list-style, outline, pause, cue) are not returned,
|
|
187
|
+
# in accordance with the DOM CSS2 specification - you should directly access the longhand
|
|
188
|
+
# properties (e.g. background-color) to access the desired values.
|
|
189
|
+
#
|
|
190
|
+
# @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration
|
|
191
|
+
#
|
|
192
|
+
|
|
193
|
+
def css_value(prop)
|
|
194
|
+
bridge.getElementValueOfCssProperty @id, prop
|
|
195
|
+
end
|
|
196
|
+
alias_method :style, :css_value
|
|
197
|
+
|
|
198
|
+
#
|
|
199
|
+
# Get the location of this element.
|
|
200
|
+
#
|
|
201
|
+
# @return [WebDriver::Point]
|
|
202
|
+
#
|
|
203
|
+
|
|
204
|
+
def location
|
|
205
|
+
bridge.getElementLocation @id
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
#
|
|
209
|
+
# Determine an element's location on the screen once it has been scrolled into view.
|
|
210
|
+
#
|
|
211
|
+
# @return [WebDriver::Point]
|
|
212
|
+
#
|
|
213
|
+
|
|
214
|
+
def location_once_scrolled_into_view
|
|
215
|
+
bridge.getElementLocationOnceScrolledIntoView @id
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
#
|
|
219
|
+
# Get the size of this element
|
|
220
|
+
#
|
|
221
|
+
# @return [WebDriver::Dimension]
|
|
222
|
+
#
|
|
223
|
+
|
|
224
|
+
def size
|
|
225
|
+
bridge.getElementSize @id
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
#-------------------------------- sugar --------------------------------
|
|
229
|
+
|
|
230
|
+
#
|
|
231
|
+
# element.first(:id, 'foo')
|
|
232
|
+
#
|
|
233
|
+
|
|
234
|
+
alias_method :first, :find_element
|
|
235
|
+
|
|
236
|
+
#
|
|
237
|
+
# element.all(:class, 'bar')
|
|
238
|
+
#
|
|
239
|
+
|
|
240
|
+
alias_method :all, :find_elements
|
|
241
|
+
|
|
242
|
+
#
|
|
243
|
+
# element['class'] or element[:class] #=> "someclass"
|
|
244
|
+
#
|
|
245
|
+
alias_method :[], :attribute
|
|
246
|
+
|
|
247
|
+
#
|
|
248
|
+
# for SearchContext and execute_script
|
|
249
|
+
#
|
|
250
|
+
# @api private
|
|
251
|
+
#
|
|
252
|
+
|
|
253
|
+
def ref
|
|
254
|
+
@id
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
#
|
|
258
|
+
# Convert to a WebElement JSON Object for transmission over the wire.
|
|
259
|
+
# @see http://code.google.com/p/selenium/wiki/JsonWireProtocol#Basic_Concepts_And_Terms
|
|
260
|
+
#
|
|
261
|
+
# @api private
|
|
262
|
+
#
|
|
263
|
+
|
|
264
|
+
def to_json(*args)
|
|
265
|
+
WebDriver.json_dump as_json
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
#
|
|
269
|
+
# For Rails 3 - http://jonathanjulian.com/2010/04/rails-to_json-or-as_json/
|
|
270
|
+
#
|
|
271
|
+
# @api private
|
|
272
|
+
#
|
|
273
|
+
|
|
274
|
+
def as_json(opts = nil)
|
|
275
|
+
{ :ELEMENT => @id }
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
private
|
|
279
|
+
|
|
280
|
+
def bridge
|
|
281
|
+
@bridge
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
def selectable?
|
|
285
|
+
tn = tag_name.downcase
|
|
286
|
+
type = attribute(:type).to_s.downcase
|
|
287
|
+
|
|
288
|
+
tn == "option" || (tn == "input" && %w[radio checkbox].include?(type))
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
end # Element
|
|
292
|
+
end # WebDriver
|
|
293
|
+
end # Selenium
|