selenium-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.
- data/chrome/prebuilt/Win32/Release/npchromedriver.dll +0 -0
- data/chrome/prebuilt/x64/Release/npchromedriver.dll +0 -0
- data/chrome/src/extension/background.html +9 -0
- data/chrome/src/extension/background.js +933 -0
- data/chrome/src/extension/content_script.js +1286 -0
- data/chrome/src/extension/manifest-nonwin.json +15 -0
- data/chrome/src/extension/manifest-win.json +16 -0
- data/chrome/src/extension/toolstrip.html +28 -0
- data/chrome/src/extension/utils.js +196 -0
- data/chrome/src/rb/lib/selenium/webdriver/chrome.rb +8 -0
- data/chrome/src/rb/lib/selenium/webdriver/chrome/bridge.rb +324 -0
- data/chrome/src/rb/lib/selenium/webdriver/chrome/command_executor.rb +70 -0
- data/chrome/src/rb/lib/selenium/webdriver/chrome/launcher.rb +119 -0
- data/common/src/js/abstractcommandprocessor.js +161 -0
- data/common/src/js/asserts.js +296 -0
- data/common/src/js/by.js +147 -0
- data/common/src/js/command.js +274 -0
- data/common/src/js/context.js +58 -0
- data/common/src/js/extension/README +2 -0
- data/common/src/js/extension/dommessenger.js +152 -0
- data/common/src/js/factory.js +55 -0
- data/common/src/js/future.js +118 -0
- data/common/src/js/key.js +117 -0
- data/common/src/js/localcommandprocessor.js +181 -0
- data/common/src/js/logging.js +249 -0
- data/common/src/js/testrunner.js +605 -0
- data/common/src/js/timing.js +89 -0
- data/common/src/js/wait.js +199 -0
- data/common/src/js/webdriver.js +853 -0
- data/common/src/js/webelement.js +683 -0
- data/common/src/rb/lib/selenium-webdriver.rb +1 -0
- data/common/src/rb/lib/selenium/webdriver.rb +52 -0
- data/common/src/rb/lib/selenium/webdriver/bridge_helper.rb +88 -0
- data/common/src/rb/lib/selenium/webdriver/child_process.rb +85 -0
- data/common/src/rb/lib/selenium/webdriver/core_ext/dir.rb +41 -0
- data/common/src/rb/lib/selenium/webdriver/driver.rb +128 -0
- data/common/src/rb/lib/selenium/webdriver/element.rb +126 -0
- data/common/src/rb/lib/selenium/webdriver/error.rb +68 -0
- data/common/src/rb/lib/selenium/webdriver/find.rb +69 -0
- data/common/src/rb/lib/selenium/webdriver/navigation.rb +23 -0
- data/common/src/rb/lib/selenium/webdriver/options.rb +50 -0
- data/common/src/rb/lib/selenium/webdriver/platform.rb +82 -0
- data/common/src/rb/lib/selenium/webdriver/target_locator.rb +23 -0
- data/firefox/prebuilt/nsICommandProcessor.xpt +0 -0
- data/firefox/prebuilt/nsINativeEvents.xpt +0 -0
- data/firefox/prebuilt/nsIResponseHandler.xpt +0 -0
- data/firefox/src/extension/chrome.manifest +3 -0
- data/firefox/src/extension/components/context.js +37 -0
- data/firefox/src/extension/components/driver-component.js +127 -0
- data/firefox/src/extension/components/firefoxDriver.js +706 -0
- data/firefox/src/extension/components/json2.js +273 -0
- data/firefox/src/extension/components/keytest.html +554 -0
- data/firefox/src/extension/components/nsCommandProcessor.js +586 -0
- data/firefox/src/extension/components/screenshooter.js +70 -0
- data/firefox/src/extension/components/socketListener.js +185 -0
- data/firefox/src/extension/components/utils.js +1200 -0
- data/firefox/src/extension/components/webLoadingListener.js +57 -0
- data/firefox/src/extension/components/webdriverserver.js +101 -0
- data/firefox/src/extension/components/wrappedElement.js +609 -0
- data/firefox/src/extension/content/fxdriver.xul +30 -0
- data/firefox/src/extension/content/server.js +95 -0
- data/firefox/src/extension/idl/nsICommandProcessor.idl +38 -0
- data/firefox/src/extension/idl/nsIResponseHandler.idl +34 -0
- data/firefox/src/extension/install.rdf +29 -0
- data/firefox/src/rb/lib/selenium/webdriver/firefox.rb +21 -0
- data/firefox/src/rb/lib/selenium/webdriver/firefox/binary.rb +86 -0
- data/firefox/src/rb/lib/selenium/webdriver/firefox/bridge.rb +426 -0
- data/firefox/src/rb/lib/selenium/webdriver/firefox/extension_connection.rb +82 -0
- data/firefox/src/rb/lib/selenium/webdriver/firefox/launcher.rb +132 -0
- data/firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb +174 -0
- data/firefox/src/rb/lib/selenium/webdriver/firefox/profiles_ini.rb +60 -0
- data/firefox/src/rb/lib/selenium/webdriver/firefox/util.rb +23 -0
- data/jobbie/prebuilt/Win32/Release/InternetExplorerDriver.dll +0 -0
- data/jobbie/prebuilt/x64/Release/InternetExplorerDriver.dll +0 -0
- data/jobbie/src/rb/lib/selenium/webdriver/ie.rb +14 -0
- data/jobbie/src/rb/lib/selenium/webdriver/ie/bridge.rb +552 -0
- data/jobbie/src/rb/lib/selenium/webdriver/ie/lib.rb +94 -0
- data/jobbie/src/rb/lib/selenium/webdriver/ie/util.rb +147 -0
- data/remote/client/src/rb/lib/selenium/webdriver/remote.rb +16 -0
- data/remote/client/src/rb/lib/selenium/webdriver/remote/bridge.rb +374 -0
- data/remote/client/src/rb/lib/selenium/webdriver/remote/capabilities.rb +105 -0
- data/remote/client/src/rb/lib/selenium/webdriver/remote/commands.rb +53 -0
- data/remote/client/src/rb/lib/selenium/webdriver/remote/default_http_client.rb +71 -0
- data/remote/client/src/rb/lib/selenium/webdriver/remote/response.rb +43 -0
- data/remote/client/src/rb/lib/selenium/webdriver/remote/server_error.rb +32 -0
- metadata +182 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "selenium/webdriver"
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require "tmpdir"
|
|
2
|
+
require "fileutils"
|
|
3
|
+
|
|
4
|
+
require "selenium/webdriver/core_ext/dir"
|
|
5
|
+
require "selenium/webdriver/error"
|
|
6
|
+
require "selenium/webdriver/platform"
|
|
7
|
+
require "selenium/webdriver/child_process"
|
|
8
|
+
require "selenium/webdriver/target_locator"
|
|
9
|
+
require "selenium/webdriver/navigation"
|
|
10
|
+
require "selenium/webdriver/options"
|
|
11
|
+
require "selenium/webdriver/find"
|
|
12
|
+
require "selenium/webdriver/bridge_helper"
|
|
13
|
+
require "selenium/webdriver/driver"
|
|
14
|
+
require "selenium/webdriver/element"
|
|
15
|
+
|
|
16
|
+
begin
|
|
17
|
+
require "json" # gem dependency
|
|
18
|
+
rescue LoadError => e
|
|
19
|
+
msg = Selenium::WebDriver::Platform.jruby? ? "jruby -S gem install json-jruby" : "gem install json"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
raise LoadError, <<-END
|
|
23
|
+
#{e.message}
|
|
24
|
+
|
|
25
|
+
You need to install the json gem or (require rubygems):
|
|
26
|
+
#{msg}
|
|
27
|
+
END
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
module Selenium
|
|
32
|
+
module WebDriver
|
|
33
|
+
Point = Struct.new(:x, :y)
|
|
34
|
+
Dimension = Struct.new(:width, :heigth)
|
|
35
|
+
|
|
36
|
+
autoload :IE, 'selenium/webdriver/ie'
|
|
37
|
+
autoload :Remote, 'selenium/webdriver/remote'
|
|
38
|
+
autoload :Chrome, 'selenium/webdriver/chrome'
|
|
39
|
+
autoload :Firefox, 'selenium/webdriver/firefox'
|
|
40
|
+
|
|
41
|
+
def self.root
|
|
42
|
+
@root ||= File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "..", ".."))
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def self.for(*args)
|
|
46
|
+
WebDriver::Driver.for(*args)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end # WebDriver
|
|
50
|
+
end # Selenium
|
|
51
|
+
|
|
52
|
+
Thread.abort_on_exception = true
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
module Selenium
|
|
2
|
+
module WebDriver
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# Shared across bridges
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
module BridgeHelper
|
|
9
|
+
|
|
10
|
+
def wrap_script_argument(arg)
|
|
11
|
+
case arg
|
|
12
|
+
when Integer, Float
|
|
13
|
+
{ :type => "NUMBER", :value => arg }
|
|
14
|
+
when TrueClass, FalseClass, NilClass
|
|
15
|
+
{ :type => "BOOLEAN", :value => !!arg }
|
|
16
|
+
when Element
|
|
17
|
+
{ :type => "ELEMENT", :value => arg.ref }
|
|
18
|
+
when String
|
|
19
|
+
{ :type => "STRING", :value => arg.to_s }
|
|
20
|
+
when Array # Enumerable?
|
|
21
|
+
arg.map { |e| wrap_script_argument(e) }
|
|
22
|
+
else
|
|
23
|
+
raise TypeError, "Parameter is not of recognized type: #{arg.inspect}:#{arg.class}"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def unwrap_script_argument(arg)
|
|
28
|
+
if arg.kind_of?(Array)
|
|
29
|
+
arg.map { |e| unwrap_script_argument(e) }
|
|
30
|
+
else
|
|
31
|
+
case arg["type"]
|
|
32
|
+
when "NULL"
|
|
33
|
+
nil
|
|
34
|
+
when "ELEMENT"
|
|
35
|
+
Element.new self, element_id_from(arg["value"])
|
|
36
|
+
when "POINT"
|
|
37
|
+
Point.new arg['x'], arg['y']
|
|
38
|
+
when "DIMENSION"
|
|
39
|
+
Dimension.new arg['width'], arg['height']
|
|
40
|
+
when "COOKIE"
|
|
41
|
+
{:name => arg['name'], :value => arg['value']}
|
|
42
|
+
else
|
|
43
|
+
arg["value"]
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def element_id_from(arr)
|
|
49
|
+
arr.to_s.split("/").last
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def parse_cookie_string(str)
|
|
53
|
+
result = {
|
|
54
|
+
'name' => '',
|
|
55
|
+
'value' => '',
|
|
56
|
+
'domain' => '',
|
|
57
|
+
'path' => '',
|
|
58
|
+
'expires' => '',
|
|
59
|
+
'secure' => false
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
str.split(";").each do |attribute|
|
|
63
|
+
if attribute.include? "="
|
|
64
|
+
key, value = attribute.strip.split("=", 2)
|
|
65
|
+
if result['name'].empty?
|
|
66
|
+
result['name'] = key
|
|
67
|
+
result['value'] = value
|
|
68
|
+
elsif key == 'domain' && value.strip =~ /^\.(.+)/
|
|
69
|
+
result['domain'] = $1
|
|
70
|
+
elsif key && value
|
|
71
|
+
result[key] = value
|
|
72
|
+
end
|
|
73
|
+
elsif attribute == "secure"
|
|
74
|
+
result['secure'] = true
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
unless [nil, "", "0"].include?(result['expires'])
|
|
78
|
+
# firefox stores expiry as number of seconds
|
|
79
|
+
result['expires'] = Time.at(result['expires'].to_i)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
result
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
end # BridgeHelper
|
|
87
|
+
end # WebDriver
|
|
88
|
+
end # Selenium
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
module Selenium
|
|
2
|
+
module WebDriver
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# Cross platform child process launcher
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
class ChildProcess
|
|
9
|
+
def initialize(*args)
|
|
10
|
+
@args = args
|
|
11
|
+
|
|
12
|
+
if Platform.jruby?
|
|
13
|
+
extend JRubyProcess
|
|
14
|
+
elsif Platform.os == :windows
|
|
15
|
+
extend WindowsProcess
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def alive?
|
|
20
|
+
return false unless @pid
|
|
21
|
+
|
|
22
|
+
# TODO: check if this works on windows
|
|
23
|
+
Process.kill 0, @pid
|
|
24
|
+
true
|
|
25
|
+
rescue Errno::ESRCH
|
|
26
|
+
false
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def start
|
|
30
|
+
@pid = fork { exec(*@args) }
|
|
31
|
+
|
|
32
|
+
self
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def wait
|
|
36
|
+
raise "called wait with no pid" unless @pid
|
|
37
|
+
Process.waitpid @pid
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def kill
|
|
41
|
+
Process.kill("TERM", @pid) if @pid
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def kill!
|
|
45
|
+
Process.kill("KILL", @pid) if @pid
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
module WindowsProcess
|
|
49
|
+
def start
|
|
50
|
+
require "win32/process" # adds a dependency on windows
|
|
51
|
+
@pid = Process.create(:app_name => @args.join(" "),
|
|
52
|
+
:process_inherit => true,
|
|
53
|
+
:thread_inherit => true,
|
|
54
|
+
:inherit => true).process_id
|
|
55
|
+
|
|
56
|
+
self
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
module JRubyProcess
|
|
61
|
+
def start
|
|
62
|
+
pb = java.lang.ProcessBuilder.new(@args)
|
|
63
|
+
|
|
64
|
+
# this isn't good
|
|
65
|
+
env = pb.environment
|
|
66
|
+
ENV.each { |k,v| env.put(k, v) }
|
|
67
|
+
|
|
68
|
+
@process = pb.start
|
|
69
|
+
|
|
70
|
+
self
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def kill
|
|
74
|
+
@process.destroy if @process
|
|
75
|
+
end
|
|
76
|
+
alias_method :kill!, :kill
|
|
77
|
+
|
|
78
|
+
def wait
|
|
79
|
+
@process.waitFor
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
end # ChildProcess
|
|
84
|
+
end # WebDriver
|
|
85
|
+
end # Selenium
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
class Dir
|
|
2
|
+
def self.mktmpdir(prefix_suffix=nil, tmpdir=nil)
|
|
3
|
+
case prefix_suffix
|
|
4
|
+
when nil
|
|
5
|
+
prefix = "d"
|
|
6
|
+
suffix = ""
|
|
7
|
+
when String
|
|
8
|
+
prefix = prefix_suffix
|
|
9
|
+
suffix = ""
|
|
10
|
+
when Array
|
|
11
|
+
prefix = prefix_suffix[0]
|
|
12
|
+
suffix = prefix_suffix[1]
|
|
13
|
+
else
|
|
14
|
+
raise ArgumentError, "unexpected prefix_suffix: #{prefix_suffix.inspect}"
|
|
15
|
+
end
|
|
16
|
+
tmpdir ||= Dir.tmpdir
|
|
17
|
+
t = Time.now.strftime("%Y%m%d")
|
|
18
|
+
n = nil
|
|
19
|
+
begin
|
|
20
|
+
path = "#{tmpdir}/#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
|
|
21
|
+
path << "-#{n}" if n
|
|
22
|
+
path << suffix
|
|
23
|
+
Dir.mkdir(path, 0700)
|
|
24
|
+
rescue Errno::EEXIST
|
|
25
|
+
n ||= 0
|
|
26
|
+
n += 1
|
|
27
|
+
retry
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
if block_given?
|
|
31
|
+
begin
|
|
32
|
+
yield path
|
|
33
|
+
ensure
|
|
34
|
+
FileUtils.remove_entry_secure path
|
|
35
|
+
end
|
|
36
|
+
else
|
|
37
|
+
path
|
|
38
|
+
end
|
|
39
|
+
end unless respond_to? :mktmpdir # > 1.8.7
|
|
40
|
+
end
|
|
41
|
+
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
module Selenium
|
|
2
|
+
module WebDriver
|
|
3
|
+
class Driver
|
|
4
|
+
include Find
|
|
5
|
+
|
|
6
|
+
attr_reader :bridge
|
|
7
|
+
|
|
8
|
+
class << self
|
|
9
|
+
def for(driver, *args)
|
|
10
|
+
case driver
|
|
11
|
+
when :ie, :internet_explorer
|
|
12
|
+
new WebDriver::IE::Bridge.new(*args)
|
|
13
|
+
when :remote
|
|
14
|
+
new WebDriver::Remote::Bridge.new(*args)
|
|
15
|
+
when :chrome
|
|
16
|
+
new WebDriver::Chrome::Bridge.new(*args)
|
|
17
|
+
when :firefox, :ff
|
|
18
|
+
new WebDriver::Firefox::Bridge.new(*args)
|
|
19
|
+
else
|
|
20
|
+
raise ArgumentError, "unknown driver: #{driver.inspect}"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def initialize(bridge)
|
|
26
|
+
@bridge = bridge
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def navigate
|
|
30
|
+
@navigate ||= WebDriver::Navigation.new(self)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def switch_to
|
|
34
|
+
@switch_to ||= WebDriver::TargetLocator.new(self)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def manage
|
|
38
|
+
@manage ||= WebDriver::Options.new(self)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def current_url
|
|
42
|
+
bridge.getCurrentUrl
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def title
|
|
46
|
+
bridge.getTitle
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def page_source
|
|
50
|
+
bridge.getPageSource
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def visible?
|
|
54
|
+
bridge.getBrowserVisible
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def visible=(bool)
|
|
58
|
+
bridge.setBrowserVisible bool
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def quit
|
|
62
|
+
bridge.quit
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def close
|
|
66
|
+
bridge.close
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def window_handles
|
|
70
|
+
bridge.getWindowHandles
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def window_handle
|
|
74
|
+
bridge.getCurrentWindowHandle
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def execute_script(script, *args)
|
|
78
|
+
bridge.executeScript(script, *args)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
#-------------------------------- sugar --------------------------------
|
|
82
|
+
|
|
83
|
+
#
|
|
84
|
+
# driver.first(:id, 'foo')
|
|
85
|
+
#
|
|
86
|
+
|
|
87
|
+
alias_method :first, :find_element
|
|
88
|
+
|
|
89
|
+
#
|
|
90
|
+
# driver.all(:class, 'bar') #=> [#<WebDriver::Element:0x1011c3b88, ...]
|
|
91
|
+
#
|
|
92
|
+
|
|
93
|
+
alias_method :all, :find_elements
|
|
94
|
+
|
|
95
|
+
#
|
|
96
|
+
# opens the specified URL in the browser.
|
|
97
|
+
#
|
|
98
|
+
|
|
99
|
+
def get(url)
|
|
100
|
+
navigate.to(url)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
#
|
|
104
|
+
# driver.script('function() { ... };')
|
|
105
|
+
#
|
|
106
|
+
|
|
107
|
+
alias_method :script, :execute_script
|
|
108
|
+
|
|
109
|
+
#
|
|
110
|
+
# driver['someElementId'] #=> #<WebDriver::Element:0x1011c3b88>
|
|
111
|
+
#
|
|
112
|
+
|
|
113
|
+
def [](id)
|
|
114
|
+
find_element :id, id
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
#
|
|
119
|
+
# for Find
|
|
120
|
+
#
|
|
121
|
+
|
|
122
|
+
def ref
|
|
123
|
+
nil
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
end # Driver
|
|
127
|
+
end # WebDriver
|
|
128
|
+
end # Selenium
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
module Selenium
|
|
2
|
+
module WebDriver
|
|
3
|
+
class Element
|
|
4
|
+
include Find
|
|
5
|
+
|
|
6
|
+
attr_reader :bridge
|
|
7
|
+
|
|
8
|
+
def initialize(bridge, id)
|
|
9
|
+
@bridge, @id = bridge, id
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def click
|
|
13
|
+
bridge.clickElement @id
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def tag_name
|
|
17
|
+
bridge.getElementTagName @id
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def value
|
|
21
|
+
bridge.getElementValue @id
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def attribute(name)
|
|
25
|
+
bridge.getElementAttribute @id, name
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def text
|
|
29
|
+
bridge.getElementText @id
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# FIXME: send_keys args
|
|
33
|
+
def send_keys(*args)
|
|
34
|
+
args.each { |str| bridge.sendKeysToElement(@id, str) }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def clear
|
|
38
|
+
bridge.clearElement @id
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def enabled?
|
|
42
|
+
bridge.isElementEnabled @id
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def selected?
|
|
46
|
+
bridge.isElementSelected @id
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def displayed?
|
|
50
|
+
bridge.isElementDisplayed @id
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def select
|
|
54
|
+
bridge.setElementSelected @id
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def submit
|
|
58
|
+
bridge.submitElement @id
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def toggle
|
|
62
|
+
bridge.toggleElement @id
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def style(prop)
|
|
66
|
+
bridge.getElementValueOfCssProperty @id, prop
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def hover
|
|
70
|
+
bridge.hoverOverElement @id
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def location
|
|
74
|
+
bridge.getElementLocation @id
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def size
|
|
78
|
+
bridge.getElementSize @id
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def drag_and_drop_by(right_by, down_by)
|
|
82
|
+
bridge.dragElement @id, right_by, down_by
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def drag_and_drop_on(other)
|
|
86
|
+
current_location = location()
|
|
87
|
+
destination = other.location
|
|
88
|
+
|
|
89
|
+
right = destination.x - current_location.x
|
|
90
|
+
down = destination.y - current_location.y
|
|
91
|
+
|
|
92
|
+
drag_and_drop_by right, down
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
#-------------------------------- sugar --------------------------------
|
|
96
|
+
|
|
97
|
+
#
|
|
98
|
+
# element.first(:id, 'foo')
|
|
99
|
+
#
|
|
100
|
+
|
|
101
|
+
alias_method :first, :find_element
|
|
102
|
+
|
|
103
|
+
#
|
|
104
|
+
# element.all(:class, 'bar')
|
|
105
|
+
#
|
|
106
|
+
|
|
107
|
+
alias_method :all, :find_elements
|
|
108
|
+
|
|
109
|
+
#
|
|
110
|
+
# element['class'] or element[:class] #=> "someclass"
|
|
111
|
+
#
|
|
112
|
+
alias_method :[], :attribute
|
|
113
|
+
|
|
114
|
+
#
|
|
115
|
+
# for Find and execute_script
|
|
116
|
+
#
|
|
117
|
+
|
|
118
|
+
def ref
|
|
119
|
+
@id
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
end # Element
|
|
125
|
+
end # WebDriver
|
|
126
|
+
end # Selenium
|