All Files (89.47%)
37 files in total.
2146 relevant lines.
1920 lines covered and
226 lines missed
./lib/watir-webdriver.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
# encoding: utf-8 |
|
2 |
require "selenium-webdriver" |
1 |
3 |
require "json" |
1 |
4 |
||
5 |
require "watir-webdriver/version" |
1 |
6 |
require "watir-webdriver/exception" |
1 |
7 |
require "watir-webdriver/xpath_support" |
1 |
8 |
require "watir-webdriver/window_switching" |
1 |
9 |
require "watir-webdriver/container" |
1 |
10 |
require "watir-webdriver/locators/element_locator" |
1 |
11 |
require "watir-webdriver/locators/button_locator" |
1 |
12 |
require "watir-webdriver/locators/text_field_locator" |
1 |
13 |
require "watir-webdriver/locators/child_row_locator" |
1 |
14 |
require "watir-webdriver/locators/child_cell_locator" |
1 |
15 |
require "watir-webdriver/browser" |
1 |
16 |
||
17 |
module Watir |
1 |
18 |
include Selenium |
1 |
19 |
||
20 |
class << self |
1 |
21 |
def tag_to_class |
1 |
22 |
@tag_to_class ||= {} |
124 |
23 |
end |
|
24 |
||
25 |
def element_class_for(tag_name) |
1 |
26 |
tag_to_class[tag_name.to_sym] || HTMLElement |
17 |
27 |
end |
|
28 |
end |
|
29 |
||
30 |
end |
|
31 |
||
32 |
require "watir-webdriver/attribute_helper" |
1 |
33 |
require "watir-webdriver/row_container" |
1 |
34 |
require "watir-webdriver/cell_container" |
1 |
35 |
require "watir-webdriver/element_collection" |
1 |
36 |
require "watir-webdriver/elements/element" |
1 |
37 |
require "watir-webdriver/elements/generated" |
1 |
38 |
require "watir-webdriver/elements/frame" |
1 |
39 |
require "watir-webdriver/elements/input" |
1 |
40 |
require "watir-webdriver/elements/button" |
1 |
41 |
require "watir-webdriver/elements/checkbox" |
1 |
42 |
require "watir-webdriver/elements/file_field" |
1 |
43 |
require "watir-webdriver/elements/image" |
1 |
44 |
require "watir-webdriver/elements/link" |
1 |
45 |
require "watir-webdriver/elements/font" |
1 |
46 |
require "watir-webdriver/elements/radio" |
1 |
47 |
require "watir-webdriver/elements/text_field" |
1 |
48 |
require "watir-webdriver/elements/hidden" |
1 |
49 |
require "watir-webdriver/elements/select" |
1 |
50 |
require "watir-webdriver/elements/form" |
1 |
51 |
require "watir-webdriver/elements/option" |
1 |
52 |
require "watir-webdriver/elements/table" |
1 |
53 |
require "watir-webdriver/elements/table_row" |
1 |
54 |
require "watir-webdriver/elements/table_cell" |
1 |
55 |
require "watir-webdriver/elements/table_section" |
1 |
56 |
||
57 |
Watir.tag_to_class.freeze |
1 |
58 |
||
59 |
module Watir |
1 |
60 |
module Container |
1 |
61 |
||
62 |
end # Container |
|
63 |
end # Watir |
|
64 |
||
65 |
||
66 |
# undefine deprecated methods to use them for Element attributes |
|
67 |
class Object |
1 |
68 |
undef_method :id if method_defined? "id" |
1 |
69 |
undef_method :type if method_defined? "type" |
1 |
70 |
end |
|
71 |
./lib/watir-webdriver/attribute_helper.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
module Watir |
1 |
2 |
||
3 |
# |
|
4 |
# @private |
|
5 |
# |
|
6 |
# Extended by Element, provides methods for defining attributes on the element classes. |
|
7 |
# |
|
8 |
||
9 |
module AttributeHelper |
1 |
10 |
||
11 |
IGNORED_ATTRIBUTES = [:text, :hash] |
1 |
12 |
||
13 |
def typed_attributes |
1 |
14 |
@typed_attributes ||= Hash.new { |hash, type| hash[type] = [] } |
402 |
15 |
end |
|
16 |
||
17 |
def attribute_list |
1 |
18 |
@attribute_list ||= ( |
|
19 |
list = typed_attributes.values.flatten |
37 |
20 |
list += ancestors[1..-1].map do |e| |
37 |
21 |
e.attribute_list if e.respond_to?(:attribute_list) |
673 |
22 |
end.compact.flatten |
|
23 |
).uniq |
2860 |
24 |
end |
|
25 |
||
26 |
def attributes(attribute_map = nil) |
1 |
27 |
attribute_map or return attribute_list |
131 |
28 |
||
29 |
add_attributes attribute_map |
89 |
30 |
||
31 |
attribute_map.each do |type, attribs| |
89 |
32 |
attribs.each do |name| |
190 |
33 |
# we don't want to override methods like :text or :hash |
|
34 |
next if IGNORED_ATTRIBUTES.include?(name) |
665 |
35 |
define_attribute(type, name) |
658 |
36 |
end |
|
37 |
end |
|
38 |
end |
|
39 |
||
40 |
private |
1 |
41 |
||
42 |
def define_attribute(type, name) |
1 |
43 |
method_name = method_name_for(type, name) |
658 |
44 |
attribute_name = attribute_for_method(name) |
658 |
45 |
||
46 |
(@attributes ||= []) << attribute_name |
658 |
47 |
||
48 |
case type |
658 |
49 |
when :string |
|
50 |
define_string_attribute(method_name, attribute_name) |
328 |
51 |
when :bool |
|
52 |
define_boolean_attribute(method_name, attribute_name) |
88 |
53 |
when :int |
|
54 |
define_int_attribute(method_name, attribute_name) |
59 |
55 |
else |
|
56 |
# $stderr.puts "treating #{type.inspect} as string for now" |
|
57 |
end |
|
58 |
end |
|
59 |
||
60 |
def define_string_attribute(mname, aname) |
1 |
61 |
define_method mname do |
328 |
62 |
assert_exists |
1149 |
63 |
@element.attribute(aname).to_s |
1022 |
64 |
end |
|
65 |
end |
|
66 |
||
67 |
def define_boolean_attribute(mname, aname) |
1 |
68 |
define_method mname do |
88 |
69 |
assert_exists |
94 |
70 |
@element.attribute(aname) == "true" |
80 |
71 |
end |
|
72 |
end |
|
73 |
||
74 |
def define_int_attribute(mname, aname) |
1 |
75 |
define_method mname do |
59 |
76 |
assert_exists |
36 |
77 |
value = @element.attribute(aname) |
36 |
78 |
value && Integer(value) |
36 |
79 |
end |
|
80 |
end |
|
81 |
||
82 |
def add_attributes(attributes) |
1 |
83 |
attributes.each do |type, attr_list| |
89 |
84 |
typed_attributes[type] += attr_list |
190 |
85 |
end |
|
86 |
end |
|
87 |
||
88 |
def method_name_for(type, attribute) |
1 |
89 |
# http://github.com/jarib/watir-webdriver/issues/issue/26 |
|
90 |
name = case attribute |
658 |
91 |
when :html_for |
|
92 |
'for' |
3 |
93 |
when :col_span |
|
94 |
'colspan' |
1 |
95 |
when :row_span |
|
96 |
'rowspan' |
1 |
97 |
else |
|
98 |
attribute.to_s |
653 |
99 |
end |
|
100 |
||
101 |
name << "?" if type == :bool |
658 |
102 |
||
103 |
name |
658 |
104 |
end |
|
105 |
||
106 |
def attribute_for_method(method) |
1 |
107 |
# http://github.com/jarib/watir-webdriver/issues/issue/26 |
|
108 |
||
109 |
case method.to_sym |
658 |
110 |
when :class_name |
|
111 |
'class' |
1 |
112 |
when :html_for |
|
113 |
'for' |
3 |
114 |
when :read_only |
|
115 |
'readonly' |
4 |
116 |
when :http_equiv |
|
117 |
'http-equiv' |
1 |
118 |
when :col_span |
|
119 |
'colspan' |
1 |
120 |
when :row_span |
|
121 |
'rowspan' |
1 |
122 |
else |
|
123 |
method.to_s |
647 |
124 |
end |
|
125 |
end |
|
126 |
||
127 |
end # AttributeHelper |
|
128 |
end # Watir |
./lib/watir-webdriver/browser.rb95.18 % covered |
||
# | Hits | |
---|---|---|
1 |
# encoding: utf-8 |
|
2 |
module Watir |
1 |
3 |
||
4 |
# |
|
5 |
# The main class through which you control the browser. |
|
6 |
# |
|
7 |
||
8 |
class Browser |
1 |
9 |
include Container |
1 |
10 |
include WindowSwitching |
1 |
11 |
||
12 |
attr_reader :driver |
1 |
13 |
alias_method :wd, :driver # ensures duck typing with Watir::Element |
1 |
14 |
||
15 |
class << self |
1 |
16 |
def start(url, browser = :firefox) |
1 |
17 |
b = new(browser) |
1 |
18 |
b.goto url |
1 |
19 |
||
20 |
b |
1 |
21 |
end |
|
22 |
end |
|
23 |
||
24 |
# |
|
25 |
# Create a Watir::Browser instance |
|
26 |
# |
|
27 |
# @param [:firefox, :ie, :chrome, :remote, Selenium::WebDriver] browser |
|
28 |
# @param args Passed to the underlying driver |
|
29 |
# |
|
30 |
||
31 |
def initialize(browser = :firefox, *args) |
1 |
32 |
case browser |
7 |
33 |
when Symbol, String |
|
34 |
@driver = Selenium::WebDriver.for browser.to_sym, *args |
5 |
35 |
when Selenium::WebDriver::Driver |
|
36 |
@driver = browser |
1 |
37 |
else |
|
38 |
raise ArgumentError, "expected Symbol or Selenium::WebDriver::Driver, got #{browser.class}" |
1 |
39 |
end |
|
40 |
||
41 |
@error_checkers = [] |
6 |
42 |
@current_frame = nil |
6 |
43 |
@closed = false |
6 |
44 |
end |
|
45 |
||
46 |
def inspect |
1 |
47 |
'#<%s:0x%x url=%s title=%s>' % [self.class, hash*2, url.inspect, title.inspect] |
0 |
48 |
end |
|
49 |
||
50 |
# |
|
51 |
# Goto the given URL |
|
52 |
# |
|
53 |
# @param [String] uri The url. |
|
54 |
# @return [String] The url you end up at. |
|
55 |
# |
|
56 |
||
57 |
def goto(uri) |
1 |
58 |
uri = "http://#{uri}" unless uri.include?("://") |
1024 |
59 |
||
60 |
@driver.navigate.to uri |
1024 |
61 |
run_checkers |
1024 |
62 |
||
63 |
url |
1024 |
64 |
end |
|
65 |
||
66 |
def back |
1 |
67 |
@driver.navigate.back |
5 |
68 |
end |
|
69 |
||
70 |
def forward |
1 |
71 |
@driver.navigate.forward |
3 |
72 |
end |
|
73 |
||
74 |
def url |
1 |
75 |
@driver.current_url |
1042 |
76 |
end |
|
77 |
||
78 |
def title |
1 |
79 |
@driver.title |
7 |
80 |
end |
|
81 |
||
82 |
def close |
1 |
83 |
return if @closed |
4 |
84 |
@driver.quit |
4 |
85 |
@closed = true |
4 |
86 |
end |
|
87 |
alias_method :quit, :close # TODO: close vs quit |
1 |
88 |
||
89 |
def clear_cookies |
1 |
90 |
@driver.manage.delete_all_cookies |
0 |
91 |
end |
|
92 |
||
93 |
def text |
1 |
94 |
@driver.find_element(:tag_name, "body").text |
9 |
95 |
end |
|
96 |
||
97 |
def html |
1 |
98 |
# use body.html instead? |
|
99 |
@driver.page_source |
1 |
100 |
end |
|
101 |
||
102 |
def refresh |
1 |
103 |
@driver.navigate.refresh |
1 |
104 |
run_checkers |
1 |
105 |
end |
|
106 |
||
107 |
def status |
1 |
108 |
execute_script "return window.status;" |
0 |
109 |
end |
|
110 |
||
111 |
def execute_script(script, *args) |
1 |
112 |
args.map! { |e| e.kind_of?(Watir::Element) ? e.element : e } |
14 |
113 |
returned = @driver.execute_script(script, *args) |
14 |
114 |
||
115 |
wrap_elements_in(returned) |
14 |
116 |
end |
|
117 |
||
118 |
def add_checker(checker = nil, &block) |
1 |
119 |
if block_given? |
3 |
120 |
@error_checkers << block |
0 |
121 |
elsif Proc === checker |
3 |
122 |
@error_checkers << checker |
2 |
123 |
else |
|
124 |
raise ArgumentError, "argument must be a Proc or block" |
1 |
125 |
end |
|
126 |
end |
|
127 |
||
128 |
def disable_checker(checker) |
1 |
129 |
@error_checkers.delete(checker) |
2 |
130 |
end |
|
131 |
||
132 |
def run_checkers |
1 |
133 |
@error_checkers.each { |e| e[self] } |
1078 |
134 |
end |
|
135 |
||
136 |
# |
|
137 |
# Protocol shared with Watir::Element |
|
138 |
# |
|
139 |
# @api private |
|
140 |
# |
|
141 |
||
142 |
def assert_exists |
1 |
143 |
if @closed |
2274 |
144 |
raise Error, "browser was closed" |
1 |
145 |
else |
|
146 |
driver.switch_to.default_content |
2273 |
147 |
true |
2273 |
148 |
end |
|
149 |
end |
|
150 |
||
151 |
def exist? |
1 |
152 |
not @closed |
2 |
153 |
end |
|
154 |
||
155 |
def browser |
1 |
156 |
self |
1 |
157 |
end |
|
158 |
||
159 |
private |
1 |
160 |
||
161 |
def wrap_elements_in(obj) |
1 |
162 |
case obj |
22 |
163 |
when WebDriver::Element |
|
164 |
wrap_element(obj) |
5 |
165 |
when Array |
|
166 |
obj.map { |e| wrap_elements_in(e) } |
4 |
167 |
when Hash |
|
168 |
obj.each { |k,v| obj[k] = wrap_elements_in(v) } |
10 |
169 |
||
170 |
obj |
4 |
171 |
else |
|
172 |
obj |
11 |
173 |
end |
|
174 |
end |
|
175 |
||
176 |
def wrap_element(element) |
1 |
177 |
Watir.element_class_for(element.tag_name).new(self, :element => element) |
5 |
178 |
end |
|
179 |
||
180 |
end # Browser |
|
181 |
end # Watir |
./lib/watir-webdriver/cell_container.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
module Watir |
1 |
2 |
module CellContainer |
1 |
3 |
||
4 |
def cell(*args) |
1 |
5 |
cell = TableCell.new(self, extract_selector(args).merge(:tag_name => /^(th|td)$/)) |
17 |
6 |
cell.locator_class = ChildCellLocator |
17 |
7 |
||
8 |
cell |
17 |
9 |
end |
|
10 |
||
11 |
def cells(*args) |
1 |
12 |
cells = TableCellCollection.new(self, extract_selector(args).merge(:tag_name => /^(th|td)$/)) |
45 |
13 |
cells.locator_class = ChildCellLocator |
45 |
14 |
||
15 |
cells |
45 |
16 |
end |
|
17 |
||
18 |
end |
|
19 |
end |
./lib/watir-webdriver/container.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
# encoding: utf-8 |
|
2 |
module Watir |
1 |
3 |
module Container |
1 |
4 |
include XpathSupport |
1 |
5 |
||
6 |
def element(*args) |
1 |
7 |
HTMLElement.new(self, extract_selector(args)) |
4 |
8 |
end |
|
9 |
||
10 |
def elements(*args) |
1 |
11 |
HTMLElementCollection.new(self, extract_selector(args)) |
2 |
12 |
end |
|
13 |
||
14 |
private |
1 |
15 |
||
16 |
def browserbot(function_name, *arguments) |
1 |
17 |
script = browserbot_script + "return browserbot.#{function_name}.apply(browserbot, arguments);" |
11 |
18 |
driver.execute_script(script, *arguments) |
11 |
19 |
end |
|
20 |
||
21 |
def browserbot_script |
1 |
22 |
@browserbot_script ||= File.read("#{File.dirname(__FILE__)}/browserbot.js") |
11 |
23 |
end |
|
24 |
||
25 |
def extract_selector(selectors) |
1 |
26 |
case selectors.size |
2819 |
27 |
when 2 |
|
28 |
return { selectors[0] => selectors[1] } |
2258 |
29 |
when 1 |
|
30 |
obj = selectors.first |
220 |
31 |
return obj if obj.kind_of? Hash |
220 |
32 |
when 0 |
|
33 |
return {} |
340 |
34 |
end |
|
35 |
||
36 |
raise ArgumentError, "expected Hash or (:how, 'what'), got #{selectors.inspect}" |
2 |
37 |
end |
|
38 |
||
39 |
end # Container |
|
40 |
end # Watir |
./lib/watir-webdriver/element_collection.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
# encoding: utf-8 |
|
2 |
module Watir |
1 |
3 |
||
4 |
# |
|
5 |
# Base class for element collections. |
|
6 |
# |
|
7 |
||
8 |
class ElementCollection |
1 |
9 |
include Enumerable |
1 |
10 |
||
11 |
def initialize(parent, selector) |
1 |
12 |
@parent = parent |
337 |
13 |
@selector = selector |
337 |
14 |
end |
|
15 |
||
16 |
# |
|
17 |
# @yieldparam [Watir::Element] element Iterate through the elements in this collection. |
|
18 |
# |
|
19 |
||
20 |
def each(&blk) |
1 |
21 |
to_a.each(&blk) |
131 |
22 |
end |
|
23 |
||
24 |
# |
|
25 |
# @return [Fixnum] The number of elements in this collection. |
|
26 |
# |
|
27 |
||
28 |
def length |
1 |
29 |
elements.length |
114 |
30 |
end |
|
31 |
alias_method :size, :length |
1 |
32 |
||
33 |
# |
|
34 |
# Get the element at the given index. |
|
35 |
# Note that this is 0-indexed and not compatible with older Watir implementations. |
|
36 |
# |
|
37 |
# Also note that because of Watir's lazy loading, this will return an Element |
|
38 |
# instance even if the index is out of bounds. |
|
39 |
# |
|
40 |
# @param [Fixnum] n Index of wanted element, 0-indexed |
|
41 |
# @return [Watir::Element] Returns an instance of a Watir::Element subclass |
|
42 |
# |
|
43 |
||
44 |
||
45 |
def [](idx) |
1 |
46 |
to_a[idx] || element_class.new(@parent, :index => idx) |
63 |
47 |
end |
|
48 |
||
49 |
# |
|
50 |
# First element of this collection |
|
51 |
# |
|
52 |
# @return [Watir::Element] Returns an instance of a Watir::Element subclass |
|
53 |
# |
|
54 |
||
55 |
def first |
1 |
56 |
self[0] |
5 |
57 |
end |
|
58 |
||
59 |
# |
|
60 |
# Last element of the collection |
|
61 |
# |
|
62 |
# @return [Watir::Element] Returns an instance of a Watir::Element subclass |
|
63 |
# |
|
64 |
||
65 |
def last |
1 |
66 |
self[-1] |
3 |
67 |
end |
|
68 |
||
69 |
# |
|
70 |
# This collection as an Array |
|
71 |
# |
|
72 |
# @return [Array<Watir::Element>] |
|
73 |
# |
|
74 |
||
75 |
def to_a |
1 |
76 |
# TODO: optimize - lazy element_class instance? |
|
77 |
@to_a ||= elements.map { |e| element_class.new(@parent, :element => e) } |
1177 |
78 |
end |
|
79 |
||
80 |
private |
1 |
81 |
||
82 |
def elements |
1 |
83 |
@elements ||= locator_class.new( |
|
84 |
@parent.wd, |
|
85 |
@selector, |
|
86 |
element_class.attribute_list |
|
87 |
).locate_all |
349 |
88 |
end |
|
89 |
||
90 |
# overridable by subclasses |
|
91 |
def locator_class |
1 |
92 |
ElementLocator |
239 |
93 |
end |
|
94 |
||
95 |
end # ElementCollection |
|
96 |
end # Watir |
./lib/watir-webdriver/elements/button.rb95.45 % covered |
||
# | Hits | |
---|---|---|
1 |
# encoding: utf-8 |
|
2 |
module Watir |
1 |
3 |
||
4 |
# |
|
5 |
# Class representing button elements. |
|
6 |
# |
|
7 |
# This class covers both <button> and <input type="submit|reset|image|button" /> elements. |
|
8 |
# |
|
9 |
||
10 |
class Button < HTMLElement |
1 |
11 |
||
12 |
# add the attributes from <input> |
|
13 |
attributes Watir::Input.typed_attributes |
1 |
14 |
||
15 |
VALID_TYPES = %w[button reset submit image] |
1 |
16 |
||
17 |
# |
|
18 |
# Returns the text of the button. |
|
19 |
# |
|
20 |
# For input elements, returns the "value" attribute. |
|
21 |
# For button elements, returns the inner text. |
|
22 |
# |
|
23 |
||
24 |
def text |
1 |
25 |
assert_exists |
5 |
26 |
case @element.tag_name |
4 |
27 |
when 'input' |
|
28 |
@element.attribute(:value) |
3 |
29 |
when 'button' |
|
30 |
@element.text |
1 |
31 |
else |
|
32 |
raise Exception::Error, "unknown tag name for button: #{@element.tag_name}" |
0 |
33 |
end |
|
34 |
end |
|
35 |
||
36 |
# |
|
37 |
# Returns true if this element is enabled |
|
38 |
# |
|
39 |
# @return [Boolean] |
|
40 |
# |
|
41 |
||
42 |
def enabled? |
1 |
43 |
!disabled? |
3 |
44 |
end |
|
45 |
||
46 |
private |
1 |
47 |
||
48 |
def locate |
1 |
49 |
@parent.assert_exists |
117 |
50 |
ButtonLocator.new(@parent.wd, @selector, self.class.attribute_list).locate |
117 |
51 |
end |
|
52 |
||
53 |
end # Button |
|
54 |
||
55 |
class ButtonCollection < ElementCollection |
1 |
56 |
private |
1 |
57 |
||
58 |
def locator_class |
1 |
59 |
ButtonLocator |
8 |
60 |
end |
|
61 |
||
62 |
def element_class |
1 |
63 |
Button |
57 |
64 |
end |
|
65 |
end # ButtonsCollection |
|
66 |
end # Watir |
./lib/watir-webdriver/elements/checkbox.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
# encoding: utf-8 |
|
2 |
||
3 |
module Watir |
1 |
4 |
class CheckBox < Input |
1 |
5 |
||
6 |
# |
|
7 |
# Set this checkbox to the given value |
|
8 |
# |
|
9 |
# Example: |
|
10 |
# |
|
11 |
# checkbox.set? #=> false |
|
12 |
# checkbox.set |
|
13 |
# checkbox.set? #=> true |
|
14 |
# checkbox.set(false) |
|
15 |
# checkbox.set? #=> false |
|
16 |
# |
|
17 |
||
18 |
def set(bool = true) |
1 |
19 |
assert_exists |
17 |
20 |
assert_enabled |
13 |
21 |
||
22 |
if @element.selected? |
9 |
23 |
@element.click unless bool |
4 |
24 |
else |
|
25 |
@element.click if bool |
5 |
26 |
end |
|
27 |
end |
|
28 |
||
29 |
# |
|
30 |
# returns true if the element is checked |
|
31 |
# @return [Boolean] |
|
32 |
# |
|
33 |
||
34 |
def set? |
1 |
35 |
assert_exists |
12 |
36 |
@element.selected? |
10 |
37 |
end |
|
38 |
||
39 |
# |
|
40 |
# Unset this checkbox. |
|
41 |
# |
|
42 |
# Same as +set(false)+ |
|
43 |
# |
|
44 |
||
45 |
def clear |
1 |
46 |
set false |
8 |
47 |
end |
|
48 |
end # CheckBox |
|
49 |
||
50 |
module Container |
1 |
51 |
def checkbox(*args) |
1 |
52 |
CheckBox.new(self, extract_selector(args).merge(:tag_name => "input", :type => "checkbox")) |
115 |
53 |
end |
|
54 |
||
55 |
def checkboxes(*args) |
1 |
56 |
CheckBoxCollection.new(self, extract_selector(args).merge(:tag_name => "input", :type => "checkbox")) |
4 |
57 |
end |
|
58 |
end # Container |
|
59 |
||
60 |
class CheckBoxCollection < InputCollection |
1 |
61 |
def element_class |
1 |
62 |
CheckBox |
19 |
63 |
end |
|
64 |
end # CheckBoxCollection |
|
65 |
end |
./lib/watir-webdriver/elements/element.rb85.61 % covered |
||
# | Hits | |
---|---|---|
1 |
# encoding: utf-8 |
|
2 |
||
3 |
module Watir |
1 |
4 |
||
5 |
# |
|
6 |
# Base class for HTML elements. |
|
7 |
# |
|
8 |
||
9 |
class Element |
1 |
10 |
include Exception |
1 |
11 |
include Container |
1 |
12 |
include Selenium |
1 |
13 |
extend AttributeHelper |
1 |
14 |
||
15 |
def initialize(parent, selector) |
1 |
16 |
@parent = parent |
3499 |
17 |
@selector = selector |
3499 |
18 |
||
19 |
unless @selector.kind_of? Hash |
3499 |
20 |
raise ArgumentError, "invalid argument: #{selector.inspect}" |
1 |
21 |
end |
|
22 |
||
23 |
if @selector.has_key?(:element) |
3498 |
24 |
@element = @selector[:element] |
963 |
25 |
end |
|
26 |
end |
|
27 |
||
28 |
def exists? |
1 |
29 |
assert_exists |
778 |
30 |
true |
383 |
31 |
rescue UnknownObjectException, UnknownFrameException |
|
32 |
false |
314 |
33 |
end |
|
34 |
alias_method :exist?, :exists? |
1 |
35 |
||
36 |
def inspect |
1 |
37 |
if @selector.has_key?(:element) |
0 |
38 |
'#<%s:0x%x located=%s selector=%s>' % [self.class, hash*2, !!@element, '{:element=>(webdriver element)}'] |
0 |
39 |
else |
|
40 |
'#<%s:0x%x located=%s selector=%s>' % [self.class, hash*2, !!@element, selector_string] |
0 |
41 |
end |
|
42 |
end |
|
43 |
||
44 |
def ==(other) |
1 |
45 |
return false unless other.kind_of? self.class |
41 |
46 |
||
47 |
assert_exists |
40 |
48 |
@element == other.element |
40 |
49 |
end |
|
50 |
alias_method :eql?, :== |
1 |
51 |
||
52 |
def hash |
1 |
53 |
@element ? @element.hash : super |
0 |
54 |
end |
|
55 |
||
56 |
def text |
1 |
57 |
assert_exists |
200 |
58 |
@element.text |
162 |
59 |
end |
|
60 |
||
61 |
def tag_name |
1 |
62 |
assert_exists |
1 |
63 |
@element.tag_name |
1 |
64 |
end |
|
65 |
||
66 |
def click |
1 |
67 |
assert_exists |
85 |
68 |
assert_enabled |
52 |
69 |
@element.click |
51 |
70 |
run_checkers |
51 |
71 |
end |
|
72 |
||
73 |
def double_click |
1 |
74 |
assert_exists |
0 |
75 |
raise NotImplementedError, "need support in WebDriver" |
0 |
76 |
||
77 |
@element.double_click |
0 |
78 |
run_checkers |
0 |
79 |
end |
|
80 |
||
81 |
def right_click |
1 |
82 |
assert_exists |
0 |
83 |
raise NotImplementedError, "need support in WebDriver" |
0 |
84 |
||
85 |
@element.right_click |
0 |
86 |
run_checkers |
0 |
87 |
end |
|
88 |
||
89 |
def flash |
1 |
90 |
original_color = style("backgroundColor") |
0 |
91 |
||
92 |
10.times do |n| |
0 |
93 |
color = (n % 2 == 0) ? "red" : original_color |
0 |
94 |
driver.execute_script("arguments[0].style.backgroundColor = '#{color}'", @element) |
0 |
95 |
end |
|
96 |
end |
|
97 |
||
98 |
def value |
1 |
99 |
assert_exists |
293 |
100 |
||
101 |
begin |
282 |
102 |
@element.value || '' |
282 |
103 |
rescue WebDriver::Error::ElementNotEnabledError |
267 |
104 |
"" |
267 |
105 |
end |
|
106 |
end |
|
107 |
||
108 |
def attribute_value(attribute_name) |
1 |
109 |
assert_exists |
130 |
110 |
@element.attribute attribute_name |
128 |
111 |
end |
|
112 |
||
113 |
def html |
1 |
114 |
assert_exists |
4 |
115 |
browserbot('getOuterHTML', @element).strip |
4 |
116 |
end |
|
117 |
||
118 |
def send_keys(*args) |
1 |
119 |
assert_exists |
1 |
120 |
@element.send_keys(*args) |
1 |
121 |
end |
|
122 |
||
123 |
# |
|
124 |
# Note: Firefox queues focus events until the window actually has focus. |
|
125 |
# |
|
126 |
# See http://code.google.com/p/selenium/issues/detail?id=157 |
|
127 |
# |
|
128 |
||
129 |
def focus |
1 |
130 |
assert_exists |
0 |
131 |
driver.execute_script "return arguments[0].focus()", @element |
0 |
132 |
end |
|
133 |
||
134 |
def fire_event(event_name, bubble = false) |
1 |
135 |
assert_exists |
7 |
136 |
event_name = event_name.to_s.sub(/^on/, '') |
7 |
137 |
browserbot('triggerEvent', @element, event_name, bubble) |
7 |
138 |
end |
|
139 |
||
140 |
def parent |
1 |
141 |
assert_exists |
1 |
142 |
||
143 |
e = driver.execute_script "return arguments[0].parentNode", @element |
1 |
144 |
||
145 |
if e.kind_of?(WebDriver::Element) |
1 |
146 |
Watir.element_class_for(e.tag_name).new(@parent, :element => e) |
1 |
147 |
end |
|
148 |
end |
|
149 |
||
150 |
def driver |
1 |
151 |
@parent.driver |
240 |
152 |
end |
|
153 |
||
154 |
def element |
1 |
155 |
assert_exists |
383 |
156 |
@element |
383 |
157 |
end |
|
158 |
alias_method :wd, :element # ensures duck typing with Browser |
1 |
159 |
||
160 |
def visible? |
1 |
161 |
assert_exists |
25 |
162 |
@element.displayed? |
25 |
163 |
end |
|
164 |
||
165 |
def style(property = nil) |
1 |
166 |
if property |
6 |
167 |
assert_exists |
0 |
168 |
@element.style property |
0 |
169 |
else |
|
170 |
attribute_value("style") || '' |
6 |
171 |
end |
|
172 |
end |
|
173 |
||
174 |
def run_checkers |
1 |
175 |
@parent.run_checkers |
55 |
176 |
end |
|
177 |
||
178 |
# |
|
179 |
# Cast this Element instance to a more specific subtype. |
|
180 |
# |
|
181 |
# Example: |
|
182 |
# |
|
183 |
# browser.element(:xpath => "//input[@type='submit']").to_subtype #=> #<Watir::Button> |
|
184 |
# |
|
185 |
||
186 |
def to_subtype |
1 |
187 |
elem = element() |
8 |
188 |
tag_name = elem.tag_name |
8 |
189 |
||
190 |
klass = nil |
8 |
191 |
||
192 |
if tag_name == "input" |
8 |
193 |
klass = case elem.attribute(:type) |
7 |
194 |
when *Button::VALID_TYPES |
|
195 |
Button |
2 |
196 |
when 'checkbox' |
|
197 |
CheckBox |
1 |
198 |
when 'radio' |
|
199 |
Radio |
2 |
200 |
when 'file' |
|
201 |
FileField |
1 |
202 |
else |
|
203 |
TextField |
1 |
204 |
end |
|
205 |
else |
|
206 |
klass = Watir.element_class_for(tag_name) |
1 |
207 |
end |
|
208 |
||
209 |
klass.new(@parent, :element => elem) |
8 |
210 |
end |
|
211 |
||
212 |
protected |
1 |
213 |
||
214 |
def assert_exists |
1 |
215 |
@element ||= locate |
3921 |
216 |
||
217 |
unless @element |
3822 |
218 |
raise UnknownObjectException, "unable to locate element, using #{selector_string}" |
556 |
219 |
end |
|
220 |
end |
|
221 |
||
222 |
def browser |
1 |
223 |
@parent.browser |
1 |
224 |
end |
|
225 |
||
226 |
def locate |
1 |
227 |
@parent.assert_exists |
2090 |
228 |
locator_class.new(@parent.wd, @selector, self.class.attribute_list).locate |
2087 |
229 |
end |
|
230 |
||
231 |
private |
1 |
232 |
||
233 |
def locator_class |
1 |
234 |
ElementLocator |
2097 |
235 |
end |
|
236 |
||
237 |
def selector_string |
1 |
238 |
@selector.inspect |
549 |
239 |
end |
|
240 |
||
241 |
def attribute?(attribute) |
1 |
242 |
assert_exists |
67 |
243 |
driver.execute_script "return !!arguments[0].getAttributeNode(arguments[1]);", @element, attribute.to_s.downcase |
67 |
244 |
end |
|
245 |
||
246 |
def assert_enabled |
1 |
247 |
raise ObjectDisabledException, "object is disabled #{selector_string}" unless @element.enabled? |
92 |
248 |
end |
|
249 |
||
250 |
def assert_writable |
1 |
251 |
assert_enabled |
14 |
252 |
raise ObjectReadOnlyException if respond_to?(:readonly?) && readonly? |
13 |
253 |
end |
|
254 |
||
255 |
def method_missing(meth, *args, &blk) |
1 |
256 |
method = meth.to_s |
122 |
257 |
if method =~ /^data_(.+)$/ |
122 |
258 |
attribute_value(method.gsub(/_/, '-'), *args) |
121 |
259 |
else |
|
260 |
super |
1 |
261 |
end |
|
262 |
end |
|
263 |
||
264 |
end # Element |
|
265 |
end # Watir |
./lib/watir-webdriver/elements/file_field.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
# encoding: utf-8 |
|
2 |
module Watir |
1 |
3 |
class FileField < Input |
1 |
4 |
# |
|
5 |
# Set the file field to the given path |
|
6 |
# |
|
7 |
# @param [String] a path |
|
8 |
# |
|
9 |
# @raise [Errno::ENOENT] if the file doesn't exist |
|
10 |
# |
|
11 |
||
12 |
def set(path) |
1 |
13 |
raise Errno::ENOENT, path unless File.exist?(path) |
2 |
14 |
self.value = path |
1 |
15 |
end |
|
16 |
||
17 |
# |
|
18 |
# Set the file field to the given path |
|
19 |
# |
|
20 |
# @param [String] a path |
|
21 |
# |
|
22 |
def value=(path) |
1 |
23 |
assert_exists |
4 |
24 |
path = path.gsub(File::SEPARATOR, File::ALT_SEPARATOR) if File::ALT_SEPARATOR |
4 |
25 |
@element.send_keys path |
4 |
26 |
end |
|
27 |
||
28 |
# |
|
29 |
# Return the value of this field |
|
30 |
# |
|
31 |
# In IE, the path returned depends on the "Include local directory path |
|
32 |
# when uploading files to a server" security setting: |
|
33 |
# |
|
34 |
# @see http://msdn.microsoft.com/en-us/library/ms535128(VS.85).aspx |
|
35 |
# |
|
36 |
# @return [String] |
|
37 |
# |
|
38 |
||
39 |
def value |
1 |
40 |
# since 'value' is an attribute on input fields, we override this here |
|
41 |
assert_exists |
7 |
42 |
@element.value |
7 |
43 |
end |
|
44 |
end |
|
45 |
||
46 |
module Container |
1 |
47 |
def file_field(*args) |
1 |
48 |
FileField.new(self, extract_selector(args).merge(:tag_name => "input", :type => "file")) |
47 |
49 |
end |
|
50 |
||
51 |
def file_fields(*args) |
1 |
52 |
FileFieldCollection.new(self, extract_selector(args).merge(:tag_name => "input", :type => "file")) |
4 |
53 |
end |
|
54 |
end # Container |
|
55 |
||
56 |
class FileFieldCollection < InputCollection |
1 |
57 |
def element_class |
1 |
58 |
FileField |
9 |
59 |
end |
|
60 |
end # FileFieldCollection |
|
61 |
end # Watir |
./lib/watir-webdriver/elements/font.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
module Watir |
1 |
2 |
module Container |
1 |
3 |
def font(*args) |
1 |
4 |
Font.new(self, extract_selector(args).merge(:tag_name => "font")) |
4 |
5 |
end |
|
6 |
|
|
7 |
def fonts(*args) |
1 |
8 |
FontCollection.new(self, extract_selector(args).merge(:tag_name => "font")) |
1 |
9 |
end |
|
10 |
end # Container |
|
11 |
end # Watir |
./lib/watir-webdriver/elements/form.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
# encoding: utf-8 |
|
2 |
module Watir |
1 |
3 |
class Form < HTMLElement |
1 |
4 |
||
5 |
# |
|
6 |
# Submits the form. |
|
7 |
# |
|
8 |
# This method should be avoided - invoke the user interface element that triggers the submit instead. |
|
9 |
# |
|
10 |
||
11 |
def submit |
1 |
12 |
assert_exists |
1 |
13 |
@element.submit |
1 |
14 |
end |
|
15 |
||
16 |
end # Form |
|
17 |
end # Watir |
./lib/watir-webdriver/elements/frame.rb94.12 % covered |
||
# | Hits | |
---|---|---|
1 |
# encoding: utf-8 |
|
2 |
module Watir |
1 |
3 |
class Frame < HTMLElement |
1 |
4 |
||
5 |
def locate |
1 |
6 |
@parent.assert_exists |
89 |
7 |
||
8 |
element = locate_iframe || locate_frame |
89 |
9 |
element or raise UnknownFrameException, "unable to locate frame/iframe using #{selector_string}" |
87 |
10 |
||
11 |
FramedDriver.new(element, driver) |
74 |
12 |
end |
|
13 |
||
14 |
def assert_exists |
1 |
15 |
if element = @selector[:element] |
102 |
16 |
@parent.assert_exists |
13 |
17 |
@element = FramedDriver.new(element, driver) |
13 |
18 |
else |
|
19 |
@element = nil |
89 |
20 |
end |
|
21 |
||
22 |
super |
102 |
23 |
end |
|
24 |
||
25 |
def execute_script(*args) |
1 |
26 |
browser.execute_script(*args) |
1 |
27 |
end |
|
28 |
||
29 |
def element_by_xpath(*args) |
1 |
30 |
assert_exists |
0 |
31 |
super |
0 |
32 |
end |
|
33 |
||
34 |
def elements_by_xpath(*args) |
1 |
35 |
assert_exists |
2 |
36 |
super |
2 |
37 |
end |
|
38 |
||
39 |
private |
1 |
40 |
||
41 |
def locate_iframe |
1 |
42 |
# hack - frame doesn't have IFrame's attributes either |
|
43 |
IFrame.new(@parent, @selector.merge(:tag_name => "iframe")).locate |
89 |
44 |
end |
|
45 |
||
46 |
def locate_frame |
1 |
47 |
locator = locator_class.new(@parent.wd, @selector.merge(:tag_name => "frame"), self.class.attribute_list) |
65 |
48 |
locator.locate |
65 |
49 |
end |
|
50 |
end # Frame |
|
51 |
||
52 |
module Container |
1 |
53 |
def frame(*args) |
1 |
54 |
Frame.new(self, extract_selector(args)) |
63 |
55 |
end |
|
56 |
||
57 |
def frames(*args) |
1 |
58 |
FrameCollection.new(self, extract_selector(args).merge(:tag_name => /^(iframe|frame)$/)) # hack |
7 |
59 |
end |
|
60 |
end |
|
61 |
||
62 |
# @api private |
|
63 |
# |
|
64 |
# another hack.. |
|
65 |
# |
|
66 |
||
67 |
class FramedDriver |
1 |
68 |
def initialize(element, driver) |
1 |
69 |
@element = element |
87 |
70 |
@driver = driver |
87 |
71 |
end |
|
72 |
|
|
73 |
def ==(other) |
1 |
74 |
@element == other.element |
1 |
75 |
end |
|
76 |
alias_method :eql?, :== |
1 |
77 |
|
|
78 |
protected |
1 |
79 |
|
|
80 |
def element |
1 |
81 |
@element |
1 |
82 |
end |
|
83 |
|
|
84 |
private |
1 |
85 |
||
86 |
def method_missing(meth, *args, &blk) |
1 |
87 |
if @driver.respond_to?(meth) |
42 |
88 |
switch! |
20 |
89 |
@driver.send(meth, *args, &blk) |
20 |
90 |
else |
|
91 |
@element.send(meth, *args, &blk) |
22 |
92 |
end |
|
93 |
end |
|
94 |
||
95 |
def switch! |
1 |
96 |
@driver.switch_to.frame @element |
20 |
97 |
rescue Selenium::WebDriver::Error::NoSuchFrameError => e |
|
98 |
raise UnknownFrameException, e.message |
0 |
99 |
end |
|
100 |
||
101 |
end # FramedDriver |
|
102 |
end # Watir |
./lib/watir-webdriver/elements/generated.rb80.58 % covered |
||
# | Hits | |
---|---|---|
1 |
# Autogenerated from the HTML5 specification. Edits may be lost. |
|
2 |
module Watir |
1 |
3 |
||
4 |
||
5 |
||
6 |
||
7 |
||
8 |
||
9 |
||
10 |
||
11 |
||
12 |
||
13 |
||
14 |
||
15 |
||
16 |
||
17 |
||
18 |
||
19 |
||
20 |
||
21 |
||
22 |
||
23 |
||
24 |
||
25 |
||
26 |
||
27 |
||
28 |
||
29 |
||
30 |
||
31 |
||
32 |
||
33 |
||
34 |
||
35 |
||
36 |
||
37 |
||
38 |
||
39 |
||
40 |
||
41 |
||
42 |
||
43 |
||
44 |
||
45 |
||
46 |
class HTMLElement < Element |
1 |
47 |
attributes(:string => [:innerhtml, :outerhtml, :id, :title, :lang, :dir, :class_name, :item_type, :item_id, :item_value, :access_key, :access_key_label, :content_editable, :command_type, :label, :icon], :token_list => [:class_list, :item_ref, :item_prop, :dropzone], :string_map => [:dataset], :bool => [:item_scope, :hidden, :draggable, :is_content_editable, :spellcheck, :disabled, :checked], :properties_collection => [:properties], :int => [:tab_index], :html_element => [:context_menu], :style => [:style], :function => [:onabort, :onblur, :oncanplay, :oncanplaythrough, :onchange, :onclick, :oncontextmenu, :oncuechange, :ondblclick, :ondrag, :ondragend, :ondragenter, :ondragleave, :ondragover, :ondragstart, :ondrop, :ondurationchange, :onemptied, :onended, :onerror, :onfocus, :onformchange, :onforminput, :oninput, :oninvalid, :onkeydown, :onkeypress, :onkeyup, :onload, :onloadeddata, :onloadedmetadata, :onloadstart, :onmousedown, :onmousemove, :onmouseout, :onmouseover, :onmouseup, :onmousewheel, :onpause, :onplay, :onplaying, :onprogress, :onratechange, :onreadystatechange, :onreset, :onscroll, :onseeked, :onseeking, :onselect, :onshow, :onstalled, :onsubmit, :onsuspend, :ontimeupdate, :onvolumechange, :onwaiting]) |
1 |
48 |
end |
|
49 |
class HTMLElementCollection < ElementCollection |
1 |
50 |
def element_class |
1 |
51 |
HTMLElement |
72 |
52 |
end |
|
53 |
end |
|
54 |
class Font < HTMLElement |
1 |
55 |
attributes(:string => [:color, :face, :size]) |
1 |
56 |
end |
|
57 |
class FontCollection < ElementCollection |
1 |
58 |
def element_class |
1 |
59 |
Font |
1 |
60 |
end |
|
61 |
end |
|
62 |
class Directory < HTMLElement |
1 |
63 |
attributes(:bool => [:compact]) |
1 |
64 |
end |
|
65 |
class DirectoryCollection < ElementCollection |
1 |
66 |
def element_class |
1 |
67 |
Directory |
0 |
68 |
end |
|
69 |
end |
|
70 |
class BaseFont < HTMLElement |
1 |
71 |
attributes(:string => [:color, :face], :int => [:size]) |
1 |
72 |
end |
|
73 |
class BaseFontCollection < ElementCollection |
1 |
74 |
def element_class |
1 |
75 |
BaseFont |
0 |
76 |
end |
|
77 |
end |
|
78 |
class Frame < HTMLElement |
1 |
79 |
attributes(:string => [:frame_border, :long_desc, :margin_height, :margin_width, :name, :scrolling, :src, :content_window], :bool => [:no_resize], :document => [:content_document]) |
1 |
80 |
end |
|
81 |
class FrameCollection < ElementCollection |
1 |
82 |
def element_class |
1 |
83 |
Frame |
16 |
84 |
end |
|
85 |
end |
|
86 |
class FrameSet < HTMLElement |
1 |
87 |
attributes(:string => [:cols, :rows], :function => [:onafterprint, :onbeforeprint, :onbeforeunload, :onblur, :onerror, :onfocus, :onhashchange, :onload, :onmessage, :onoffline, :ononline, :onpagehide, :onpageshow, :onpopstate, :onredo, :onresize, :onscroll, :onstorage, :onundo, :onunload]) |
1 |
88 |
end |
|
89 |
class FrameSetCollection < ElementCollection |
1 |
90 |
def element_class |
1 |
91 |
FrameSet |
0 |
92 |
end |
|
93 |
end |
|
94 |
class Marquee < HTMLElement |
1 |
95 |
attributes(:string => [:behavior, :bg_color, :direction, :height, :width], :int => [:hspace, :loop, :scroll_amount, :scroll_delay, :vspace], :bool => [:true_speed], :function => [:onbounce, :onfinish, :onstart]) |
1 |
96 |
end |
|
97 |
class MarqueeCollection < ElementCollection |
1 |
98 |
def element_class |
1 |
99 |
Marquee |
0 |
100 |
end |
|
101 |
end |
|
102 |
class Applet < HTMLElement |
1 |
103 |
attributes(:string => [:align, :alt, :archive, :code, :code_base, :height, :name, :object, :width], :int => [:hspace, :vspace]) |
1 |
104 |
end |
|
105 |
class AppletCollection < ElementCollection |
1 |
106 |
def element_class |
1 |
107 |
Applet |
0 |
108 |
end |
|
109 |
end |
|
110 |
class Device < HTMLElement |
1 |
111 |
attributes(:string => [:type, :data]) |
1 |
112 |
end |
|
113 |
class DeviceCollection < ElementCollection |
1 |
114 |
def element_class |
1 |
115 |
Device |
0 |
116 |
end |
|
117 |
end |
|
118 |
class Menu < HTMLElement |
1 |
119 |
attributes(:string => [:type, :label]) |
1 |
120 |
end |
|
121 |
class MenuCollection < ElementCollection |
1 |
122 |
def element_class |
1 |
123 |
Menu |
0 |
124 |
end |
|
125 |
end |
|
126 |
class Menu < HTMLElement |
1 |
127 |
attributes(:bool => [:compact]) |
1 |
128 |
end |
|
129 |
# do nothing |
|
130 |
class Command < HTMLElement |
1 |
131 |
attributes(:string => [:type, :label, :icon, :radiogroup], :bool => [:disabled, :checked]) |
1 |
132 |
end |
|
133 |
class CommandCollection < ElementCollection |
1 |
134 |
def element_class |
1 |
135 |
Command |
0 |
136 |
end |
|
137 |
end |
|
138 |
class Details < HTMLElement |
1 |
139 |
attributes(:bool => [:open]) |
1 |
140 |
end |
|
141 |
class DetailsCollection < ElementCollection |
1 |
142 |
def element_class |
1 |
143 |
Details |
0 |
144 |
end |
|
145 |
end |
|
146 |
class Meter < HTMLElement |
1 |
147 |
attributes(:float => [:value, :min, :max, :low, :high, :optimum], :html_element => [:form], :list => [:labels]) |
1 |
148 |
end |
|
149 |
class MeterCollection < ElementCollection |
1 |
150 |
def element_class |
1 |
151 |
Meter |
0 |
152 |
end |
|
153 |
end |
|
154 |
class Progress < HTMLElement |
1 |
155 |
attributes(:float => [:value, :max, :position], :html_element => [:form], :list => [:labels]) |
1 |
156 |
end |
|
157 |
class ProgressCollection < ElementCollection |
1 |
158 |
def element_class |
1 |
159 |
Progress |
0 |
160 |
end |
|
161 |
end |
|
162 |
class Output < HTMLElement |
1 |
163 |
attributes(:token_list => [:html_for], :html_element => [:form], :string => [:name, :type, :default_value, :value, :validity, :validation_message], :bool => [:will_validate], :list => [:labels]) |
1 |
164 |
end |
|
165 |
class OutputCollection < ElementCollection |
1 |
166 |
def element_class |
1 |
167 |
Output |
0 |
168 |
end |
|
169 |
end |
|
170 |
class Keygen < HTMLElement |
1 |
171 |
attributes(:bool => [:autofocus, :disabled, :will_validate], :string => [:challenge, :keytype, :name, :type, :validity, :validation_message], :html_element => [:form], :list => [:labels]) |
1 |
172 |
end |
|
173 |
class KeygenCollection < ElementCollection |
1 |
174 |
def element_class |
1 |
175 |
Keygen |
0 |
176 |
end |
|
177 |
end |
|
178 |
class TextArea < HTMLElement |
1 |
179 |
attributes(:bool => [:autofocus, :disabled, :read_only, :required, :will_validate], :int => [:cols, :max_length, :rows, :text_length, :selection_start, :selection_end], :string => [:dir_name, :name, :placeholder, :wrap, :type, :default_value, :value, :validity, :validation_message], :html_element => [:form], :list => [:labels]) |
1 |
180 |
end |
|
181 |
class TextAreaCollection < ElementCollection |
1 |
182 |
def element_class |
1 |
183 |
TextArea |
0 |
184 |
end |
|
185 |
end |
|
186 |
class Option < HTMLElement |
1 |
187 |
attributes(:bool => [:disabled, :default_selected, :selected], :html_element => [:form], :string => [:label, :value, :text], :int => [:index]) |
1 |
188 |
end |
|
189 |
class OptionCollection < ElementCollection |
1 |
190 |
def element_class |
1 |
191 |
Option |
221 |
192 |
end |
|
193 |
end |
|
194 |
class OptGroup < HTMLElement |
1 |
195 |
attributes(:bool => [:disabled], :string => [:label]) |
1 |
196 |
end |
|
197 |
class OptGroupCollection < ElementCollection |
1 |
198 |
def element_class |
1 |
199 |
OptGroup |
0 |
200 |
end |
|
201 |
end |
|
202 |
class DataList < HTMLElement |
1 |
203 |
attributes(:html_collection => [:options]) |
1 |
204 |
end |
|
205 |
class DataListCollection < ElementCollection |
1 |
206 |
def element_class |
1 |
207 |
DataList |
0 |
208 |
end |
|
209 |
end |
|
210 |
class Select < HTMLElement |
1 |
211 |
attributes(:bool => [:autofocus, :disabled, :multiple, :required, :will_validate], :html_element => [:form], :string => [:name, :type, :value, :validity, :validation_message], :int => [:size, :length, :selected_index], :html_collection => [:options, :selected_options], :list => [:labels]) |
1 |
212 |
end |
|
213 |
class SelectCollection < ElementCollection |
1 |
214 |
def element_class |
1 |
215 |
Select |
33 |
216 |
end |
|
217 |
end |
|
218 |
class Button < HTMLElement |
1 |
219 |
attributes(:bool => [:autofocus, :disabled, :will_validate], :html_element => [:form], :string => [:form_action, :form_enctype, :form_method, :form_no_validate, :form_target, :name, :type, :value, :validity, :validation_message], :list => [:labels]) |
1 |
220 |
end |
|
221 |
class ButtonCollection < ElementCollection |
1 |
222 |
def element_class |
1 |
223 |
Button |
0 |
224 |
end |
|
225 |
end |
|
226 |
class Input < HTMLElement |
1 |
227 |
attributes(:string => [:accept, :alt, :autocomplete, :dir_name, :form_action, :form_enctype, :form_method, :form_target, :height, :max, :min, :name, :pattern, :placeholder, :src, :step, :type, :default_value, :value, :width, :validity, :validation_message], :bool => [:autofocus, :default_checked, :checked, :disabled, :form_no_validate, :indeterminate, :multiple, :read_only, :required, :will_validate], :html_element => [:form, :list, :selected_option], :list => [:files, :labels], :int => [:max_length, :size, :selection_start, :selection_end], :date => [:value_as_date], :float => [:value_as_number]) |
1 |
228 |
end |
|
229 |
class InputCollection < ElementCollection |
1 |
230 |
def element_class |
1 |
231 |
Input |
0 |
232 |
end |
|
233 |
end |
|
234 |
class Input < HTMLElement |
1 |
235 |
attributes(:string => [:align, :use_map]) |
1 |
236 |
end |
|
237 |
# do nothing |
|
238 |
class Label < HTMLElement |
1 |
239 |
attributes(:html_element => [:form, :control], :string => [:html_for]) |
1 |
240 |
end |
|
241 |
class LabelCollection < ElementCollection |
1 |
242 |
def element_class |
1 |
243 |
Label |
57 |
244 |
end |
|
245 |
end |
|
246 |
class Legend < HTMLElement |
1 |
247 |
attributes(:html_element => [:form]) |
1 |
248 |
end |
|
249 |
class LegendCollection < ElementCollection |
1 |
250 |
def element_class |
1 |
251 |
Legend |
0 |
252 |
end |
|
253 |
end |
|
254 |
class Legend < HTMLElement |
1 |
255 |
attributes(:string => [:align]) |
1 |
256 |
end |
|
257 |
# do nothing |
|
258 |
class FieldSet < HTMLElement |
1 |
259 |
attributes(:bool => [:disabled, :will_validate], :html_element => [:form], :string => [:name, :type, :validity, :validation_message], :html_collection => [:elements]) |
1 |
260 |
end |
|
261 |
class FieldSetCollection < ElementCollection |
1 |
262 |
def element_class |
1 |
263 |
FieldSet |
0 |
264 |
end |
|
265 |
end |
|
266 |
class Form < HTMLElement |
1 |
267 |
attributes(:string => [:accept_charset, :action, :autocomplete, :enctype, :encoding, :method, :name, :target], :bool => [:no_validate], :html_collection => [:elements], :int => [:length]) |
1 |
268 |
end |
|
269 |
class FormCollection < ElementCollection |
1 |
270 |
def element_class |
1 |
271 |
Form |
12 |
272 |
end |
|
273 |
end |
|
274 |
class TableCell < HTMLElement |
1 |
275 |
attributes(:int => [:col_span, :row_span, :cell_index], :token_list => [:headers]) |
1 |
276 |
end |
|
277 |
class TableCellCollection < ElementCollection |
1 |
278 |
def element_class |
1 |
279 |
TableCell |
103 |
280 |
end |
|
281 |
end |
|
282 |
class TableCell < HTMLElement |
1 |
283 |
attributes(:string => [:abbr, :align, :axis, :bg_color, :ch, :ch_off, :height, :v_align, :width], :bool => [:no_wrap]) |
1 |
284 |
end |
|
285 |
# do nothing |
|
286 |
class TableHeaderCell < TableCell |
1 |
287 |
attributes(:string => [:scope]) |
1 |
288 |
end |
|
289 |
class TableHeaderCellCollection < ElementCollection |
1 |
290 |
def element_class |
1 |
291 |
TableHeaderCell |
5 |
292 |
end |
|
293 |
end |
|
294 |
class TableDataCell < TableCell |
1 |
295 |
# do nothing |
|
296 |
end |
|
297 |
class TableDataCellCollection < ElementCollection |
1 |
298 |
def element_class |
1 |
299 |
TableDataCell |
36 |
300 |
end |
|
301 |
end |
|
302 |
class TableRow < HTMLElement |
1 |
303 |
attributes(:int => [:row_index, :section_row_index], :html_collection => [:cells]) |
1 |
304 |
end |
|
305 |
class TableRowCollection < ElementCollection |
1 |
306 |
def element_class |
1 |
307 |
TableRow |
130 |
308 |
end |
|
309 |
end |
|
310 |
class TableRow < HTMLElement |
1 |
311 |
attributes(:string => [:align, :bg_color, :ch, :ch_off, :v_align]) |
1 |
312 |
end |
|
313 |
# do nothing |
|
314 |
class TableSection < HTMLElement |
1 |
315 |
attributes(:html_collection => [:rows]) |
1 |
316 |
end |
|
317 |
class TableSectionCollection < ElementCollection |
1 |
318 |
def element_class |
1 |
319 |
TableSection |
66 |
320 |
end |
|
321 |
end |
|
322 |
class TableSection < HTMLElement |
1 |
323 |
attributes(:string => [:align, :ch, :ch_off, :v_align]) |
1 |
324 |
end |
|
325 |
# do nothing |
|
326 |
class TableCol < HTMLElement |
1 |
327 |
attributes(:int => [:span]) |
1 |
328 |
end |
|
329 |
class TableColCollection < ElementCollection |
1 |
330 |
def element_class |
1 |
331 |
TableCol |
0 |
332 |
end |
|
333 |
end |
|
334 |
class TableCol < HTMLElement |
1 |
335 |
attributes(:string => [:align, :ch, :ch_off, :v_align, :width]) |
1 |
336 |
end |
|
337 |
# do nothing |
|
338 |
class TableCaption < HTMLElement |
1 |
339 |
# do nothing |
|
340 |
end |
|
341 |
class TableCaptionCollection < ElementCollection |
1 |
342 |
def element_class |
1 |
343 |
TableCaption |
0 |
344 |
end |
|
345 |
end |
|
346 |
class TableCaption < HTMLElement |
1 |
347 |
attributes(:string => [:align]) |
1 |
348 |
end |
|
349 |
# do nothing |
|
350 |
class Table < HTMLElement |
1 |
351 |
attributes(:html_element => [:caption, :t_head, :t_foot], :html_collection => [:t_bodies, :rows], :string => [:summary]) |
1 |
352 |
end |
|
353 |
class TableCollection < ElementCollection |
1 |
354 |
def element_class |
1 |
355 |
Table |
48 |
356 |
end |
|
357 |
end |
|
358 |
class Table < HTMLElement |
1 |
359 |
attributes(:string => [:align, :bg_color, :border, :cell_padding, :cell_spacing, :frame, :rules, :width]) |
1 |
360 |
end |
|
361 |
# do nothing |
|
362 |
class Area < HTMLElement |
1 |
363 |
attributes(:string => [:alt, :coords, :shape, :href, :target, :ping, :rel, :media, :hreflang, :type, :protocol, :host, :hostname, :port, :pathname, :search, :hash], :token_list => [:rel_list]) |
1 |
364 |
end |
|
365 |
class AreaCollection < ElementCollection |
1 |
366 |
def element_class |
1 |
367 |
Area |
11 |
368 |
end |
|
369 |
end |
|
370 |
class Area < HTMLElement |
1 |
371 |
attributes(:bool => [:no_href]) |
1 |
372 |
end |
|
373 |
# do nothing |
|
374 |
class Map < HTMLElement |
1 |
375 |
attributes(:string => [:name], :html_collection => [:areas, :images]) |
1 |
376 |
end |
|
377 |
class MapCollection < ElementCollection |
1 |
378 |
def element_class |
1 |
379 |
Map |
9 |
380 |
end |
|
381 |
end |
|
382 |
class Canvas < HTMLElement |
1 |
383 |
attributes(:int => [:width, :height]) |
1 |
384 |
end |
|
385 |
class CanvasCollection < ElementCollection |
1 |
386 |
def element_class |
1 |
387 |
Canvas |
0 |
388 |
end |
|
389 |
end |
|
390 |
class Media < HTMLElement |
1 |
391 |
attributes(:string => [:error, :src, :current_src, :preload, :buffered, :played, :seekable, :tracks], :int => [:network_state, :ready_state], :bool => [:seeking, :paused, :ended, :autoplay, :loop, :controls, :muted], :float => [:current_time, :initial_time, :duration, :default_playback_rate, :playback_rate, :volume], :date => [:start_offset_time]) |
1 |
392 |
end |
|
393 |
class MediaCollection < ElementCollection |
1 |
394 |
def element_class |
1 |
395 |
Media |
0 |
396 |
end |
|
397 |
end |
|
398 |
class Audio < Media |
1 |
399 |
# do nothing |
|
400 |
end |
|
401 |
class AudioCollection < ElementCollection |
1 |
402 |
def element_class |
1 |
403 |
Audio |
0 |
404 |
end |
|
405 |
end |
|
406 |
class Video < Media |
1 |
407 |
attributes(:int => [:width, :height, :video_width, :video_height], :string => [:poster], :token_list => [:audio]) |
1 |
408 |
end |
|
409 |
class VideoCollection < ElementCollection |
1 |
410 |
def element_class |
1 |
411 |
Video |
0 |
412 |
end |
|
413 |
end |
|
414 |
class Track < HTMLElement |
1 |
415 |
attributes(:string => [:kind, :src, :srclang, :label, :track], :bool => [:default]) |
1 |
416 |
end |
|
417 |
class TrackCollection < ElementCollection |
1 |
418 |
def element_class |
1 |
419 |
Track |
0 |
420 |
end |
|
421 |
end |
|
422 |
class Source < HTMLElement |
1 |
423 |
attributes(:string => [:src, :type, :media]) |
1 |
424 |
end |
|
425 |
class SourceCollection < ElementCollection |
1 |
426 |
def element_class |
1 |
427 |
Source |
0 |
428 |
end |
|
429 |
end |
|
430 |
class Param < HTMLElement |
1 |
431 |
attributes(:string => [:name, :value]) |
1 |
432 |
end |
|
433 |
class ParamCollection < ElementCollection |
1 |
434 |
def element_class |
1 |
435 |
Param |
0 |
436 |
end |
|
437 |
end |
|
438 |
class Param < HTMLElement |
1 |
439 |
attributes(:string => [:type, :value_type]) |
1 |
440 |
end |
|
441 |
# do nothing |
|
442 |
class Object < HTMLElement |
1 |
443 |
attributes(:string => [:data, :type, :name, :use_map, :width, :height, :content_window, :validity, :validation_message], :html_element => [:form], :document => [:content_document], :bool => [:will_validate]) |
1 |
444 |
end |
|
445 |
class ObjectCollection < ElementCollection |
1 |
446 |
def element_class |
1 |
447 |
Object |
0 |
448 |
end |
|
449 |
end |
|
450 |
class Object < HTMLElement |
1 |
451 |
attributes(:string => [:align, :archive, :border, :code, :code_base, :code_type, :standby], :bool => [:declare], :int => [:hspace, :vspace]) |
1 |
452 |
end |
|
453 |
# do nothing |
|
454 |
class Embed < HTMLElement |
1 |
455 |
attributes(:string => [:src, :type, :width, :height]) |
1 |
456 |
end |
|
457 |
class EmbedCollection < ElementCollection |
1 |
458 |
def element_class |
1 |
459 |
Embed |
0 |
460 |
end |
|
461 |
end |
|
462 |
class Embed < HTMLElement |
1 |
463 |
attributes(:string => [:align, :name]) |
1 |
464 |
end |
|
465 |
# do nothing |
|
466 |
class IFrame < HTMLElement |
1 |
467 |
attributes(:string => [:src, :srcdoc, :name, :width, :height, :content_window], :token_list => [:sandbox], :bool => [:seamless], :document => [:content_document]) |
1 |
468 |
end |
|
469 |
class IFrameCollection < ElementCollection |
1 |
470 |
def element_class |
1 |
471 |
IFrame |
0 |
472 |
end |
|
473 |
end |
|
474 |
class IFrame < HTMLElement |
1 |
475 |
attributes(:string => [:align, :frame_border, :long_desc, :margin_height, :margin_width, :scrolling]) |
1 |
476 |
end |
|
477 |
# do nothing |
|
478 |
class Image < HTMLElement |
1 |
479 |
attributes(:string => [:alt, :src, :use_map], :bool => [:is_map, :complete], :int => [:width, :height, :natural_width, :natural_height]) |
1 |
480 |
end |
|
481 |
class ImageCollection < ElementCollection |
1 |
482 |
def element_class |
1 |
483 |
Image |
25 |
484 |
end |
|
485 |
end |
|
486 |
class Image < HTMLElement |
1 |
487 |
attributes(:string => [:name, :align, :border, :long_desc], :int => [:hspace, :vspace]) |
1 |
488 |
end |
|
489 |
# do nothing |
|
490 |
class Mod < HTMLElement |
1 |
491 |
attributes(:string => [:cite, :date_time]) |
1 |
492 |
end |
|
493 |
class ModCollection < ElementCollection |
1 |
494 |
def element_class |
1 |
495 |
Mod |
30 |
496 |
end |
|
497 |
end |
|
498 |
class BR < HTMLElement |
1 |
499 |
# do nothing |
|
500 |
end |
|
501 |
class BRCollection < ElementCollection |
1 |
502 |
def element_class |
1 |
503 |
BR |
0 |
504 |
end |
|
505 |
end |
|
506 |
class BR < HTMLElement |
1 |
507 |
attributes(:string => [:clear]) |
1 |
508 |
end |
|
509 |
# do nothing |
|
510 |
class Span < HTMLElement |
1 |
511 |
# do nothing |
|
512 |
end |
|
513 |
class SpanCollection < ElementCollection |
1 |
514 |
def element_class |
1 |
515 |
Span |
18 |
516 |
end |
|
517 |
end |
|
518 |
class Time < HTMLElement |
1 |
519 |
attributes(:string => [:date_time], :bool => [:pub_date], :date => [:value_as_date]) |
1 |
520 |
end |
|
521 |
class TimeCollection < ElementCollection |
1 |
522 |
def element_class |
1 |
523 |
Time |
0 |
524 |
end |
|
525 |
end |
|
526 |
class Anchor < HTMLElement |
1 |
527 |
attributes(:string => [:href, :target, :ping, :rel, :media, :hreflang, :type, :text, :protocol, :host, :hostname, :port, :pathname, :search, :hash], :token_list => [:rel_list]) |
1 |
528 |
end |
|
529 |
class AnchorCollection < ElementCollection |
1 |
530 |
def element_class |
1 |
531 |
Anchor |
19 |
532 |
end |
|
533 |
end |
|
534 |
class Anchor < HTMLElement |
1 |
535 |
attributes(:string => [:coords, :charset, :name, :rev, :shape]) |
1 |
536 |
end |
|
537 |
# do nothing |
|
538 |
class Div < HTMLElement |
1 |
539 |
# do nothing |
|
540 |
end |
|
541 |
class DivCollection < ElementCollection |
1 |
542 |
def element_class |
1 |
543 |
Div |
64 |
544 |
end |
|
545 |
end |
|
546 |
class Div < HTMLElement |
1 |
547 |
attributes(:string => [:align]) |
1 |
548 |
end |
|
549 |
# do nothing |
|
550 |
class DList < HTMLElement |
1 |
551 |
# do nothing |
|
552 |
end |
|
553 |
class DListCollection < ElementCollection |
1 |
554 |
def element_class |
1 |
555 |
DList |
19 |
556 |
end |
|
557 |
end |
|
558 |
class DList < HTMLElement |
1 |
559 |
attributes(:bool => [:compact]) |
1 |
560 |
end |
|
561 |
# do nothing |
|
562 |
class LI < HTMLElement |
1 |
563 |
attributes(:int => [:value]) |
1 |
564 |
end |
|
565 |
class LICollection < ElementCollection |
1 |
566 |
def element_class |
1 |
567 |
LI |
41 |
568 |
end |
|
569 |
end |
|
570 |
class LI < HTMLElement |
1 |
571 |
attributes(:string => [:type]) |
1 |
572 |
end |
|
573 |
# do nothing |
|
574 |
class UList < HTMLElement |
1 |
575 |
# do nothing |
|
576 |
end |
|
577 |
class UListCollection < ElementCollection |
1 |
578 |
def element_class |
1 |
579 |
UList |
9 |
580 |
end |
|
581 |
end |
|
582 |
class UList < HTMLElement |
1 |
583 |
attributes(:bool => [:compact], :string => [:type]) |
1 |
584 |
end |
|
585 |
# do nothing |
|
586 |
class OList < HTMLElement |
1 |
587 |
attributes(:bool => [:reversed], :int => [:start], :string => [:type]) |
1 |
588 |
end |
|
589 |
class OListCollection < ElementCollection |
1 |
590 |
def element_class |
1 |
591 |
OList |
9 |
592 |
end |
|
593 |
end |
|
594 |
class OList < HTMLElement |
1 |
595 |
attributes(:bool => [:compact]) |
1 |
596 |
end |
|
597 |
# do nothing |
|
598 |
class Quote < HTMLElement |
1 |
599 |
attributes(:string => [:cite]) |
1 |
600 |
end |
|
601 |
class QuoteCollection < ElementCollection |
1 |
602 |
def element_class |
1 |
603 |
Quote |
0 |
604 |
end |
|
605 |
end |
|
606 |
class Pre < HTMLElement |
1 |
607 |
# do nothing |
|
608 |
end |
|
609 |
class PreCollection < ElementCollection |
1 |
610 |
def element_class |
1 |
611 |
Pre |
19 |
612 |
end |
|
613 |
end |
|
614 |
class Pre < HTMLElement |
1 |
615 |
attributes(:int => [:width]) |
1 |
616 |
end |
|
617 |
# do nothing |
|
618 |
class HR < HTMLElement |
1 |
619 |
# do nothing |
|
620 |
end |
|
621 |
class HRCollection < ElementCollection |
1 |
622 |
def element_class |
1 |
623 |
HR |
0 |
624 |
end |
|
625 |
end |
|
626 |
class HR < HTMLElement |
1 |
627 |
attributes(:string => [:align, :color, :size, :width], :bool => [:no_shade]) |
1 |
628 |
end |
|
629 |
# do nothing |
|
630 |
class Paragraph < HTMLElement |
1 |
631 |
# do nothing |
|
632 |
end |
|
633 |
class ParagraphCollection < ElementCollection |
1 |
634 |
def element_class |
1 |
635 |
Paragraph |
16 |
636 |
end |
|
637 |
end |
|
638 |
class Paragraph < HTMLElement |
1 |
639 |
attributes(:string => [:align]) |
1 |
640 |
end |
|
641 |
# do nothing |
|
642 |
class Heading < HTMLElement |
1 |
643 |
# do nothing |
|
644 |
end |
|
645 |
class HeadingCollection < ElementCollection |
1 |
646 |
def element_class |
1 |
647 |
Heading |
29 |
648 |
end |
|
649 |
end |
|
650 |
class Heading < HTMLElement |
1 |
651 |
attributes(:string => [:align]) |
1 |
652 |
end |
|
653 |
# do nothing |
|
654 |
class Body < HTMLElement |
1 |
655 |
attributes(:function => [:onafterprint, :onbeforeprint, :onbeforeunload, :onblur, :onerror, :onfocus, :onhashchange, :onload, :onmessage, :onoffline, :ononline, :onpopstate, :onpagehide, :onpageshow, :onredo, :onresize, :onscroll, :onstorage, :onundo, :onunload]) |
1 |
656 |
end |
|
657 |
class BodyCollection < ElementCollection |
1 |
658 |
def element_class |
1 |
659 |
Body |
0 |
660 |
end |
|
661 |
end |
|
662 |
class Body < HTMLElement |
1 |
663 |
attributes(:string => [:text, :bg_color, :background, :link, :v_link, :a_link]) |
1 |
664 |
end |
|
665 |
# do nothing |
|
666 |
class Script < HTMLElement |
1 |
667 |
attributes(:string => [:src, :type, :charset, :text], :bool => [:async, :defer]) |
1 |
668 |
end |
|
669 |
class ScriptCollection < ElementCollection |
1 |
670 |
def element_class |
1 |
671 |
Script |
0 |
672 |
end |
|
673 |
end |
|
674 |
class Script < HTMLElement |
1 |
675 |
attributes(:string => [:event, :html_for]) |
1 |
676 |
end |
|
677 |
# do nothing |
|
678 |
class Style < HTMLElement |
1 |
679 |
attributes(:bool => [:disabled, :scoped], :string => [:media, :type]) |
1 |
680 |
end |
|
681 |
class StyleCollection < ElementCollection |
1 |
682 |
def element_class |
1 |
683 |
Style |
0 |
684 |
end |
|
685 |
end |
|
686 |
class Meta < HTMLElement |
1 |
687 |
attributes(:string => [:name, :http_equiv, :content]) |
1 |
688 |
end |
|
689 |
class MetaCollection < ElementCollection |
1 |
690 |
def element_class |
1 |
691 |
Meta |
9 |
692 |
end |
|
693 |
end |
|
694 |
class Meta < HTMLElement |
1 |
695 |
attributes(:string => [:scheme]) |
1 |
696 |
end |
|
697 |
# do nothing |
|
698 |
class Base < HTMLElement |
1 |
699 |
attributes(:string => [:href, :target]) |
1 |
700 |
end |
|
701 |
class BaseCollection < ElementCollection |
1 |
702 |
def element_class |
1 |
703 |
Base |
0 |
704 |
end |
|
705 |
end |
|
706 |
class Title < HTMLElement |
1 |
707 |
attributes(:string => [:text]) |
1 |
708 |
end |
|
709 |
class TitleCollection < ElementCollection |
1 |
710 |
def element_class |
1 |
711 |
Title |
0 |
712 |
end |
|
713 |
end |
|
714 |
class Head < HTMLElement |
1 |
715 |
# do nothing |
|
716 |
end |
|
717 |
class HeadCollection < ElementCollection |
1 |
718 |
def element_class |
1 |
719 |
Head |
0 |
720 |
end |
|
721 |
end |
|
722 |
class Html < HTMLElement |
1 |
723 |
# do nothing |
|
724 |
end |
|
725 |
class HtmlCollection < ElementCollection |
1 |
726 |
def element_class |
1 |
727 |
Html |
0 |
728 |
end |
|
729 |
end |
|
730 |
class Html < HTMLElement |
1 |
731 |
attributes(:string => [:version]) |
1 |
732 |
end |
|
733 |
# do nothing |
|
734 |
class Unknown < HTMLElement |
1 |
735 |
# do nothing |
|
736 |
end |
|
737 |
class UnknownCollection < ElementCollection |
1 |
738 |
def element_class |
1 |
739 |
Unknown |
0 |
740 |
end |
|
741 |
end |
|
742 |
||
743 |
||
744 |
||
745 |
||
746 |
||
747 |
||
748 |
||
749 |
||
750 |
||
751 |
||
752 |
||
753 |
||
754 |
||
755 |
||
756 |
||
757 |
module Container |
1 |
758 |
# |
|
759 |
# @return [Anchor] |
|
760 |
# |
|
761 |
||
762 |
def a(*args) |
1 |
763 |
Anchor.new(self, extract_selector(args).merge(:tag_name => "a")) |
86 |
764 |
end |
|
765 |
||
766 |
# |
|
767 |
# @return [AnchorCollection] |
|
768 |
# |
|
769 |
||
770 |
def as(*args) |
1 |
771 |
AnchorCollection.new(self, extract_selector(args).merge(:tag_name => "a")) |
5 |
772 |
end |
|
773 |
||
774 |
Watir.tag_to_class[:a] = Anchor |
1 |
775 |
# |
|
776 |
# @return [HTMLElement] |
|
777 |
# |
|
778 |
||
779 |
def abbr(*args) |
1 |
780 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "abbr")) |
0 |
781 |
end |
|
782 |
||
783 |
# |
|
784 |
# @return [HTMLElementCollection] |
|
785 |
# |
|
786 |
||
787 |
def abbrs(*args) |
1 |
788 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "abbr")) |
0 |
789 |
end |
|
790 |
||
791 |
Watir.tag_to_class[:abbr] = HTMLElement |
1 |
792 |
# |
|
793 |
# @return [HTMLElement] |
|
794 |
# |
|
795 |
||
796 |
def address(*args) |
1 |
797 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "address")) |
0 |
798 |
end |
|
799 |
||
800 |
# |
|
801 |
# @return [HTMLElementCollection] |
|
802 |
# |
|
803 |
||
804 |
def addresses(*args) |
1 |
805 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "address")) |
0 |
806 |
end |
|
807 |
||
808 |
Watir.tag_to_class[:address] = HTMLElement |
1 |
809 |
# |
|
810 |
# @return [Area] |
|
811 |
# |
|
812 |
||
813 |
def area(*args) |
1 |
814 |
Area.new(self, extract_selector(args).merge(:tag_name => "area")) |
31 |
815 |
end |
|
816 |
||
817 |
# |
|
818 |
# @return [AreaCollection] |
|
819 |
# |
|
820 |
||
821 |
def areas(*args) |
1 |
822 |
AreaCollection.new(self, extract_selector(args).merge(:tag_name => "area")) |
4 |
823 |
end |
|
824 |
||
825 |
Watir.tag_to_class[:area] = Area |
1 |
826 |
# |
|
827 |
# @return [HTMLElement] |
|
828 |
# |
|
829 |
||
830 |
def article(*args) |
1 |
831 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "article")) |
0 |
832 |
end |
|
833 |
||
834 |
# |
|
835 |
# @return [HTMLElementCollection] |
|
836 |
# |
|
837 |
||
838 |
def articles(*args) |
1 |
839 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "article")) |
0 |
840 |
end |
|
841 |
||
842 |
Watir.tag_to_class[:article] = HTMLElement |
1 |
843 |
# |
|
844 |
# @return [HTMLElement] |
|
845 |
# |
|
846 |
||
847 |
def aside(*args) |
1 |
848 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "aside")) |
0 |
849 |
end |
|
850 |
||
851 |
# |
|
852 |
# @return [HTMLElementCollection] |
|
853 |
# |
|
854 |
||
855 |
def asides(*args) |
1 |
856 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "aside")) |
0 |
857 |
end |
|
858 |
||
859 |
Watir.tag_to_class[:aside] = HTMLElement |
1 |
860 |
# |
|
861 |
# @return [Audio] |
|
862 |
# |
|
863 |
||
864 |
def audio(*args) |
1 |
865 |
Audio.new(self, extract_selector(args).merge(:tag_name => "audio")) |
0 |
866 |
end |
|
867 |
||
868 |
# |
|
869 |
# @return [AudioCollection] |
|
870 |
# |
|
871 |
||
872 |
def audios(*args) |
1 |
873 |
AudioCollection.new(self, extract_selector(args).merge(:tag_name => "audio")) |
0 |
874 |
end |
|
875 |
||
876 |
Watir.tag_to_class[:audio] = Audio |
1 |
877 |
# |
|
878 |
# @return [HTMLElement] |
|
879 |
# |
|
880 |
||
881 |
def b(*args) |
1 |
882 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "b")) |
0 |
883 |
end |
|
884 |
||
885 |
# |
|
886 |
# @return [HTMLElementCollection] |
|
887 |
# |
|
888 |
||
889 |
def bs(*args) |
1 |
890 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "b")) |
0 |
891 |
end |
|
892 |
||
893 |
Watir.tag_to_class[:b] = HTMLElement |
1 |
894 |
# |
|
895 |
# @return [Base] |
|
896 |
# |
|
897 |
||
898 |
def base(*args) |
1 |
899 |
Base.new(self, extract_selector(args).merge(:tag_name => "base")) |
0 |
900 |
end |
|
901 |
||
902 |
# |
|
903 |
# @return [BaseCollection] |
|
904 |
# |
|
905 |
||
906 |
def bases(*args) |
1 |
907 |
BaseCollection.new(self, extract_selector(args).merge(:tag_name => "base")) |
0 |
908 |
end |
|
909 |
||
910 |
Watir.tag_to_class[:base] = Base |
1 |
911 |
# |
|
912 |
# @return [HTMLElement] |
|
913 |
# |
|
914 |
||
915 |
def bdi(*args) |
1 |
916 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "bdi")) |
0 |
917 |
end |
|
918 |
||
919 |
# |
|
920 |
# @return [HTMLElementCollection] |
|
921 |
# |
|
922 |
||
923 |
def bdis(*args) |
1 |
924 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "bdi")) |
0 |
925 |
end |
|
926 |
||
927 |
Watir.tag_to_class[:bdi] = HTMLElement |
1 |
928 |
# |
|
929 |
# @return [HTMLElement] |
|
930 |
# |
|
931 |
||
932 |
def bdo(*args) |
1 |
933 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "bdo")) |
0 |
934 |
end |
|
935 |
||
936 |
# |
|
937 |
# @return [HTMLElementCollection] |
|
938 |
# |
|
939 |
||
940 |
def bdos(*args) |
1 |
941 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "bdo")) |
0 |
942 |
end |
|
943 |
||
944 |
Watir.tag_to_class[:bdo] = HTMLElement |
1 |
945 |
# |
|
946 |
# @return [Quote] |
|
947 |
# |
|
948 |
||
949 |
def blockquote(*args) |
1 |
950 |
Quote.new(self, extract_selector(args).merge(:tag_name => "blockquote")) |
0 |
951 |
end |
|
952 |
||
953 |
# |
|
954 |
# @return [QuoteCollection] |
|
955 |
# |
|
956 |
||
957 |
def blockquotes(*args) |
1 |
958 |
QuoteCollection.new(self, extract_selector(args).merge(:tag_name => "blockquote")) |
0 |
959 |
end |
|
960 |
||
961 |
Watir.tag_to_class[:blockquote] = Quote |
1 |
962 |
# |
|
963 |
# @return [Body] |
|
964 |
# |
|
965 |
||
966 |
def body(*args) |
1 |
967 |
Body.new(self, extract_selector(args).merge(:tag_name => "body")) |
0 |
968 |
end |
|
969 |
||
970 |
# |
|
971 |
# @return [BodyCollection] |
|
972 |
# |
|
973 |
||
974 |
def bodys(*args) |
1 |
975 |
BodyCollection.new(self, extract_selector(args).merge(:tag_name => "body")) |
0 |
976 |
end |
|
977 |
||
978 |
Watir.tag_to_class[:body] = Body |
1 |
979 |
# |
|
980 |
# @return [BR] |
|
981 |
# |
|
982 |
||
983 |
def br(*args) |
1 |
984 |
BR.new(self, extract_selector(args).merge(:tag_name => "br")) |
0 |
985 |
end |
|
986 |
||
987 |
# |
|
988 |
# @return [BRCollection] |
|
989 |
# |
|
990 |
||
991 |
def brs(*args) |
1 |
992 |
BRCollection.new(self, extract_selector(args).merge(:tag_name => "br")) |
0 |
993 |
end |
|
994 |
||
995 |
Watir.tag_to_class[:br] = BR |
1 |
996 |
# |
|
997 |
# @return [Button] |
|
998 |
# |
|
999 |
||
1000 |
def button(*args) |
1 |
1001 |
Button.new(self, extract_selector(args).merge(:tag_name => "button")) |
125 |
1002 |
end |
|
1003 |
||
1004 |
# |
|
1005 |
# @return [ButtonCollection] |
|
1006 |
# |
|
1007 |
||
1008 |
def buttons(*args) |
1 |
1009 |
ButtonCollection.new(self, extract_selector(args).merge(:tag_name => "button")) |
8 |
1010 |
end |
|
1011 |
||
1012 |
Watir.tag_to_class[:button] = Button |
1 |
1013 |
# |
|
1014 |
# @return [Canvas] |
|
1015 |
# |
|
1016 |
||
1017 |
def canvas(*args) |
1 |
1018 |
Canvas.new(self, extract_selector(args).merge(:tag_name => "canvas")) |
0 |
1019 |
end |
|
1020 |
||
1021 |
# |
|
1022 |
# @return [CanvasCollection] |
|
1023 |
# |
|
1024 |
||
1025 |
def canvases(*args) |
1 |
1026 |
CanvasCollection.new(self, extract_selector(args).merge(:tag_name => "canvas")) |
0 |
1027 |
end |
|
1028 |
||
1029 |
Watir.tag_to_class[:canvas] = Canvas |
1 |
1030 |
# |
|
1031 |
# @return [TableCaption] |
|
1032 |
# |
|
1033 |
||
1034 |
def caption(*args) |
1 |
1035 |
TableCaption.new(self, extract_selector(args).merge(:tag_name => "caption")) |
0 |
1036 |
end |
|
1037 |
||
1038 |
# |
|
1039 |
# @return [TableCaptionCollection] |
|
1040 |
# |
|
1041 |
||
1042 |
def captions(*args) |
1 |
1043 |
TableCaptionCollection.new(self, extract_selector(args).merge(:tag_name => "caption")) |
0 |
1044 |
end |
|
1045 |
||
1046 |
Watir.tag_to_class[:caption] = TableCaption |
1 |
1047 |
# |
|
1048 |
# @return [HTMLElement] |
|
1049 |
# |
|
1050 |
||
1051 |
def cite(*args) |
1 |
1052 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "cite")) |
0 |
1053 |
end |
|
1054 |
||
1055 |
# |
|
1056 |
# @return [HTMLElementCollection] |
|
1057 |
# |
|
1058 |
||
1059 |
def cites(*args) |
1 |
1060 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "cite")) |
0 |
1061 |
end |
|
1062 |
||
1063 |
Watir.tag_to_class[:cite] = HTMLElement |
1 |
1064 |
# |
|
1065 |
# @return [HTMLElement] |
|
1066 |
# |
|
1067 |
||
1068 |
def code(*args) |
1 |
1069 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "code")) |
0 |
1070 |
end |
|
1071 |
||
1072 |
# |
|
1073 |
# @return [HTMLElementCollection] |
|
1074 |
# |
|
1075 |
||
1076 |
def codes(*args) |
1 |
1077 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "code")) |
0 |
1078 |
end |
|
1079 |
||
1080 |
Watir.tag_to_class[:code] = HTMLElement |
1 |
1081 |
# |
|
1082 |
# @return [TableCol] |
|
1083 |
# |
|
1084 |
||
1085 |
def col(*args) |
1 |
1086 |
TableCol.new(self, extract_selector(args).merge(:tag_name => "col")) |
0 |
1087 |
end |
|
1088 |
||
1089 |
# |
|
1090 |
# @return [TableColCollection] |
|
1091 |
# |
|
1092 |
||
1093 |
def cols(*args) |
1 |
1094 |
TableColCollection.new(self, extract_selector(args).merge(:tag_name => "col")) |
0 |
1095 |
end |
|
1096 |
||
1097 |
Watir.tag_to_class[:col] = TableCol |
1 |
1098 |
# |
|
1099 |
# @return [TableCol] |
|
1100 |
# |
|
1101 |
||
1102 |
def colgroup(*args) |
1 |
1103 |
TableCol.new(self, extract_selector(args).merge(:tag_name => "colgroup")) |
0 |
1104 |
end |
|
1105 |
||
1106 |
# |
|
1107 |
# @return [TableColCollection] |
|
1108 |
# |
|
1109 |
||
1110 |
def colgroups(*args) |
1 |
1111 |
TableColCollection.new(self, extract_selector(args).merge(:tag_name => "colgroup")) |
0 |
1112 |
end |
|
1113 |
||
1114 |
Watir.tag_to_class[:colgroup] = TableCol |
1 |
1115 |
# |
|
1116 |
# @return [Command] |
|
1117 |
# |
|
1118 |
||
1119 |
def command(*args) |
1 |
1120 |
Command.new(self, extract_selector(args).merge(:tag_name => "command")) |
0 |
1121 |
end |
|
1122 |
||
1123 |
# |
|
1124 |
# @return [CommandCollection] |
|
1125 |
# |
|
1126 |
||
1127 |
def commands(*args) |
1 |
1128 |
CommandCollection.new(self, extract_selector(args).merge(:tag_name => "command")) |
0 |
1129 |
end |
|
1130 |
||
1131 |
Watir.tag_to_class[:command] = Command |
1 |
1132 |
# |
|
1133 |
# @return [DataList] |
|
1134 |
# |
|
1135 |
||
1136 |
def datalist(*args) |
1 |
1137 |
DataList.new(self, extract_selector(args).merge(:tag_name => "datalist")) |
0 |
1138 |
end |
|
1139 |
||
1140 |
# |
|
1141 |
# @return [DataListCollection] |
|
1142 |
# |
|
1143 |
||
1144 |
def datalists(*args) |
1 |
1145 |
DataListCollection.new(self, extract_selector(args).merge(:tag_name => "datalist")) |
0 |
1146 |
end |
|
1147 |
||
1148 |
Watir.tag_to_class[:datalist] = DataList |
1 |
1149 |
# |
|
1150 |
# @return [HTMLElement] |
|
1151 |
# |
|
1152 |
||
1153 |
def dd(*args) |
1 |
1154 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "dd")) |
62 |
1155 |
end |
|
1156 |
||
1157 |
# |
|
1158 |
# @return [HTMLElementCollection] |
|
1159 |
# |
|
1160 |
||
1161 |
def dds(*args) |
1 |
1162 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "dd")) |
4 |
1163 |
end |
|
1164 |
||
1165 |
Watir.tag_to_class[:dd] = HTMLElement |
1 |
1166 |
# |
|
1167 |
# @return [Mod] |
|
1168 |
# |
|
1169 |
||
1170 |
def del(*args) |
1 |
1171 |
Mod.new(self, extract_selector(args).merge(:tag_name => "del")) |
59 |
1172 |
end |
|
1173 |
||
1174 |
# |
|
1175 |
# @return [ModCollection] |
|
1176 |
# |
|
1177 |
||
1178 |
def dels(*args) |
1 |
1179 |
ModCollection.new(self, extract_selector(args).merge(:tag_name => "del")) |
4 |
1180 |
end |
|
1181 |
||
1182 |
Watir.tag_to_class[:del] = Mod |
1 |
1183 |
# |
|
1184 |
# @return [Details] |
|
1185 |
# |
|
1186 |
||
1187 |
def details(*args) |
1 |
1188 |
Details.new(self, extract_selector(args).merge(:tag_name => "details")) |
0 |
1189 |
end |
|
1190 |
||
1191 |
# |
|
1192 |
# @return [DetailsCollection] |
|
1193 |
# |
|
1194 |
||
1195 |
def details(*args) |
1 |
1196 |
DetailsCollection.new(self, extract_selector(args).merge(:tag_name => "details")) |
0 |
1197 |
end |
|
1198 |
||
1199 |
Watir.tag_to_class[:details] = Details |
1 |
1200 |
# |
|
1201 |
# @return [HTMLElement] |
|
1202 |
# |
|
1203 |
||
1204 |
def dfn(*args) |
1 |
1205 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "dfn")) |
0 |
1206 |
end |
|
1207 |
||
1208 |
# |
|
1209 |
# @return [HTMLElementCollection] |
|
1210 |
# |
|
1211 |
||
1212 |
def dfns(*args) |
1 |
1213 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "dfn")) |
0 |
1214 |
end |
|
1215 |
||
1216 |
Watir.tag_to_class[:dfn] = HTMLElement |
1 |
1217 |
# |
|
1218 |
# @return [Div] |
|
1219 |
# |
|
1220 |
||
1221 |
def div(*args) |
1 |
1222 |
Div.new(self, extract_selector(args).merge(:tag_name => "div")) |
129 |
1223 |
end |
|
1224 |
||
1225 |
# |
|
1226 |
# @return [DivCollection] |
|
1227 |
# |
|
1228 |
||
1229 |
def divs(*args) |
1 |
1230 |
DivCollection.new(self, extract_selector(args).merge(:tag_name => "div")) |
17 |
1231 |
end |
|
1232 |
||
1233 |
Watir.tag_to_class[:div] = Div |
1 |
1234 |
# |
|
1235 |
# @return [DList] |
|
1236 |
# |
|
1237 |
||
1238 |
def dl(*args) |
1 |
1239 |
DList.new(self, extract_selector(args).merge(:tag_name => "dl")) |
50 |
1240 |
end |
|
1241 |
||
1242 |
# |
|
1243 |
# @return [DListCollection] |
|
1244 |
# |
|
1245 |
||
1246 |
def dls(*args) |
1 |
1247 |
DListCollection.new(self, extract_selector(args).merge(:tag_name => "dl")) |
6 |
1248 |
end |
|
1249 |
||
1250 |
Watir.tag_to_class[:dl] = DList |
1 |
1251 |
# |
|
1252 |
# @return [HTMLElement] |
|
1253 |
# |
|
1254 |
||
1255 |
def dt(*args) |
1 |
1256 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "dt")) |
65 |
1257 |
end |
|
1258 |
||
1259 |
# |
|
1260 |
# @return [HTMLElementCollection] |
|
1261 |
# |
|
1262 |
||
1263 |
def dts(*args) |
1 |
1264 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "dt")) |
4 |
1265 |
end |
|
1266 |
||
1267 |
Watir.tag_to_class[:dt] = HTMLElement |
1 |
1268 |
# |
|
1269 |
# @return [HTMLElement] |
|
1270 |
# |
|
1271 |
||
1272 |
def em(*args) |
1 |
1273 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "em")) |
36 |
1274 |
end |
|
1275 |
||
1276 |
# |
|
1277 |
# @return [HTMLElementCollection] |
|
1278 |
# |
|
1279 |
||
1280 |
def ems(*args) |
1 |
1281 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "em")) |
4 |
1282 |
end |
|
1283 |
||
1284 |
Watir.tag_to_class[:em] = HTMLElement |
1 |
1285 |
# |
|
1286 |
# @return [Embed] |
|
1287 |
# |
|
1288 |
||
1289 |
def embed(*args) |
1 |
1290 |
Embed.new(self, extract_selector(args).merge(:tag_name => "embed")) |
0 |
1291 |
end |
|
1292 |
||
1293 |
# |
|
1294 |
# @return [EmbedCollection] |
|
1295 |
# |
|
1296 |
||
1297 |
def embeds(*args) |
1 |
1298 |
EmbedCollection.new(self, extract_selector(args).merge(:tag_name => "embed")) |
0 |
1299 |
end |
|
1300 |
||
1301 |
Watir.tag_to_class[:embed] = Embed |
1 |
1302 |
# |
|
1303 |
# @return [FieldSet] |
|
1304 |
# |
|
1305 |
||
1306 |
def fieldset(*args) |
1 |
1307 |
FieldSet.new(self, extract_selector(args).merge(:tag_name => "fieldset")) |
0 |
1308 |
end |
|
1309 |
||
1310 |
# |
|
1311 |
# @return [FieldSetCollection] |
|
1312 |
# |
|
1313 |
||
1314 |
def fieldsets(*args) |
1 |
1315 |
FieldSetCollection.new(self, extract_selector(args).merge(:tag_name => "fieldset")) |
0 |
1316 |
end |
|
1317 |
||
1318 |
Watir.tag_to_class[:fieldset] = FieldSet |
1 |
1319 |
# |
|
1320 |
# @return [HTMLElement] |
|
1321 |
# |
|
1322 |
||
1323 |
def figcaption(*args) |
1 |
1324 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "figcaption")) |
0 |
1325 |
end |
|
1326 |
||
1327 |
# |
|
1328 |
# @return [HTMLElementCollection] |
|
1329 |
# |
|
1330 |
||
1331 |
def figcaptions(*args) |
1 |
1332 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "figcaption")) |
0 |
1333 |
end |
|
1334 |
||
1335 |
Watir.tag_to_class[:figcaption] = HTMLElement |
1 |
1336 |
# |
|
1337 |
# @return [HTMLElement] |
|
1338 |
# |
|
1339 |
||
1340 |
def figure(*args) |
1 |
1341 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "figure")) |
0 |
1342 |
end |
|
1343 |
||
1344 |
# |
|
1345 |
# @return [HTMLElementCollection] |
|
1346 |
# |
|
1347 |
||
1348 |
def figures(*args) |
1 |
1349 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "figure")) |
0 |
1350 |
end |
|
1351 |
||
1352 |
Watir.tag_to_class[:figure] = HTMLElement |
1 |
1353 |
# |
|
1354 |
# @return [HTMLElement] |
|
1355 |
# |
|
1356 |
||
1357 |
def footer(*args) |
1 |
1358 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "footer")) |
0 |
1359 |
end |
|
1360 |
||
1361 |
# |
|
1362 |
# @return [HTMLElementCollection] |
|
1363 |
# |
|
1364 |
||
1365 |
def footers(*args) |
1 |
1366 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "footer")) |
0 |
1367 |
end |
|
1368 |
||
1369 |
Watir.tag_to_class[:footer] = HTMLElement |
1 |
1370 |
# |
|
1371 |
# @return [Form] |
|
1372 |
# |
|
1373 |
||
1374 |
def form(*args) |
1 |
1375 |
Form.new(self, extract_selector(args).merge(:tag_name => "form")) |
33 |
1376 |
end |
|
1377 |
||
1378 |
# |
|
1379 |
# @return [FormCollection] |
|
1380 |
# |
|
1381 |
||
1382 |
def forms(*args) |
1 |
1383 |
FormCollection.new(self, extract_selector(args).merge(:tag_name => "form")) |
5 |
1384 |
end |
|
1385 |
||
1386 |
Watir.tag_to_class[:form] = Form |
1 |
1387 |
# |
|
1388 |
# @return [Heading] |
|
1389 |
# |
|
1390 |
||
1391 |
def h1(*args) |
1 |
1392 |
Heading.new(self, extract_selector(args).merge(:tag_name => "h1")) |
26 |
1393 |
end |
|
1394 |
||
1395 |
# |
|
1396 |
# @return [HeadingCollection] |
|
1397 |
# |
|
1398 |
||
1399 |
def h1s(*args) |
1 |
1400 |
HeadingCollection.new(self, extract_selector(args).merge(:tag_name => "h1")) |
3 |
1401 |
end |
|
1402 |
||
1403 |
Watir.tag_to_class[:h1] = Heading |
1 |
1404 |
# |
|
1405 |
# @return [Heading] |
|
1406 |
# |
|
1407 |
||
1408 |
def h2(*args) |
1 |
1409 |
Heading.new(self, extract_selector(args).merge(:tag_name => "h2")) |
21 |
1410 |
end |
|
1411 |
||
1412 |
# |
|
1413 |
# @return [HeadingCollection] |
|
1414 |
# |
|
1415 |
||
1416 |
def h2s(*args) |
1 |
1417 |
HeadingCollection.new(self, extract_selector(args).merge(:tag_name => "h2")) |
2 |
1418 |
end |
|
1419 |
||
1420 |
Watir.tag_to_class[:h2] = Heading |
1 |
1421 |
# |
|
1422 |
# @return [Heading] |
|
1423 |
# |
|
1424 |
||
1425 |
def h3(*args) |
1 |
1426 |
Heading.new(self, extract_selector(args).merge(:tag_name => "h3")) |
6 |
1427 |
end |
|
1428 |
||
1429 |
# |
|
1430 |
# @return [HeadingCollection] |
|
1431 |
# |
|
1432 |
||
1433 |
def h3s(*args) |
1 |
1434 |
HeadingCollection.new(self, extract_selector(args).merge(:tag_name => "h3")) |
1 |
1435 |
end |
|
1436 |
||
1437 |
Watir.tag_to_class[:h3] = Heading |
1 |
1438 |
# |
|
1439 |
# @return [Heading] |
|
1440 |
# |
|
1441 |
||
1442 |
def h4(*args) |
1 |
1443 |
Heading.new(self, extract_selector(args).merge(:tag_name => "h4")) |
3 |
1444 |
end |
|
1445 |
||
1446 |
# |
|
1447 |
# @return [HeadingCollection] |
|
1448 |
# |
|
1449 |
||
1450 |
def h4s(*args) |
1 |
1451 |
HeadingCollection.new(self, extract_selector(args).merge(:tag_name => "h4")) |
1 |
1452 |
end |
|
1453 |
||
1454 |
Watir.tag_to_class[:h4] = Heading |
1 |
1455 |
# |
|
1456 |
# @return [Heading] |
|
1457 |
# |
|
1458 |
||
1459 |
def h5(*args) |
1 |
1460 |
Heading.new(self, extract_selector(args).merge(:tag_name => "h5")) |
3 |
1461 |
end |
|
1462 |
||
1463 |
# |
|
1464 |
# @return [HeadingCollection] |
|
1465 |
# |
|
1466 |
||
1467 |
def h5s(*args) |
1 |
1468 |
HeadingCollection.new(self, extract_selector(args).merge(:tag_name => "h5")) |
1 |
1469 |
end |
|
1470 |
||
1471 |
Watir.tag_to_class[:h5] = Heading |
1 |
1472 |
# |
|
1473 |
# @return [Heading] |
|
1474 |
# |
|
1475 |
||
1476 |
def h6(*args) |
1 |
1477 |
Heading.new(self, extract_selector(args).merge(:tag_name => "h6")) |
6 |
1478 |
end |
|
1479 |
||
1480 |
# |
|
1481 |
# @return [HeadingCollection] |
|
1482 |
# |
|
1483 |
||
1484 |
def h6s(*args) |
1 |
1485 |
HeadingCollection.new(self, extract_selector(args).merge(:tag_name => "h6")) |
1 |
1486 |
end |
|
1487 |
||
1488 |
Watir.tag_to_class[:h6] = Heading |
1 |
1489 |
# |
|
1490 |
# @return [Head] |
|
1491 |
# |
|
1492 |
||
1493 |
def head(*args) |
1 |
1494 |
Head.new(self, extract_selector(args).merge(:tag_name => "head")) |
0 |
1495 |
end |
|
1496 |
||
1497 |
# |
|
1498 |
# @return [HeadCollection] |
|
1499 |
# |
|
1500 |
||
1501 |
def heads(*args) |
1 |
1502 |
HeadCollection.new(self, extract_selector(args).merge(:tag_name => "head")) |
0 |
1503 |
end |
|
1504 |
||
1505 |
Watir.tag_to_class[:head] = Head |
1 |
1506 |
# |
|
1507 |
# @return [HTMLElement] |
|
1508 |
# |
|
1509 |
||
1510 |
def header(*args) |
1 |
1511 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "header")) |
0 |
1512 |
end |
|
1513 |
||
1514 |
# |
|
1515 |
# @return [HTMLElementCollection] |
|
1516 |
# |
|
1517 |
||
1518 |
def headers(*args) |
1 |
1519 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "header")) |
0 |
1520 |
end |
|
1521 |
||
1522 |
Watir.tag_to_class[:header] = HTMLElement |
1 |
1523 |
# |
|
1524 |
# @return [HTMLElement] |
|
1525 |
# |
|
1526 |
||
1527 |
def hgroup(*args) |
1 |
1528 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "hgroup")) |
0 |
1529 |
end |
|
1530 |
||
1531 |
# |
|
1532 |
# @return [HTMLElementCollection] |
|
1533 |
# |
|
1534 |
||
1535 |
def hgroups(*args) |
1 |
1536 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "hgroup")) |
0 |
1537 |
end |
|
1538 |
||
1539 |
Watir.tag_to_class[:hgroup] = HTMLElement |
1 |
1540 |
# |
|
1541 |
# @return [HR] |
|
1542 |
# |
|
1543 |
||
1544 |
def hr(*args) |
1 |
1545 |
HR.new(self, extract_selector(args).merge(:tag_name => "hr")) |
0 |
1546 |
end |
|
1547 |
||
1548 |
# |
|
1549 |
# @return [HRCollection] |
|
1550 |
# |
|
1551 |
||
1552 |
def hrs(*args) |
1 |
1553 |
HRCollection.new(self, extract_selector(args).merge(:tag_name => "hr")) |
0 |
1554 |
end |
|
1555 |
||
1556 |
Watir.tag_to_class[:hr] = HR |
1 |
1557 |
# |
|
1558 |
# @return [Html] |
|
1559 |
# |
|
1560 |
||
1561 |
def html(*args) |
1 |
1562 |
Html.new(self, extract_selector(args).merge(:tag_name => "html")) |
0 |
1563 |
end |
|
1564 |
||
1565 |
# |
|
1566 |
# @return [HtmlCollection] |
|
1567 |
# |
|
1568 |
||
1569 |
def htmls(*args) |
1 |
1570 |
HtmlCollection.new(self, extract_selector(args).merge(:tag_name => "html")) |
0 |
1571 |
end |
|
1572 |
||
1573 |
Watir.tag_to_class[:html] = Html |
1 |
1574 |
# |
|
1575 |
# @return [HTMLElement] |
|
1576 |
# |
|
1577 |
||
1578 |
def i(*args) |
1 |
1579 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "i")) |
0 |
1580 |
end |
|
1581 |
||
1582 |
# |
|
1583 |
# @return [HTMLElementCollection] |
|
1584 |
# |
|
1585 |
||
1586 |
def is(*args) |
1 |
1587 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "i")) |
0 |
1588 |
end |
|
1589 |
||
1590 |
Watir.tag_to_class[:i] = HTMLElement |
1 |
1591 |
# |
|
1592 |
# @return [IFrame] |
|
1593 |
# |
|
1594 |
||
1595 |
def iframe(*args) |
1 |
1596 |
IFrame.new(self, extract_selector(args).merge(:tag_name => "iframe")) |
0 |
1597 |
end |
|
1598 |
||
1599 |
# |
|
1600 |
# @return [IFrameCollection] |
|
1601 |
# |
|
1602 |
||
1603 |
def iframes(*args) |
1 |
1604 |
IFrameCollection.new(self, extract_selector(args).merge(:tag_name => "iframe")) |
0 |
1605 |
end |
|
1606 |
||
1607 |
Watir.tag_to_class[:iframe] = IFrame |
1 |
1608 |
# |
|
1609 |
# @return [Image] |
|
1610 |
# |
|
1611 |
||
1612 |
def img(*args) |
1 |
1613 |
Image.new(self, extract_selector(args).merge(:tag_name => "img")) |
69 |
1614 |
end |
|
1615 |
||
1616 |
# |
|
1617 |
# @return [ImageCollection] |
|
1618 |
# |
|
1619 |
||
1620 |
def imgs(*args) |
1 |
1621 |
ImageCollection.new(self, extract_selector(args).merge(:tag_name => "img")) |
4 |
1622 |
end |
|
1623 |
||
1624 |
Watir.tag_to_class[:img] = Image |
1 |
1625 |
# |
|
1626 |
# @return [Input] |
|
1627 |
# |
|
1628 |
||
1629 |
def input(*args) |
1 |
1630 |
Input.new(self, extract_selector(args).merge(:tag_name => "input")) |
6 |
1631 |
end |
|
1632 |
||
1633 |
# |
|
1634 |
# @return [InputCollection] |
|
1635 |
# |
|
1636 |
||
1637 |
def inputs(*args) |
1 |
1638 |
InputCollection.new(self, extract_selector(args).merge(:tag_name => "input")) |
0 |
1639 |
end |
|
1640 |
||
1641 |
Watir.tag_to_class[:input] = Input |
1 |
1642 |
# |
|
1643 |
# @return [Mod] |
|
1644 |
# |
|
1645 |
||
1646 |
def ins(*args) |
1 |
1647 |
Mod.new(self, extract_selector(args).merge(:tag_name => "ins")) |
59 |
1648 |
end |
|
1649 |
||
1650 |
# |
|
1651 |
# @return [ModCollection] |
|
1652 |
# |
|
1653 |
||
1654 |
def inses(*args) |
1 |
1655 |
ModCollection.new(self, extract_selector(args).merge(:tag_name => "ins")) |
4 |
1656 |
end |
|
1657 |
||
1658 |
Watir.tag_to_class[:ins] = Mod |
1 |
1659 |
# |
|
1660 |
# @return [HTMLElement] |
|
1661 |
# |
|
1662 |
||
1663 |
def kbd(*args) |
1 |
1664 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "kbd")) |
0 |
1665 |
end |
|
1666 |
||
1667 |
# |
|
1668 |
# @return [HTMLElementCollection] |
|
1669 |
# |
|
1670 |
||
1671 |
def kbds(*args) |
1 |
1672 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "kbd")) |
0 |
1673 |
end |
|
1674 |
||
1675 |
Watir.tag_to_class[:kbd] = HTMLElement |
1 |
1676 |
# |
|
1677 |
# @return [Keygen] |
|
1678 |
# |
|
1679 |
||
1680 |
def keygen(*args) |
1 |
1681 |
Keygen.new(self, extract_selector(args).merge(:tag_name => "keygen")) |
0 |
1682 |
end |
|
1683 |
||
1684 |
# |
|
1685 |
# @return [KeygenCollection] |
|
1686 |
# |
|
1687 |
||
1688 |
def keygens(*args) |
1 |
1689 |
KeygenCollection.new(self, extract_selector(args).merge(:tag_name => "keygen")) |
0 |
1690 |
end |
|
1691 |
||
1692 |
Watir.tag_to_class[:keygen] = Keygen |
1 |
1693 |
# |
|
1694 |
# @return [Label] |
|
1695 |
# |
|
1696 |
||
1697 |
def label(*args) |
1 |
1698 |
Label.new(self, extract_selector(args).merge(:tag_name => "label")) |
77 |
1699 |
end |
|
1700 |
||
1701 |
# |
|
1702 |
# @return [LabelCollection] |
|
1703 |
# |
|
1704 |
||
1705 |
def labels(*args) |
1 |
1706 |
LabelCollection.new(self, extract_selector(args).merge(:tag_name => "label")) |
4 |
1707 |
end |
|
1708 |
||
1709 |
Watir.tag_to_class[:label] = Label |
1 |
1710 |
# |
|
1711 |
# @return [Legend] |
|
1712 |
# |
|
1713 |
||
1714 |
def legend(*args) |
1 |
1715 |
Legend.new(self, extract_selector(args).merge(:tag_name => "legend")) |
0 |
1716 |
end |
|
1717 |
||
1718 |
# |
|
1719 |
# @return [LegendCollection] |
|
1720 |
# |
|
1721 |
||
1722 |
def legends(*args) |
1 |
1723 |
LegendCollection.new(self, extract_selector(args).merge(:tag_name => "legend")) |
0 |
1724 |
end |
|
1725 |
||
1726 |
Watir.tag_to_class[:legend] = Legend |
1 |
1727 |
# |
|
1728 |
# @return [LI] |
|
1729 |
# |
|
1730 |
||
1731 |
def li(*args) |
1 |
1732 |
LI.new(self, extract_selector(args).merge(:tag_name => "li")) |
75 |
1733 |
end |
|
1734 |
||
1735 |
# |
|
1736 |
# @return [LICollection] |
|
1737 |
# |
|
1738 |
||
1739 |
def lis(*args) |
1 |
1740 |
LICollection.new(self, extract_selector(args).merge(:tag_name => "li")) |
4 |
1741 |
end |
|
1742 |
||
1743 |
Watir.tag_to_class[:li] = LI |
1 |
1744 |
# |
|
1745 |
# @return [Map] |
|
1746 |
# |
|
1747 |
||
1748 |
def map(*args) |
1 |
1749 |
Map.new(self, extract_selector(args).merge(:tag_name => "map")) |
32 |
1750 |
end |
|
1751 |
||
1752 |
# |
|
1753 |
# @return [MapCollection] |
|
1754 |
# |
|
1755 |
||
1756 |
def maps(*args) |
1 |
1757 |
MapCollection.new(self, extract_selector(args).merge(:tag_name => "map")) |
4 |
1758 |
end |
|
1759 |
||
1760 |
Watir.tag_to_class[:map] = Map |
1 |
1761 |
# |
|
1762 |
# @return [HTMLElement] |
|
1763 |
# |
|
1764 |
||
1765 |
def mark(*args) |
1 |
1766 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "mark")) |
0 |
1767 |
end |
|
1768 |
||
1769 |
# |
|
1770 |
# @return [HTMLElementCollection] |
|
1771 |
# |
|
1772 |
||
1773 |
def marks(*args) |
1 |
1774 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "mark")) |
0 |
1775 |
end |
|
1776 |
||
1777 |
Watir.tag_to_class[:mark] = HTMLElement |
1 |
1778 |
# |
|
1779 |
# @return [Menu] |
|
1780 |
# |
|
1781 |
||
1782 |
def menu(*args) |
1 |
1783 |
Menu.new(self, extract_selector(args).merge(:tag_name => "menu")) |
0 |
1784 |
end |
|
1785 |
||
1786 |
# |
|
1787 |
# @return [MenuCollection] |
|
1788 |
# |
|
1789 |
||
1790 |
def menus(*args) |
1 |
1791 |
MenuCollection.new(self, extract_selector(args).merge(:tag_name => "menu")) |
0 |
1792 |
end |
|
1793 |
||
1794 |
Watir.tag_to_class[:menu] = Menu |
1 |
1795 |
# |
|
1796 |
# @return [Meta] |
|
1797 |
# |
|
1798 |
||
1799 |
def meta(*args) |
1 |
1800 |
Meta.new(self, extract_selector(args).merge(:tag_name => "meta")) |
6 |
1801 |
end |
|
1802 |
||
1803 |
# |
|
1804 |
# @return [MetaCollection] |
|
1805 |
# |
|
1806 |
||
1807 |
def metas(*args) |
1 |
1808 |
MetaCollection.new(self, extract_selector(args).merge(:tag_name => "meta")) |
4 |
1809 |
end |
|
1810 |
||
1811 |
Watir.tag_to_class[:meta] = Meta |
1 |
1812 |
# |
|
1813 |
# @return [Meter] |
|
1814 |
# |
|
1815 |
||
1816 |
def meter(*args) |
1 |
1817 |
Meter.new(self, extract_selector(args).merge(:tag_name => "meter")) |
0 |
1818 |
end |
|
1819 |
||
1820 |
# |
|
1821 |
# @return [MeterCollection] |
|
1822 |
# |
|
1823 |
||
1824 |
def meters(*args) |
1 |
1825 |
MeterCollection.new(self, extract_selector(args).merge(:tag_name => "meter")) |
0 |
1826 |
end |
|
1827 |
||
1828 |
Watir.tag_to_class[:meter] = Meter |
1 |
1829 |
# |
|
1830 |
# @return [HTMLElement] |
|
1831 |
# |
|
1832 |
||
1833 |
def nav(*args) |
1 |
1834 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "nav")) |
0 |
1835 |
end |
|
1836 |
||
1837 |
# |
|
1838 |
# @return [HTMLElementCollection] |
|
1839 |
# |
|
1840 |
||
1841 |
def navs(*args) |
1 |
1842 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "nav")) |
0 |
1843 |
end |
|
1844 |
||
1845 |
Watir.tag_to_class[:nav] = HTMLElement |
1 |
1846 |
# |
|
1847 |
# @return [HTMLElement] |
|
1848 |
# |
|
1849 |
||
1850 |
def noscript(*args) |
1 |
1851 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "noscript")) |
0 |
1852 |
end |
|
1853 |
||
1854 |
# |
|
1855 |
# @return [HTMLElementCollection] |
|
1856 |
# |
|
1857 |
||
1858 |
def noscripts(*args) |
1 |
1859 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "noscript")) |
0 |
1860 |
end |
|
1861 |
||
1862 |
Watir.tag_to_class[:noscript] = HTMLElement |
1 |
1863 |
# |
|
1864 |
# @return [Object] |
|
1865 |
# |
|
1866 |
||
1867 |
def object(*args) |
1 |
1868 |
Object.new(self, extract_selector(args).merge(:tag_name => "object")) |
0 |
1869 |
end |
|
1870 |
||
1871 |
# |
|
1872 |
# @return [ObjectCollection] |
|
1873 |
# |
|
1874 |
||
1875 |
def objects(*args) |
1 |
1876 |
ObjectCollection.new(self, extract_selector(args).merge(:tag_name => "object")) |
0 |
1877 |
end |
|
1878 |
||
1879 |
Watir.tag_to_class[:object] = Object |
1 |
1880 |
# |
|
1881 |
# @return [OList] |
|
1882 |
# |
|
1883 |
||
1884 |
def ol(*args) |
1 |
1885 |
OList.new(self, extract_selector(args).merge(:tag_name => "ol")) |
37 |
1886 |
end |
|
1887 |
||
1888 |
# |
|
1889 |
# @return [OListCollection] |
|
1890 |
# |
|
1891 |
||
1892 |
def ols(*args) |
1 |
1893 |
OListCollection.new(self, extract_selector(args).merge(:tag_name => "ol")) |
4 |
1894 |
end |
|
1895 |
||
1896 |
Watir.tag_to_class[:ol] = OList |
1 |
1897 |
# |
|
1898 |
# @return [OptGroup] |
|
1899 |
# |
|
1900 |
||
1901 |
def optgroup(*args) |
1 |
1902 |
OptGroup.new(self, extract_selector(args).merge(:tag_name => "optgroup")) |
0 |
1903 |
end |
|
1904 |
||
1905 |
# |
|
1906 |
# @return [OptGroupCollection] |
|
1907 |
# |
|
1908 |
||
1909 |
def optgroups(*args) |
1 |
1910 |
OptGroupCollection.new(self, extract_selector(args).merge(:tag_name => "optgroup")) |
0 |
1911 |
end |
|
1912 |
||
1913 |
Watir.tag_to_class[:optgroup] = OptGroup |
1 |
1914 |
# |
|
1915 |
# @return [Option] |
|
1916 |
# |
|
1917 |
||
1918 |
def option(*args) |
1 |
1919 |
Option.new(self, extract_selector(args).merge(:tag_name => "option")) |
63 |
1920 |
end |
|
1921 |
||
1922 |
# |
|
1923 |
# @return [OptionCollection] |
|
1924 |
# |
|
1925 |
||
1926 |
def options(*args) |
1 |
1927 |
OptionCollection.new(self, extract_selector(args).merge(:tag_name => "option")) |
39 |
1928 |
end |
|
1929 |
||
1930 |
Watir.tag_to_class[:option] = Option |
1 |
1931 |
# |
|
1932 |
# @return [Output] |
|
1933 |
# |
|
1934 |
||
1935 |
def output(*args) |
1 |
1936 |
Output.new(self, extract_selector(args).merge(:tag_name => "output")) |
0 |
1937 |
end |
|
1938 |
||
1939 |
# |
|
1940 |
# @return [OutputCollection] |
|
1941 |
# |
|
1942 |
||
1943 |
def outputs(*args) |
1 |
1944 |
OutputCollection.new(self, extract_selector(args).merge(:tag_name => "output")) |
0 |
1945 |
end |
|
1946 |
||
1947 |
Watir.tag_to_class[:output] = Output |
1 |
1948 |
# |
|
1949 |
# @return [Paragraph] |
|
1950 |
# |
|
1951 |
||
1952 |
def p(*args) |
1 |
1953 |
Paragraph.new(self, extract_selector(args).merge(:tag_name => "p")) |
58 |
1954 |
end |
|
1955 |
||
1956 |
# |
|
1957 |
# @return [ParagraphCollection] |
|
1958 |
# |
|
1959 |
||
1960 |
def ps(*args) |
1 |
1961 |
ParagraphCollection.new(self, extract_selector(args).merge(:tag_name => "p")) |
5 |
1962 |
end |
|
1963 |
||
1964 |
Watir.tag_to_class[:p] = Paragraph |
1 |
1965 |
# |
|
1966 |
# @return [Param] |
|
1967 |
# |
|
1968 |
||
1969 |
def param(*args) |
1 |
1970 |
Param.new(self, extract_selector(args).merge(:tag_name => "param")) |
0 |
1971 |
end |
|
1972 |
||
1973 |
# |
|
1974 |
# @return [ParamCollection] |
|
1975 |
# |
|
1976 |
||
1977 |
def params(*args) |
1 |
1978 |
ParamCollection.new(self, extract_selector(args).merge(:tag_name => "param")) |
0 |
1979 |
end |
|
1980 |
||
1981 |
Watir.tag_to_class[:param] = Param |
1 |
1982 |
# |
|
1983 |
# @return [Pre] |
|
1984 |
# |
|
1985 |
||
1986 |
def pre(*args) |
1 |
1987 |
Pre.new(self, extract_selector(args).merge(:tag_name => "pre")) |
51 |
1988 |
end |
|
1989 |
||
1990 |
# |
|
1991 |
# @return [PreCollection] |
|
1992 |
# |
|
1993 |
||
1994 |
def pres(*args) |
1 |
1995 |
PreCollection.new(self, extract_selector(args).merge(:tag_name => "pre")) |
4 |
1996 |
end |
|
1997 |
||
1998 |
Watir.tag_to_class[:pre] = Pre |
1 |
1999 |
# |
|
2000 |
# @return [Progress] |
|
2001 |
# |
|
2002 |
||
2003 |
def progress(*args) |
1 |
2004 |
Progress.new(self, extract_selector(args).merge(:tag_name => "progress")) |
0 |
2005 |
end |
|
2006 |
||
2007 |
# |
|
2008 |
# @return [ProgressCollection] |
|
2009 |
# |
|
2010 |
||
2011 |
def progresses(*args) |
1 |
2012 |
ProgressCollection.new(self, extract_selector(args).merge(:tag_name => "progress")) |
0 |
2013 |
end |
|
2014 |
||
2015 |
Watir.tag_to_class[:progress] = Progress |
1 |
2016 |
# |
|
2017 |
# @return [Quote] |
|
2018 |
# |
|
2019 |
||
2020 |
def q(*args) |
1 |
2021 |
Quote.new(self, extract_selector(args).merge(:tag_name => "q")) |
0 |
2022 |
end |
|
2023 |
||
2024 |
# |
|
2025 |
# @return [QuoteCollection] |
|
2026 |
# |
|
2027 |
||
2028 |
def qs(*args) |
1 |
2029 |
QuoteCollection.new(self, extract_selector(args).merge(:tag_name => "q")) |
0 |
2030 |
end |
|
2031 |
||
2032 |
Watir.tag_to_class[:q] = Quote |
1 |
2033 |
# |
|
2034 |
# @return [HTMLElement] |
|
2035 |
# |
|
2036 |
||
2037 |
def rp(*args) |
1 |
2038 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "rp")) |
0 |
2039 |
end |
|
2040 |
||
2041 |
# |
|
2042 |
# @return [HTMLElementCollection] |
|
2043 |
# |
|
2044 |
||
2045 |
def rps(*args) |
1 |
2046 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "rp")) |
0 |
2047 |
end |
|
2048 |
||
2049 |
Watir.tag_to_class[:rp] = HTMLElement |
1 |
2050 |
# |
|
2051 |
# @return [HTMLElement] |
|
2052 |
# |
|
2053 |
||
2054 |
def rt(*args) |
1 |
2055 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "rt")) |
0 |
2056 |
end |
|
2057 |
||
2058 |
# |
|
2059 |
# @return [HTMLElementCollection] |
|
2060 |
# |
|
2061 |
||
2062 |
def rts(*args) |
1 |
2063 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "rt")) |
0 |
2064 |
end |
|
2065 |
||
2066 |
Watir.tag_to_class[:rt] = HTMLElement |
1 |
2067 |
# |
|
2068 |
# @return [HTMLElement] |
|
2069 |
# |
|
2070 |
||
2071 |
def ruby(*args) |
1 |
2072 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "ruby")) |
0 |
2073 |
end |
|
2074 |
||
2075 |
# |
|
2076 |
# @return [HTMLElementCollection] |
|
2077 |
# |
|
2078 |
||
2079 |
def rubies(*args) |
1 |
2080 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "ruby")) |
0 |
2081 |
end |
|
2082 |
||
2083 |
Watir.tag_to_class[:ruby] = HTMLElement |
1 |
2084 |
# |
|
2085 |
# @return [HTMLElement] |
|
2086 |
# |
|
2087 |
||
2088 |
def s(*args) |
1 |
2089 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "s")) |
0 |
2090 |
end |
|
2091 |
||
2092 |
# |
|
2093 |
# @return [HTMLElementCollection] |
|
2094 |
# |
|
2095 |
||
2096 |
def ss(*args) |
1 |
2097 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "s")) |
0 |
2098 |
end |
|
2099 |
||
2100 |
Watir.tag_to_class[:s] = HTMLElement |
1 |
2101 |
# |
|
2102 |
# @return [HTMLElement] |
|
2103 |
# |
|
2104 |
||
2105 |
def samp(*args) |
1 |
2106 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "samp")) |
0 |
2107 |
end |
|
2108 |
||
2109 |
# |
|
2110 |
# @return [HTMLElementCollection] |
|
2111 |
# |
|
2112 |
||
2113 |
def samps(*args) |
1 |
2114 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "samp")) |
0 |
2115 |
end |
|
2116 |
||
2117 |
Watir.tag_to_class[:samp] = HTMLElement |
1 |
2118 |
# |
|
2119 |
# @return [Script] |
|
2120 |
# |
|
2121 |
||
2122 |
def script(*args) |
1 |
2123 |
Script.new(self, extract_selector(args).merge(:tag_name => "script")) |
0 |
2124 |
end |
|
2125 |
||
2126 |
# |
|
2127 |
# @return [ScriptCollection] |
|
2128 |
# |
|
2129 |
||
2130 |
def scripts(*args) |
1 |
2131 |
ScriptCollection.new(self, extract_selector(args).merge(:tag_name => "script")) |
0 |
2132 |
end |
|
2133 |
||
2134 |
Watir.tag_to_class[:script] = Script |
1 |
2135 |
# |
|
2136 |
# @return [HTMLElement] |
|
2137 |
# |
|
2138 |
||
2139 |
def section(*args) |
1 |
2140 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "section")) |
0 |
2141 |
end |
|
2142 |
||
2143 |
# |
|
2144 |
# @return [HTMLElementCollection] |
|
2145 |
# |
|
2146 |
||
2147 |
def sections(*args) |
1 |
2148 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "section")) |
0 |
2149 |
end |
|
2150 |
||
2151 |
Watir.tag_to_class[:section] = HTMLElement |
1 |
2152 |
# |
|
2153 |
# @return [Select] |
|
2154 |
# |
|
2155 |
||
2156 |
def select(*args) |
1 |
2157 |
Select.new(self, extract_selector(args).merge(:tag_name => "select")) |
153 |
2158 |
end |
|
2159 |
||
2160 |
# |
|
2161 |
# @return [SelectCollection] |
|
2162 |
# |
|
2163 |
||
2164 |
def selects(*args) |
1 |
2165 |
SelectCollection.new(self, extract_selector(args).merge(:tag_name => "select")) |
7 |
2166 |
end |
|
2167 |
||
2168 |
Watir.tag_to_class[:select] = Select |
1 |
2169 |
# |
|
2170 |
# @return [HTMLElement] |
|
2171 |
# |
|
2172 |
||
2173 |
def small(*args) |
1 |
2174 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "small")) |
0 |
2175 |
end |
|
2176 |
||
2177 |
# |
|
2178 |
# @return [HTMLElementCollection] |
|
2179 |
# |
|
2180 |
||
2181 |
def smalls(*args) |
1 |
2182 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "small")) |
0 |
2183 |
end |
|
2184 |
||
2185 |
Watir.tag_to_class[:small] = HTMLElement |
1 |
2186 |
# |
|
2187 |
# @return [Source] |
|
2188 |
# |
|
2189 |
||
2190 |
def source(*args) |
1 |
2191 |
Source.new(self, extract_selector(args).merge(:tag_name => "source")) |
0 |
2192 |
end |
|
2193 |
||
2194 |
# |
|
2195 |
# @return [SourceCollection] |
|
2196 |
# |
|
2197 |
||
2198 |
def sources(*args) |
1 |
2199 |
SourceCollection.new(self, extract_selector(args).merge(:tag_name => "source")) |
0 |
2200 |
end |
|
2201 |
||
2202 |
Watir.tag_to_class[:source] = Source |
1 |
2203 |
# |
|
2204 |
# @return [Span] |
|
2205 |
# |
|
2206 |
||
2207 |
def span(*args) |
1 |
2208 |
Span.new(self, extract_selector(args).merge(:tag_name => "span")) |
67 |
2209 |
end |
|
2210 |
||
2211 |
# |
|
2212 |
# @return [SpanCollection] |
|
2213 |
# |
|
2214 |
||
2215 |
def spans(*args) |
1 |
2216 |
SpanCollection.new(self, extract_selector(args).merge(:tag_name => "span")) |
5 |
2217 |
end |
|
2218 |
||
2219 |
Watir.tag_to_class[:span] = Span |
1 |
2220 |
# |
|
2221 |
# @return [HTMLElement] |
|
2222 |
# |
|
2223 |
||
2224 |
def strong(*args) |
1 |
2225 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "strong")) |
34 |
2226 |
end |
|
2227 |
||
2228 |
# |
|
2229 |
# @return [HTMLElementCollection] |
|
2230 |
# |
|
2231 |
||
2232 |
def strongs(*args) |
1 |
2233 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "strong")) |
4 |
2234 |
end |
|
2235 |
||
2236 |
Watir.tag_to_class[:strong] = HTMLElement |
1 |
2237 |
# |
|
2238 |
# @return [Style] |
|
2239 |
# |
|
2240 |
||
2241 |
def style(*args) |
1 |
2242 |
Style.new(self, extract_selector(args).merge(:tag_name => "style")) |
0 |
2243 |
end |
|
2244 |
||
2245 |
# |
|
2246 |
# @return [StyleCollection] |
|
2247 |
# |
|
2248 |
||
2249 |
def styles(*args) |
1 |
2250 |
StyleCollection.new(self, extract_selector(args).merge(:tag_name => "style")) |
0 |
2251 |
end |
|
2252 |
||
2253 |
Watir.tag_to_class[:style] = Style |
1 |
2254 |
# |
|
2255 |
# @return [HTMLElement] |
|
2256 |
# |
|
2257 |
||
2258 |
def sub(*args) |
1 |
2259 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "sub")) |
0 |
2260 |
end |
|
2261 |
||
2262 |
# |
|
2263 |
# @return [HTMLElementCollection] |
|
2264 |
# |
|
2265 |
||
2266 |
def subs(*args) |
1 |
2267 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "sub")) |
0 |
2268 |
end |
|
2269 |
||
2270 |
Watir.tag_to_class[:sub] = HTMLElement |
1 |
2271 |
# |
|
2272 |
# @return [HTMLElement] |
|
2273 |
# |
|
2274 |
||
2275 |
def summary(*args) |
1 |
2276 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "summary")) |
0 |
2277 |
end |
|
2278 |
||
2279 |
# |
|
2280 |
# @return [HTMLElementCollection] |
|
2281 |
# |
|
2282 |
||
2283 |
def summaries(*args) |
1 |
2284 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "summary")) |
0 |
2285 |
end |
|
2286 |
||
2287 |
Watir.tag_to_class[:summary] = HTMLElement |
1 |
2288 |
# |
|
2289 |
# @return [HTMLElement] |
|
2290 |
# |
|
2291 |
||
2292 |
def sup(*args) |
1 |
2293 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "sup")) |
0 |
2294 |
end |
|
2295 |
||
2296 |
# |
|
2297 |
# @return [HTMLElementCollection] |
|
2298 |
# |
|
2299 |
||
2300 |
def sups(*args) |
1 |
2301 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "sup")) |
0 |
2302 |
end |
|
2303 |
||
2304 |
Watir.tag_to_class[:sup] = HTMLElement |
1 |
2305 |
# |
|
2306 |
# @return [Table] |
|
2307 |
# |
|
2308 |
||
2309 |
def table(*args) |
1 |
2310 |
Table.new(self, extract_selector(args).merge(:tag_name => "table")) |
98 |
2311 |
end |
|
2312 |
||
2313 |
# |
|
2314 |
# @return [TableCollection] |
|
2315 |
# |
|
2316 |
||
2317 |
def tables(*args) |
1 |
2318 |
TableCollection.new(self, extract_selector(args).merge(:tag_name => "table")) |
7 |
2319 |
end |
|
2320 |
||
2321 |
Watir.tag_to_class[:table] = Table |
1 |
2322 |
# |
|
2323 |
# @return [TableSection] |
|
2324 |
# |
|
2325 |
||
2326 |
def tbody(*args) |
1 |
2327 |
TableSection.new(self, extract_selector(args).merge(:tag_name => "tbody")) |
39 |
2328 |
end |
|
2329 |
||
2330 |
# |
|
2331 |
# @return [TableSectionCollection] |
|
2332 |
# |
|
2333 |
||
2334 |
def tbodys(*args) |
1 |
2335 |
TableSectionCollection.new(self, extract_selector(args).merge(:tag_name => "tbody")) |
9 |
2336 |
end |
|
2337 |
||
2338 |
Watir.tag_to_class[:tbody] = TableSection |
1 |
2339 |
# |
|
2340 |
# @return [TableDataCell] |
|
2341 |
# |
|
2342 |
||
2343 |
def td(*args) |
1 |
2344 |
TableDataCell.new(self, extract_selector(args).merge(:tag_name => "td")) |
87 |
2345 |
end |
|
2346 |
||
2347 |
# |
|
2348 |
# @return [TableDataCellCollection] |
|
2349 |
# |
|
2350 |
||
2351 |
def tds(*args) |
1 |
2352 |
TableDataCellCollection.new(self, extract_selector(args).merge(:tag_name => "td")) |
3 |
2353 |
end |
|
2354 |
||
2355 |
Watir.tag_to_class[:td] = TableDataCell |
1 |
2356 |
# |
|
2357 |
# @return [TextArea] |
|
2358 |
# |
|
2359 |
||
2360 |
def textarea(*args) |
1 |
2361 |
TextArea.new(self, extract_selector(args).merge(:tag_name => "textarea")) |
0 |
2362 |
end |
|
2363 |
||
2364 |
# |
|
2365 |
# @return [TextAreaCollection] |
|
2366 |
# |
|
2367 |
||
2368 |
def textareas(*args) |
1 |
2369 |
TextAreaCollection.new(self, extract_selector(args).merge(:tag_name => "textarea")) |
0 |
2370 |
end |
|
2371 |
||
2372 |
Watir.tag_to_class[:textarea] = TextArea |
1 |
2373 |
# |
|
2374 |
# @return [TableSection] |
|
2375 |
# |
|
2376 |
||
2377 |
def tfoot(*args) |
1 |
2378 |
TableSection.new(self, extract_selector(args).merge(:tag_name => "tfoot")) |
34 |
2379 |
end |
|
2380 |
||
2381 |
# |
|
2382 |
# @return [TableSectionCollection] |
|
2383 |
# |
|
2384 |
||
2385 |
def tfoots(*args) |
1 |
2386 |
TableSectionCollection.new(self, extract_selector(args).merge(:tag_name => "tfoot")) |
8 |
2387 |
end |
|
2388 |
||
2389 |
Watir.tag_to_class[:tfoot] = TableSection |
1 |
2390 |
# |
|
2391 |
# @return [TableHeaderCell] |
|
2392 |
# |
|
2393 |
||
2394 |
def th(*args) |
1 |
2395 |
TableHeaderCell.new(self, extract_selector(args).merge(:tag_name => "th")) |
0 |
2396 |
end |
|
2397 |
||
2398 |
# |
|
2399 |
# @return [TableHeaderCellCollection] |
|
2400 |
# |
|
2401 |
||
2402 |
def ths(*args) |
1 |
2403 |
TableHeaderCellCollection.new(self, extract_selector(args).merge(:tag_name => "th")) |
1 |
2404 |
end |
|
2405 |
||
2406 |
Watir.tag_to_class[:th] = TableHeaderCell |
1 |
2407 |
# |
|
2408 |
# @return [TableSection] |
|
2409 |
# |
|
2410 |
||
2411 |
def thead(*args) |
1 |
2412 |
TableSection.new(self, extract_selector(args).merge(:tag_name => "thead")) |
34 |
2413 |
end |
|
2414 |
||
2415 |
# |
|
2416 |
# @return [TableSectionCollection] |
|
2417 |
# |
|
2418 |
||
2419 |
def theads(*args) |
1 |
2420 |
TableSectionCollection.new(self, extract_selector(args).merge(:tag_name => "thead")) |
8 |
2421 |
end |
|
2422 |
||
2423 |
Watir.tag_to_class[:thead] = TableSection |
1 |
2424 |
# |
|
2425 |
# @return [Time] |
|
2426 |
# |
|
2427 |
||
2428 |
def time(*args) |
1 |
2429 |
Time.new(self, extract_selector(args).merge(:tag_name => "time")) |
0 |
2430 |
end |
|
2431 |
||
2432 |
# |
|
2433 |
# @return [TimeCollection] |
|
2434 |
# |
|
2435 |
||
2436 |
def times(*args) |
1 |
2437 |
TimeCollection.new(self, extract_selector(args).merge(:tag_name => "time")) |
0 |
2438 |
end |
|
2439 |
||
2440 |
Watir.tag_to_class[:time] = Time |
1 |
2441 |
# |
|
2442 |
# @return [Title] |
|
2443 |
# |
|
2444 |
||
2445 |
def title(*args) |
1 |
2446 |
Title.new(self, extract_selector(args).merge(:tag_name => "title")) |
0 |
2447 |
end |
|
2448 |
||
2449 |
# |
|
2450 |
# @return [TitleCollection] |
|
2451 |
# |
|
2452 |
||
2453 |
def titles(*args) |
1 |
2454 |
TitleCollection.new(self, extract_selector(args).merge(:tag_name => "title")) |
0 |
2455 |
end |
|
2456 |
||
2457 |
Watir.tag_to_class[:title] = Title |
1 |
2458 |
# |
|
2459 |
# @return [TableRow] |
|
2460 |
# |
|
2461 |
||
2462 |
def tr(*args) |
1 |
2463 |
TableRow.new(self, extract_selector(args).merge(:tag_name => "tr")) |
61 |
2464 |
end |
|
2465 |
||
2466 |
# |
|
2467 |
# @return [TableRowCollection] |
|
2468 |
# |
|
2469 |
||
2470 |
def trs(*args) |
1 |
2471 |
TableRowCollection.new(self, extract_selector(args).merge(:tag_name => "tr")) |
58 |
2472 |
end |
|
2473 |
||
2474 |
Watir.tag_to_class[:tr] = TableRow |
1 |
2475 |
# |
|
2476 |
# @return [Track] |
|
2477 |
# |
|
2478 |
||
2479 |
def track(*args) |
1 |
2480 |
Track.new(self, extract_selector(args).merge(:tag_name => "track")) |
0 |
2481 |
end |
|
2482 |
||
2483 |
# |
|
2484 |
# @return [TrackCollection] |
|
2485 |
# |
|
2486 |
||
2487 |
def tracks(*args) |
1 |
2488 |
TrackCollection.new(self, extract_selector(args).merge(:tag_name => "track")) |
0 |
2489 |
end |
|
2490 |
||
2491 |
Watir.tag_to_class[:track] = Track |
1 |
2492 |
# |
|
2493 |
# @return [UList] |
|
2494 |
# |
|
2495 |
||
2496 |
def ul(*args) |
1 |
2497 |
UList.new(self, extract_selector(args).merge(:tag_name => "ul")) |
29 |
2498 |
end |
|
2499 |
||
2500 |
# |
|
2501 |
# @return [UListCollection] |
|
2502 |
# |
|
2503 |
||
2504 |
def uls(*args) |
1 |
2505 |
UListCollection.new(self, extract_selector(args).merge(:tag_name => "ul")) |
4 |
2506 |
end |
|
2507 |
||
2508 |
Watir.tag_to_class[:ul] = UList |
1 |
2509 |
# |
|
2510 |
# @return [HTMLElement] |
|
2511 |
# |
|
2512 |
||
2513 |
def var(*args) |
1 |
2514 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "var")) |
0 |
2515 |
end |
|
2516 |
||
2517 |
# |
|
2518 |
# @return [HTMLElementCollection] |
|
2519 |
# |
|
2520 |
||
2521 |
def vars(*args) |
1 |
2522 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "var")) |
0 |
2523 |
end |
|
2524 |
||
2525 |
Watir.tag_to_class[:var] = HTMLElement |
1 |
2526 |
# |
|
2527 |
# @return [Video] |
|
2528 |
# |
|
2529 |
||
2530 |
def video(*args) |
1 |
2531 |
Video.new(self, extract_selector(args).merge(:tag_name => "video")) |
0 |
2532 |
end |
|
2533 |
||
2534 |
# |
|
2535 |
# @return [VideoCollection] |
|
2536 |
# |
|
2537 |
||
2538 |
def videos(*args) |
1 |
2539 |
VideoCollection.new(self, extract_selector(args).merge(:tag_name => "video")) |
0 |
2540 |
end |
|
2541 |
||
2542 |
Watir.tag_to_class[:video] = Video |
1 |
2543 |
# |
|
2544 |
# @return [HTMLElement] |
|
2545 |
# |
|
2546 |
||
2547 |
def wbr(*args) |
1 |
2548 |
HTMLElement.new(self, extract_selector(args).merge(:tag_name => "wbr")) |
0 |
2549 |
end |
|
2550 |
||
2551 |
# |
|
2552 |
# @return [HTMLElementCollection] |
|
2553 |
# |
|
2554 |
||
2555 |
def wbrs(*args) |
1 |
2556 |
HTMLElementCollection.new(self, extract_selector(args).merge(:tag_name => "wbr")) |
0 |
2557 |
end |
|
2558 |
||
2559 |
Watir.tag_to_class[:wbr] = HTMLElement |
1 |
2560 |
end # Container |
|
2561 |
end # Watir |
./lib/watir-webdriver/elements/hidden.rb91.67 % covered |
||
# | Hits | |
---|---|---|
1 |
# encoding: utf-8 |
|
2 |
module Watir |
1 |
3 |
class Hidden < Input |
1 |
4 |
def visible? |
1 |
5 |
false |
0 |
6 |
end |
|
7 |
end |
|
8 |
||
9 |
module Container |
1 |
10 |
def hidden(*args) |
1 |
11 |
Hidden.new(self, extract_selector(args).merge(:tag_name => "input", :type => "hidden")) |
41 |
12 |
end |
|
13 |
||
14 |
def hiddens(*args) |
1 |
15 |
HiddenCollection.new(self, extract_selector(args).merge(:tag_name => "input", :type => "hidden")) |
4 |
16 |
end |
|
17 |
end # Container |
|
18 |
||
19 |
class HiddenCollection < InputCollection |
1 |
20 |
def element_class |
1 |
21 |
Hidden |
7 |
22 |
end |
|
23 |
end # HiddenCollection |
|
24 |
end |
./lib/watir-webdriver/elements/image.rb71.43 % covered |
||
# | Hits | |
---|---|---|
1 |
# encoding: utf-8 |
|
2 |
module Watir |
1 |
3 |
class Image < HTMLElement |
1 |
4 |
||
5 |
alias_method :loaded?, :complete? |
1 |
6 |
||
7 |
# |
|
8 |
# returns the image's width in pixels |
|
9 |
# |
|
10 |
# @return [Integer] width |
|
11 |
# |
|
12 |
||
13 |
def width |
1 |
14 |
assert_exists |
2 |
15 |
driver.execute_script "return arguments[0].width", @element |
1 |
16 |
end |
|
17 |
||
18 |
# |
|
19 |
# returns the image's height in pixels |
|
20 |
# |
|
21 |
# @return [Integer] height |
|
22 |
# |
|
23 |
||
24 |
def height |
1 |
25 |
assert_exists |
2 |
26 |
driver.execute_script "return arguments[0].height", @element |
1 |
27 |
end |
|
28 |
||
29 |
def file_created_date |
1 |
30 |
assert_exists |
0 |
31 |
raise NotImplementedError |
0 |
32 |
end |
|
33 |
||
34 |
def file_size |
1 |
35 |
assert_exists |
0 |
36 |
raise NotImplementedError |
0 |
37 |
end |
|
38 |
||
39 |
def save(path) |
1 |
40 |
assert_exists |
0 |
41 |
raise NotImplementedError |
0 |
42 |
end |
|
43 |
||
44 |
end # Image |
|
45 |
||
46 |
module Container |
1 |
47 |
alias_method :image, :img |
1 |
48 |
alias_method :images, :imgs |
1 |
49 |
end # Container |
|
50 |
||
51 |
end # Watir |
./lib/watir-webdriver/elements/input.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
# encoding: utf-8 |
|
2 |
module Watir |
1 |
3 |
class Input < HTMLElement |
1 |
4 |
||
5 |
alias_method :readonly?, :read_only? |
1 |
6 |
||
7 |
def enabled? |
1 |
8 |
!disabled? |
16 |
9 |
end |
|
10 |
||
11 |
# |
|
12 |
# Return the type attribute of the element, or 'text' if the attribute is invalid. |
|
13 |
# TODO: discuss. |
|
14 |
# |
|
15 |
# @return [String] |
|
16 |
# |
|
17 |
||
18 |
def type |
1 |
19 |
assert_exists |
12 |
20 |
value = @element.attribute("type").to_s |
7 |
21 |
||
22 |
# we return 'text' if the type is invalid |
|
23 |
# not sure if we really should do this |
|
24 |
TextFieldLocator::NON_TEXT_TYPES.include?(value) ? value : 'text' |
7 |
25 |
end |
|
26 |
||
27 |
end # Input |
|
28 |
end # Watir |
./lib/watir-webdriver/elements/link.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
# encoding: utf-8 |
|
2 |
module Watir |
1 |
3 |
module Container |
1 |
4 |
alias_method :link, :a |
1 |
5 |
alias_method :links, :as |
1 |
6 |
end |
|
7 |
end # Watir |
./lib/watir-webdriver/elements/option.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
# encoding: utf-8 |
|
2 |
module Watir |
1 |
3 |
||
4 |
# |
|
5 |
# Represents an option in a select list. |
|
6 |
# |
|
7 |
||
8 |
class Option < HTMLElement |
1 |
9 |
||
10 |
# |
|
11 |
# Select this option |
|
12 |
# |
|
13 |
||
14 |
def select |
1 |
15 |
assert_exists |
12 |
16 |
||
17 |
@element.select |
6 |
18 |
fire_event("onclick") rescue nil |
6 |
19 |
end |
|
20 |
||
21 |
# |
|
22 |
# Toggle the selected state of this option |
|
23 |
# |
|
24 |
||
25 |
def toggle |
1 |
26 |
assert_exists |
14 |
27 |
@element.toggle |
14 |
28 |
end |
|
29 |
||
30 |
# |
|
31 |
# Is this option selected? |
|
32 |
# |
|
33 |
||
34 |
def selected? |
1 |
35 |
assert_exists |
133 |
36 |
@element.selected? |
133 |
37 |
end |
|
38 |
||
39 |
def text |
1 |
40 |
assert_exists |
35 |
41 |
||
42 |
# A little unintuitive - we'll return the 'label' or 'text' attribute if |
|
43 |
# they exist, otherwise the inner text of the element |
|
44 |
||
45 |
attribute = [:label, :text].find { |a| attribute? a } |
102 |
46 |
||
47 |
if attribute |
35 |
48 |
@element.attribute(attribute) |
3 |
49 |
else |
|
50 |
@element.text |
32 |
51 |
end |
|
52 |
end |
|
53 |
||
54 |
end # Option |
|
55 |
end # Watir |
./lib/watir-webdriver/elements/radio.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
# encoding: utf-8 |
|
2 |
module Watir |
1 |
3 |
class Radio < Input |
1 |
4 |
# |
|
5 |
# Select this radio button. |
|
6 |
# |
|
7 |
||
8 |
def set |
1 |
9 |
assert_exists |
15 |
10 |
assert_enabled |
13 |
11 |
||
12 |
@element.click unless set? |
11 |
13 |
end |
|
14 |
||
15 |
# |
|
16 |
# Is this radio set? |
|
17 |
# |
|
18 |
||
19 |
def set? |
1 |
20 |
assert_exists |
20 |
21 |
@element.selected? |
18 |
22 |
end |
|
23 |
end # Radio |
|
24 |
||
25 |
module Container |
1 |
26 |
def radio(*args) |
1 |
27 |
Radio.new(self, extract_selector(args).merge(:tag_name => "input", :type => "radio")) |
103 |
28 |
end |
|
29 |
||
30 |
def radios(*args) |
1 |
31 |
RadioCollection.new(self, extract_selector(args).merge(:tag_name => "input", :type => "radio" )) |
4 |
32 |
end |
|
33 |
end # Container |
|
34 |
||
35 |
class RadioCollection < InputCollection |
1 |
36 |
private |
1 |
37 |
||
38 |
def element_class |
1 |
39 |
Radio |
15 |
40 |
end |
|
41 |
end # RadioCollection |
|
42 |
end # Watir |
./lib/watir-webdriver/elements/select.rb97.59 % covered |
||
# | Hits | |
---|---|---|
1 |
# encoding: utf-8 |
|
2 |
module Watir |
1 |
3 |
class Select < HTMLElement |
1 |
4 |
include Watir::Exception |
1 |
5 |
||
6 |
# |
|
7 |
# Returns true if this element is enabled |
|
8 |
# |
|
9 |
# @return [Boolean] |
|
10 |
# |
|
11 |
||
12 |
def enabled? |
1 |
13 |
!disabled? |
3 |
14 |
end |
|
15 |
||
16 |
# |
|
17 |
# Clear all selected options |
|
18 |
# |
|
19 |
||
20 |
def clear |
1 |
21 |
assert_exists |
9 |
22 |
||
23 |
raise Error, "you can only clear multi-selects" unless multiple? |
8 |
24 |
||
25 |
options.each do |o| |
7 |
26 |
o.toggle if o.selected? |
28 |
27 |
end |
|
28 |
end |
|
29 |
||
30 |
# |
|
31 |
# Get all the options in the select list |
|
32 |
# |
|
33 |
# @return [Watir::OptionCollection] |
|
34 |
# |
|
35 |
||
36 |
def options |
1 |
37 |
assert_exists |
41 |
38 |
super |
39 |
39 |
end |
|
40 |
||
41 |
# |
|
42 |
# Returns true if the select list has one or more options where text or label matches the given value. |
|
43 |
# |
|
44 |
# @param [String, Regexp] value A value. |
|
45 |
# @return [Boolean] |
|
46 |
# |
|
47 |
||
48 |
def include?(str_or_rx) |
1 |
49 |
assert_exists |
2 |
50 |
# TODO: optimize similar to selected? |
|
51 |
options.any? { |e| str_or_rx === e.text } |
9 |
52 |
end |
|
53 |
||
54 |
# |
|
55 |
# Select the option(s) whose text or label matches the given string. |
|
56 |
# If this is a multi-select and several options match the value given, all will be selected. |
|
57 |
# |
|
58 |
# @param [String, Regexp] value A value. |
|
59 |
# @raise [Watir::Exception::NoValueFoundException] if the value does not exist. |
|
60 |
# @return [String] The text of the option selected. If multiple options match, returns the first match. |
|
61 |
# |
|
62 |
||
63 |
def select(str_or_rx) |
1 |
64 |
select_by :text, str_or_rx |
21 |
65 |
end |
|
66 |
||
67 |
# |
|
68 |
# Selects the option(s) whose value attribute matches the given string. |
|
69 |
# |
|
70 |
# @see +select+ |
|
71 |
# |
|
72 |
# @param [String, Regexp] value A value. |
|
73 |
# @raise [Watir::Exception::NoValueFoundException] if the value does not exist. |
|
74 |
# @return [String] The option selected. If multiple options match, returns the first match |
|
75 |
# |
|
76 |
||
77 |
def select_value(str_or_rx) |
1 |
78 |
select_by :value, str_or_rx |
4 |
79 |
end |
|
80 |
||
81 |
# |
|
82 |
# Returns true if any of the selected options' text or label match the given value. |
|
83 |
# |
|
84 |
# @param [String, Regexp] value A value. |
|
85 |
# @raise [Watir::Exception::UnknownObjectException] if the value does not exist. |
|
86 |
# @return [Boolean] |
|
87 |
# |
|
88 |
||
89 |
def selected?(str_or_rx) |
1 |
90 |
assert_exists |
3 |
91 |
matches = @element.find_elements(:tag_name, 'option').select { |e| str_or_rx === e.text || str_or_rx === e.attribute(:label) } |
21 |
92 |
||
93 |
if matches.empty? |
3 |
94 |
raise UnknownObjectException, "Unable to locate option matching #{str_or_rx.inspect}" |
1 |
95 |
end |
|
96 |
||
97 |
matches.any? { |e| e.selected? } |
4 |
98 |
end |
|
99 |
||
100 |
# |
|
101 |
# Returns the value of the first selected option in the select list. |
|
102 |
# Returns nil if no option is selected. |
|
103 |
# |
|
104 |
# @return [String, nil] |
|
105 |
# |
|
106 |
||
107 |
def value |
1 |
108 |
o = options.find { |e| e.selected? } || return |
37 |
109 |
o.value |
13 |
110 |
end |
|
111 |
||
112 |
||
113 |
# |
|
114 |
# @return [Array<String>] An array of strings representing the text value of the currently selected options. |
|
115 |
# |
|
116 |
||
117 |
def selected_options |
1 |
118 |
assert_exists |
17 |
119 |
options.map { |e| e.text if e.selected? }.compact |
96 |
120 |
end |
|
121 |
||
122 |
private |
1 |
123 |
||
124 |
def select_by(how, str_or_rx) |
1 |
125 |
assert_exists |
25 |
126 |
||
127 |
case str_or_rx |
25 |
128 |
when String, Numeric |
|
129 |
select_by_string(how, str_or_rx.to_s) |
16 |
130 |
when Regexp |
|
131 |
select_by_regexp(how, str_or_rx) |
8 |
132 |
else |
|
133 |
raise TypeError, "expected String or Regexp, got #{str_or_rx.inspect}:#{str_or_rx.class}" |
1 |
134 |
end |
|
135 |
end |
|
136 |
||
137 |
def select_by_string(how, string) |
1 |
138 |
xpath = option_xpath_for(how, string) |
16 |
139 |
||
140 |
if multiple? |
16 |
141 |
elements = @element.find_elements(:xpath, xpath) |
9 |
142 |
no_value_found(string) if elements.empty? |
9 |
143 |
||
144 |
elements.each { |e| e.select unless e.selected? } |
16 |
145 |
elements.first.text |
8 |
146 |
else |
|
147 |
begin |
7 |
148 |
e = @element.find_element(:xpath, xpath) |
7 |
149 |
rescue WebDriver::Error::NoSuchElementError |
|
150 |
no_value_found(string) |
1 |
151 |
end |
|
152 |
||
153 |
e.select unless e.selected? |
6 |
154 |
||
155 |
safe_text(e) |
6 |
156 |
end |
|
157 |
end |
|
158 |
||
159 |
def select_by_regexp(how, exp) |
1 |
160 |
elements = @element.find_elements(:tag_name, 'option') |
8 |
161 |
no_value_found(nil, "no options in select list") if elements.empty? |
8 |
162 |
||
163 |
if multiple? |
8 |
164 |
found = elements.select do |e| |
5 |
165 |
next unless matches_regexp?(how, e, exp) |
20 |
166 |
e.select unless e.selected? |
11 |
167 |
true |
11 |
168 |
end |
|
169 |
||
170 |
no_value_found(exp) if found.empty? |
5 |
171 |
||
172 |
found.first.text |
4 |
173 |
else |
|
174 |
element = elements.find { |e| matches_regexp?(how, e, exp) } |
13 |
175 |
no_value_found(exp) unless element |
3 |
176 |
||
177 |
element.select unless element.selected? |
2 |
178 |
||
179 |
safe_text(element) |
2 |
180 |
end |
|
181 |
end |
|
182 |
||
183 |
def option_xpath_for(how, string) |
1 |
184 |
case how |
16 |
185 |
when :text |
|
186 |
".//option[normalize-space()='#{string}' or @label='#{string}']" |
14 |
187 |
when :value |
|
188 |
".//option[@value='#{string}']" |
2 |
189 |
else |
|
190 |
raise Error, "unknown how: #{how.inspect}" |
0 |
191 |
end |
|
192 |
end |
|
193 |
||
194 |
def matches_regexp?(how, element, exp) |
1 |
195 |
case how |
30 |
196 |
when :text |
|
197 |
element.text =~ exp || element.attribute(:label) =~ exp |
22 |
198 |
when :value |
|
199 |
element.attribute(:value) =~ exp |
8 |
200 |
else |
|
201 |
raise Error, "unknown how: #{how.inspect}" |
0 |
202 |
end |
|
203 |
end |
|
204 |
||
205 |
def safe_text(element) |
1 |
206 |
element.text |
8 |
207 |
rescue Selenium::WebDriver::Error::ObsoleteElementError |
|
208 |
# guard for scenario where selecting the element changes the page, making our element obsolete |
|
209 |
||
210 |
'' |
1 |
211 |
end |
|
212 |
||
213 |
def no_value_found(arg, msg = nil) |
1 |
214 |
raise NoValueFoundException, msg || "#{arg.inspect} not found in select list" |
4 |
215 |
end |
|
216 |
end # Select |
|
217 |
||
218 |
module Container |
1 |
219 |
alias_method :select_list, :select |
1 |
220 |
alias_method :select_lists, :selects |
1 |
221 |
end # Container |
|
222 |
end # Watir |
./lib/watir-webdriver/elements/table.rb93.75 % covered |
||
# | Hits | |
---|---|---|
1 |
# encoding: utf-8 |
|
2 |
||
3 |
module Watir |
1 |
4 |
class Table < HTMLElement |
1 |
5 |
include RowContainer |
1 |
6 |
||
7 |
def hashes |
1 |
8 |
all_rows = rows.to_a |
1 |
9 |
header_row = all_rows.shift or raise Exception::Error, "no rows in table" |
1 |
10 |
||
11 |
headers = header_row.ths.map { |header_cell| header_cell.text } |
5 |
12 |
result = [] |
1 |
13 |
||
14 |
all_rows.each_with_index do |row, idx| |
1 |
15 |
cells = row.cells.to_a |
7 |
16 |
if cells.length != headers.length |
7 |
17 |
raise Exception::Error, "row at index #{idx} has #{cells.length} cells, expected #{headers.length}" |
0 |
18 |
end |
|
19 |
||
20 |
result << headers.inject({}) { |res, header| res.merge(header => cells.shift.text) } |
35 |
21 |
end |
|
22 |
||
23 |
result |
1 |
24 |
end |
|
25 |
||
26 |
# |
|
27 |
# Get the n'th row of this table. |
|
28 |
# |
|
29 |
# @return Watir::TableRow |
|
30 |
# |
|
31 |
||
32 |
def [](idx) |
1 |
33 |
row(:index, idx) |
11 |
34 |
end |
|
35 |
||
36 |
end # Table |
|
37 |
end # Watir |
./lib/watir-webdriver/elements/table_cell.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
module Watir |
1 |
2 |
class TableCell < HTMLElement |
1 |
3 |
# @private |
|
4 |
attr_writer :locator_class |
1 |
5 |
||
6 |
def locator_class |
1 |
7 |
@locator_class || super |
102 |
8 |
end |
|
9 |
||
10 |
def colspan |
1 |
11 |
value = attribute_value :colspan |
2 |
12 |
value ? Integer(value) : 1 |
2 |
13 |
end |
|
14 |
end |
|
15 |
||
16 |
class TableCellCollection < ElementCollection |
1 |
17 |
attr_writer :locator_class |
1 |
18 |
||
19 |
def locator_class |
1 |
20 |
@locator_class || super |
90 |
21 |
end |
|
22 |
||
23 |
def elements |
1 |
24 |
# we do this craziness since the xpath used will find direct child rows |
|
25 |
# before any rows inside thead/tbody/tfoot... |
|
26 |
elements = super |
45 |
27 |
||
28 |
if locator_class == ChildCellLocator |
45 |
29 |
elements = elements.sort_by { |row| row.attribute(:cellIndex).to_i } |
115 |
30 |
end |
|
31 |
||
32 |
elements |
45 |
33 |
end |
|
34 |
||
35 |
end |
|
36 |
end |
./lib/watir-webdriver/elements/table_row.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
module Watir |
1 |
2 |
class TableRow < HTMLElement |
1 |
3 |
include CellContainer |
1 |
4 |
||
5 |
# @private |
|
6 |
attr_writer :locator_class |
1 |
7 |
||
8 |
# |
|
9 |
# Get the n'th cell (<th> or <td>) of this row |
|
10 |
# |
|
11 |
# @return Watir::TableCell |
|
12 |
# |
|
13 |
||
14 |
def [](idx) |
1 |
15 |
cell(:index, idx) |
15 |
16 |
end |
|
17 |
||
18 |
private |
1 |
19 |
||
20 |
def locator_class |
1 |
21 |
@locator_class || super |
59 |
22 |
end |
|
23 |
end # TableRow |
|
24 |
||
25 |
||
26 |
class TableRowCollection < ElementCollection |
1 |
27 |
attr_writer :locator_class |
1 |
28 |
||
29 |
def elements |
1 |
30 |
# we do this craziness since the xpath used will find direct child rows |
|
31 |
# before any rows inside thead/tbody/tfoot... |
|
32 |
elements = super |
62 |
33 |
||
34 |
if locator_class == ChildRowLocator and @parent.kind_of? Table |
62 |
35 |
elements = elements.sort_by { |row| row.attribute(:rowIndex).to_i } |
54 |
36 |
end |
|
37 |
||
38 |
elements |
62 |
39 |
end |
|
40 |
||
41 |
def locator_class |
1 |
42 |
@locator_class || super |
120 |
43 |
end |
|
44 |
end # TableRowCollection |
|
45 |
end # Watir |
./lib/watir-webdriver/elements/table_section.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
module Watir |
1 |
2 |
class TableSection < HTMLElement |
1 |
3 |
include RowContainer |
1 |
4 |
||
5 |
def [](idx) |
1 |
6 |
row(:index => idx) |
19 |
7 |
end |
|
8 |
end |
|
9 |
end |
./lib/watir-webdriver/elements/text_field.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
# encoding: utf-8 |
|
2 |
module Watir |
1 |
3 |
class TextField < Input |
1 |
4 |
||
5 |
attributes Watir::TextArea.typed_attributes |
1 |
6 |
remove_method :type # we want Input#type here, which was overriden by TextArea's attributes |
1 |
7 |
||
8 |
# |
|
9 |
# Clear the element, the type in the given value. |
|
10 |
# |
|
11 |
||
12 |
def set(*args) |
1 |
13 |
assert_exists |
12 |
14 |
assert_writable |
10 |
15 |
||
16 |
@element.clear |
10 |
17 |
@element.send_keys(*args) |
10 |
18 |
end |
|
19 |
alias_method :value=, :set |
1 |
20 |
||
21 |
# |
|
22 |
# Append the given value to the text in the text field. |
|
23 |
# |
|
24 |
||
25 |
def append(*args) |
1 |
26 |
assert_exists |
5 |
27 |
assert_writable |
4 |
28 |
||
29 |
@element.send_keys(*args) |
2 |
30 |
end |
|
31 |
||
32 |
# |
|
33 |
# Clear the text field. |
|
34 |
# |
|
35 |
||
36 |
def clear |
1 |
37 |
assert_exists |
3 |
38 |
@element.clear |
2 |
39 |
end |
|
40 |
||
41 |
# |
|
42 |
# Returns the text in the text field. |
|
43 |
# |
|
44 |
||
45 |
def value |
1 |
46 |
# since 'value' is an attribute on input fields, we override this here |
|
47 |
assert_exists |
43 |
48 |
@element.value |
42 |
49 |
end |
|
50 |
||
51 |
private |
1 |
52 |
||
53 |
def locate |
1 |
54 |
@parent.assert_exists |
134 |
55 |
TextFieldLocator.new(@parent.wd, @selector, self.class.attribute_list).locate |
134 |
56 |
end |
|
57 |
||
58 |
def selector_string |
1 |
59 |
selector = @selector.dup |
28 |
60 |
selector[:type] = '(any text type)' |
28 |
61 |
selector[:tag_name] = "input or textarea" |
28 |
62 |
selector.inspect |
28 |
63 |
end |
|
64 |
end |
|
65 |
||
66 |
module Container |
1 |
67 |
def text_field(*args) |
1 |
68 |
TextField.new(self, extract_selector(args).merge(:tag_name => "input")) |
140 |
69 |
end |
|
70 |
||
71 |
def text_fields(*args) |
1 |
72 |
TextFieldCollection.new(self, extract_selector(args).merge(:tag_name => "input")) |
6 |
73 |
end |
|
74 |
end # Container |
|
75 |
||
76 |
class TextFieldCollection < InputCollection |
1 |
77 |
private |
1 |
78 |
||
79 |
def locator_class |
1 |
80 |
TextFieldLocator |
6 |
81 |
end |
|
82 |
||
83 |
def element_class |
1 |
84 |
TextField |
43 |
85 |
end |
|
86 |
end # TextFieldCollection |
|
87 |
end |
./lib/watir-webdriver/exception.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
# encoding: utf-8 |
|
2 |
||
3 |
module Watir |
1 |
4 |
module Exception |
1 |
5 |
class Error < StandardError; end |
1 |
6 |
||
7 |
# TODO: rename Object -> Element? |
|
8 |
class UnknownObjectException < Error; end |
1 |
9 |
class ObjectDisabledException < Error; end |
1 |
10 |
class ObjectReadOnlyException < Error; end |
1 |
11 |
class NoValueFoundException < Error; end |
1 |
12 |
class MissingWayOfFindingObjectException < Error; end |
1 |
13 |
class UnknownCellException < Error; end |
1 |
14 |
class NoMatchingWindowFoundException < Error; end |
1 |
15 |
class NoStatusBarException < Error; end |
1 |
16 |
class NavigationException < Error; end |
1 |
17 |
class UnknownFrameException < Error; end |
1 |
18 |
class UnknownRowException < Error; end |
1 |
19 |
||
20 |
end # Exception |
|
21 |
end # Watir |
./lib/watir-webdriver/extensions/alerts.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
module Watir |
1 |
2 |
||
3 |
# |
|
4 |
# Module provided by optional require: |
|
5 |
# |
|
6 |
# require "watir-webdriver/extensions/alerts" |
|
7 |
# |
|
8 |
||
9 |
module AlertHelper |
1 |
10 |
||
11 |
# |
|
12 |
# Overwrite window.alert() |
|
13 |
# |
|
14 |
# This method is provided by an optional require - API is subject to change. |
|
15 |
# |
|
16 |
# @example |
|
17 |
# browser.alert do |
|
18 |
# browser.button(:value => "Alert").click |
|
19 |
# end #=> "the alert message" |
|
20 |
# |
|
21 |
||
22 |
def alert(&blk) |
1 |
23 |
execute_script "window.alert = function(msg) { window.__lastWatirAlert = msg; }" |
1 |
24 |
yield |
1 |
25 |
execute_script "return window.__lastWatirAlert" |
1 |
26 |
end |
|
27 |
||
28 |
# |
|
29 |
# Overwrite window.confirm() |
|
30 |
# |
|
31 |
# This method is provided by an optional require - API is subject to change. |
|
32 |
# |
|
33 |
# @example |
|
34 |
# browser.confirm(true) do |
|
35 |
# browser.button(:value => "Confirm").click |
|
36 |
# end #=> "the confirm message" |
|
37 |
||
38 |
def confirm(bool, &blk) |
1 |
39 |
execute_script "window.confirm = function(msg) { window.__lastWatirConfirm = msg; return #{!!bool} }" |
2 |
40 |
yield |
2 |
41 |
execute_script "return window.__lastWatirConfirm" |
2 |
42 |
end |
|
43 |
||
44 |
# |
|
45 |
# Overwrite window.prompt() |
|
46 |
# |
|
47 |
# This method is provided by an optional require - API is subject to change. |
|
48 |
# |
|
49 |
# @example |
|
50 |
# browser.prompt("hello") do |
|
51 |
# browser.button(:value => "Prompt").click |
|
52 |
# end #=> { :message => "foo", :default_value => "bar" } |
|
53 |
# |
|
54 |
||
55 |
def prompt(answer, &blk) |
1 |
56 |
execute_script "window.prompt = function(text, value) { window.__lastWatirPrompt = { message: text, default_value: value }; return #{answer.to_json}; }" |
1 |
57 |
yield |
1 |
58 |
result = execute_script "return window.__lastWatirPrompt" |
1 |
59 |
||
60 |
result && result.dup.each_key { |k| result[k.to_sym] = result.delete(k)} |
3 |
61 |
result |
1 |
62 |
end |
|
63 |
end |
|
64 |
||
65 |
class Browser |
1 |
66 |
include AlertHelper |
1 |
67 |
end |
|
68 |
||
69 |
end |
./lib/watir-webdriver/extensions/wait.rb97.37 % covered |
||
# | Hits | |
---|---|---|
1 |
# encoding: utf-8 |
|
2 |
module Watir |
1 |
3 |
||
4 |
# |
|
5 |
# Module provided by optional require: |
|
6 |
# |
|
7 |
# require "watir-webdriver/extensions/wait" |
|
8 |
# |
|
9 |
||
10 |
module Wait |
1 |
11 |
module_function |
1 |
12 |
||
13 |
class TimeoutError < StandardError |
1 |
14 |
end |
|
15 |
||
16 |
# |
|
17 |
# Wait until the block evaluates to true or times out. |
|
18 |
# |
|
19 |
||
20 |
def until(timeout = 30, &block) |
1 |
21 |
end_time = ::Time.now + timeout |
8 |
22 |
||
23 |
until ::Time.now > end_time |
8 |
24 |
result = yield(self) |
15 |
25 |
return result if result |
15 |
26 |
sleep 0.5 |
11 |
27 |
end |
|
28 |
||
29 |
raise TimeoutError, "timed out after #{timeout} seconds" |
4 |
30 |
end |
|
31 |
||
32 |
# |
|
33 |
# Wait while the block evaluates to true or times out. |
|
34 |
# |
|
35 |
||
36 |
def while(timeout = 30, &block) |
1 |
37 |
end_time = ::Time.now + timeout |
5 |
38 |
||
39 |
until ::Time.now > end_time |
5 |
40 |
return unless yield(self) |
9 |
41 |
sleep 0.5 |
6 |
42 |
end |
|
43 |
||
44 |
raise TimeoutError, "timed out after #{timeout} seconds" |
2 |
45 |
end |
|
46 |
||
47 |
end # Wait |
|
48 |
||
49 |
# |
|
50 |
# Wraps an Element so that any subsequent method calls are |
|
51 |
# put on hold until the element is present (exists and is visible) on the page. |
|
52 |
# |
|
53 |
||
54 |
class WhenPresentDecorator |
1 |
55 |
def initialize(element, timeout) |
1 |
56 |
@element = element |
2 |
57 |
@timeout = timeout |
2 |
58 |
end |
|
59 |
||
60 |
def method_missing(m, *args, &block) |
1 |
61 |
unless @element.respond_to?(m) |
2 |
62 |
raise NoMethodError, "undefined method `#{m}' for #{@element.inspect}:#{@element.class}" |
0 |
63 |
end |
|
64 |
||
65 |
Watir::Wait.until(@timeout) { @element.present? } |
6 |
66 |
||
67 |
@element.__send__(m, *args, &block) |
1 |
68 |
end |
|
69 |
end # WhenPresentDecorator |
|
70 |
||
71 |
class Element |
1 |
72 |
||
73 |
# |
|
74 |
# Returns true if the element exists and is visible on the page |
|
75 |
# |
|
76 |
# This method is provided by an optional require. |
|
77 |
# @see Watir::Wait |
|
78 |
# |
|
79 |
||
80 |
def present? |
1 |
81 |
exists? && visible? |
21 |
82 |
end |
|
83 |
||
84 |
# |
|
85 |
# Waits until the element is present. |
|
86 |
# |
|
87 |
# This method is provided by an optional require. |
|
88 |
# @see Watir::Wait |
|
89 |
# |
|
90 |
# Example: |
|
91 |
# browser.button(:id, 'foo').when_present.click |
|
92 |
# browser.div(:id, 'bar').when_present { |div| ... } |
|
93 |
# browser.p(:id, 'baz').when_present(60).text |
|
94 |
# |
|
95 |
# @param [Integer] timeout seconds to wait before timing out |
|
96 |
# |
|
97 |
||
98 |
def when_present(timeout = 30) |
1 |
99 |
if block_given? |
4 |
100 |
Watir::Wait.until(timeout) { self.present? } |
6 |
101 |
yield self |
1 |
102 |
else |
|
103 |
WhenPresentDecorator.new(self, timeout) |
2 |
104 |
end |
|
105 |
end |
|
106 |
||
107 |
# |
|
108 |
# Waits until the element is present. |
|
109 |
# |
|
110 |
# This method is provided by an optional require. |
|
111 |
# |
|
112 |
# @param [Integer] timeout seconds to wait before timing out |
|
113 |
# |
|
114 |
# @see Watir::Wait |
|
115 |
# @see Watir::Element#present? |
|
116 |
# |
|
117 |
||
118 |
def wait_until_present(timeout = 30) |
1 |
119 |
Watir::Wait.until(timeout) { self.present? } |
6 |
120 |
end |
|
121 |
||
122 |
# |
|
123 |
# Waits while the element is present. |
|
124 |
# |
|
125 |
# This method is provided by an optional require. |
|
126 |
# |
|
127 |
# @param [Integer] timeout seconds to wait before timing out |
|
128 |
# |
|
129 |
# @see Watir::Wait |
|
130 |
# @see Watir::Element#present? |
|
131 |
# |
|
132 |
||
133 |
def wait_while_present(timeout = 30) |
1 |
134 |
Watir::Wait.while(timeout) { self.present? } |
9 |
135 |
rescue Selenium::WebDriver::Error::ObsoleteElementError |
|
136 |
# it's not present |
|
137 |
end |
|
138 |
end # Element |
|
139 |
||
140 |
||
141 |
end # Watir |
./lib/watir-webdriver/locators/button_locator.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
module Watir |
1 |
2 |
class ButtonLocator < ElementLocator |
1 |
3 |
||
4 |
def locate_all |
1 |
5 |
find_all_by_multiple |
8 |
6 |
end |
|
7 |
||
8 |
private |
1 |
9 |
||
10 |
def wd_find_first_by(how, what) |
1 |
11 |
if how == :tag_name |
1 |
12 |
how = :xpath |
1 |
13 |
what = ".//button | .//input[#{attribute_expression :type => Button::VALID_TYPES}]" |
1 |
14 |
end |
|
15 |
||
16 |
super |
1 |
17 |
end |
|
18 |
||
19 |
def build_xpath(selectors) |
1 |
20 |
return if selectors.values.any? { |e| e.kind_of? Regexp } |
264 |
21 |
||
22 |
selectors.delete(:tag_name) || raise("internal error: no tag_name?!") |
101 |
23 |
||
24 |
@building = :button |
101 |
25 |
button_attr_exp = attribute_expression(selectors) |
101 |
26 |
||
27 |
@building = :input |
101 |
28 |
selectors[:type] = Button::VALID_TYPES |
101 |
29 |
input_attr_exp = attribute_expression(selectors) |
101 |
30 |
||
31 |
xpath = ".//button" |
101 |
32 |
xpath << "[#{button_attr_exp}]" unless button_attr_exp.empty? |
101 |
33 |
xpath << " | .//input" |
101 |
34 |
xpath << "[#{input_attr_exp}]" |
101 |
35 |
||
36 |
p :build_xpath => xpath if $DEBUG |
101 |
37 |
||
38 |
xpath |
101 |
39 |
end |
|
40 |
||
41 |
def lhs_for(key) |
1 |
42 |
if @building == :input && key == :text |
476 |
43 |
"@value" |
3 |
44 |
elsif @building == :button && key == :value |
473 |
45 |
"text()" |
4 |
46 |
else |
|
47 |
super |
469 |
48 |
end |
|
49 |
end |
|
50 |
||
51 |
def matches_selector?(element, rx_selector) |
1 |
52 |
rx_selector = rx_selector.dup |
76 |
53 |
||
54 |
[:value, :caption].each do |key| |
76 |
55 |
if rx_selector.has_key?(key) |
152 |
56 |
correct_key = element.tag_name == 'button' ? :text : :value |
12 |
57 |
rx_selector[correct_key] = rx_selector.delete(key) |
12 |
58 |
end |
|
59 |
end |
|
60 |
||
61 |
super |
76 |
62 |
end |
|
63 |
||
64 |
def tag_name_matches?(element, _) |
1 |
65 |
!!(/^(input|button)$/ === element.tag_name) |
89 |
66 |
end |
|
67 |
||
68 |
def validate_element(element) |
1 |
69 |
return if element.tag_name == "input" && !Button::VALID_TYPES.include?(element.attribute(:type)) |
73 |
70 |
super |
72 |
71 |
end |
|
72 |
||
73 |
end # ButtonLocator |
|
74 |
end # Watir |
./lib/watir-webdriver/locators/child_cell_locator.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
module Watir |
1 |
2 |
class ChildCellLocator < ElementLocator |
1 |
3 |
||
4 |
def locate_all |
1 |
5 |
find_all_by_multiple |
45 |
6 |
end |
|
7 |
||
8 |
private |
1 |
9 |
||
10 |
def by_id |
1 |
11 |
nil |
|
12 |
end |
|
13 |
||
14 |
def build_xpath(selectors) |
1 |
15 |
return if selectors.values.any? { |e| e.kind_of? Regexp } |
188 |
16 |
||
17 |
expressions = %w[./th ./td] |
62 |
18 |
attr_expr = attribute_expression(selectors) |
62 |
19 |
||
20 |
unless attr_expr.empty? |
62 |
21 |
expressions.map! { |e| "#{e}[#{attr_expr}]" } |
3 |
22 |
end |
|
23 |
||
24 |
xpath = expressions.join(" | ") |
62 |
25 |
||
26 |
p :build_xpath => xpath if $DEBUG |
62 |
27 |
||
28 |
xpath |
62 |
29 |
end |
|
30 |
||
31 |
end # ChildCellLocator |
|
32 |
end # Watir |
./lib/watir-webdriver/locators/child_row_locator.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
module Watir |
1 |
2 |
class ChildRowLocator < ElementLocator |
1 |
3 |
||
4 |
def locate_all |
1 |
5 |
find_all_by_multiple |
49 |
6 |
end |
|
7 |
||
8 |
private |
1 |
9 |
||
10 |
def by_id |
1 |
11 |
nil # avoid this |
|
12 |
end |
|
13 |
||
14 |
def build_xpath(selectors) |
1 |
15 |
return if selectors.values.any? { |e| e.kind_of? Regexp } |
190 |
16 |
selectors.delete(:tag_name) || raise("internal error: no tag_name?!") |
87 |
17 |
||
18 |
expressions = %w[./tr] |
87 |
19 |
unless %w[tbody tfoot thead].include?(@wd.tag_name) |
87 |
20 |
expressions += %w[./tbody/tr ./thead/tr ./tfoot/tr] |
47 |
21 |
end |
|
22 |
||
23 |
attr_expr = attribute_expression(selectors) |
87 |
24 |
||
25 |
unless attr_expr.empty? |
87 |
26 |
expressions.map! { |e| "#{e}[#{attr_expr}]" } |
25 |
27 |
end |
|
28 |
||
29 |
xpath = expressions.join(" | ") |
87 |
30 |
||
31 |
p :build_xpath => xpath if $DEBUG |
87 |
32 |
||
33 |
xpath |
87 |
34 |
end |
|
35 |
||
36 |
end # ChildRowLocator |
|
37 |
end # Watir |
./lib/watir-webdriver/locators/element_locator.rb98.31 % covered |
||
# | Hits | |
---|---|---|
1 |
# encoding: utf-8 |
|
2 |
module Watir |
1 |
3 |
class ElementLocator |
1 |
4 |
include Watir::Exception |
1 |
5 |
include Selenium |
1 |
6 |
||
7 |
WD_FINDERS = [ |
1 |
8 |
:class, |
|
9 |
:class_name, |
|
10 |
:css, |
|
11 |
:id, |
|
12 |
:link, |
|
13 |
:link_text, |
|
14 |
:name, |
|
15 |
:partial_link_text, |
|
16 |
:tag_name, |
|
17 |
:xpath |
|
18 |
] |
|
19 |
||
20 |
def initialize(wd, selector, valid_attributes) |
1 |
21 |
@wd = wd |
2782 |
22 |
@selector = selector.dup |
2782 |
23 |
@valid_attributes = valid_attributes |
2782 |
24 |
end |
|
25 |
||
26 |
def locate |
1 |
27 |
e = by_id and return e # short-circuit if :id is given |
2433 |
28 |
||
29 |
||
30 |
if @selector.size == 1 |
2151 |
31 |
element = find_first_by_one |
51 |
32 |
else |
|
33 |
element = find_first_by_multiple |
2100 |
34 |
end |
|
35 |
||
36 |
# this actually only applies when finding by xpath - browser.text_field(:xpath, "//input[@type='radio']") |
|
37 |
# we don't need to validate the element if we built the xpath ourselves. |
|
38 |
validate_element(element) if element |
1703 |
39 |
rescue WebDriver::Error::NoSuchElementError => wde |
|
40 |
nil |
362 |
41 |
end |
|
42 |
||
43 |
def locate_all |
1 |
44 |
if @selector.size == 1 |
241 |
45 |
find_all_by_one |
187 |
46 |
else |
|
47 |
find_all_by_multiple |
54 |
48 |
end |
|
49 |
end |
|
50 |
||
51 |
private |
1 |
52 |
||
53 |
def find_first_by_one |
1 |
54 |
how, what = @selector.to_a.first |
51 |
55 |
check_type how, what |
51 |
56 |
||
57 |
if WD_FINDERS.include?(how) |
50 |
58 |
wd_find_first_by(how, what) |
48 |
59 |
else |
|
60 |
find_first_by_multiple |
2 |
61 |
end |
|
62 |
end |
|
63 |
||
64 |
def find_all_by_one |
1 |
65 |
how, what = @selector.to_a.first |
187 |
66 |
check_type how, what |
187 |
67 |
||
68 |
if WD_FINDERS.include?(how) |
187 |
69 |
wd_find_all_by(how, what) |
187 |
70 |
else |
|
71 |
find_all_by_multiple |
0 |
72 |
end |
|
73 |
end |
|
74 |
||
75 |
def find_first_by_multiple |
1 |
76 |
selector = normalized_selector |
2102 |
77 |
||
78 |
idx = selector.delete(:index) |
2018 |
79 |
xpath = given_xpath(selector) || build_xpath(selector) |
2018 |
80 |
||
81 |
if xpath |
2017 |
82 |
# could build xpath for selector |
|
83 |
if idx |
1765 |
84 |
@wd.find_elements(:xpath, xpath)[idx] |
967 |
85 |
else |
|
86 |
@wd.find_element(:xpath, xpath) |
798 |
87 |
end |
|
88 |
else |
|
89 |
# can't use xpath, probably a regexp in there |
|
90 |
if idx |
252 |
91 |
wd_find_by_regexp_selector(selector, :select)[idx] |
16 |
92 |
else |
|
93 |
wd_find_by_regexp_selector(selector, :find) |
236 |
94 |
end |
|
95 |
end |
|
96 |
end |
|
97 |
||
98 |
def find_all_by_multiple |
1 |
99 |
selector = normalized_selector |
162 |
100 |
||
101 |
if selector.has_key? :index |
162 |
102 |
raise ArgumentError, "can't locate all elements by :index" |
1 |
103 |
end |
|
104 |
||
105 |
xpath = given_xpath(selector) || build_xpath(selector) |
161 |
106 |
if xpath |
161 |
107 |
@wd.find_elements(:xpath, xpath) |
108 |
108 |
else |
|
109 |
wd_find_by_regexp_selector(selector, :select) |
53 |
110 |
end |
|
111 |
end |
|
112 |
||
113 |
def wd_find_first_by(how, what) |
1 |
114 |
if what.kind_of? String |
48 |
115 |
@wd.find_element(how, what) |
48 |
116 |
else |
|
117 |
all_elements.find { |element| fetch_value(element, how) =~ what } |
0 |
118 |
end |
|
119 |
end |
|
120 |
||
121 |
def wd_find_all_by(how, what) |
1 |
122 |
if what.kind_of? String |
187 |
123 |
@wd.find_elements(how, what) |
180 |
124 |
else |
|
125 |
all_elements.select { |element| fetch_value(element, how) =~ what } |
179 |
126 |
end |
|
127 |
end |
|
128 |
||
129 |
def wd_find_by_regexp_selector(selector, method = :find) |
1 |
130 |
rx_selector = delete_regexps_from(selector) |
305 |
131 |
||
132 |
if rx_selector.has_key?(:label) && should_use_label_element? |
305 |
133 |
selector[:id] = id_from_label(rx_selector.delete(:label)) || return |
4 |
134 |
end |
|
135 |
||
136 |
xpath = build_xpath(selector) || raise("internal error: unable to build xpath from #{selector.inspect}") |
303 |
137 |
||
138 |
elements = @wd.find_elements(:xpath, xpath) |
303 |
139 |
elements.__send__(method) { |el| matches_selector?(el, rx_selector) } |
1510 |
140 |
end |
|
141 |
||
142 |
VALID_WHATS = [String, Regexp] |
1 |
143 |
||
144 |
def check_type(how, what) |
1 |
145 |
case how |
4886 |
146 |
when :index |
|
147 |
unless what.kind_of?(Fixnum) |
985 |
148 |
raise TypeError, "expected Fixnum, got #{what.inspect}:#{what.class}" |
1 |
149 |
end |
|
150 |
else |
|
151 |
unless VALID_WHATS.any? { |t| what.kind_of? t } |
8157 |
152 |
raise TypeError, "expected one of #{VALID_WHATS.inspect}, got #{what.inspect}:#{what.class}" |
41 |
153 |
end |
|
154 |
end |
|
155 |
end |
|
156 |
||
157 |
def id_from_label(label_exp) |
1 |
158 |
# TODO: this won't work correctly if @wd is a sub-element |
|
159 |
label = @wd.find_elements(:tag_name, 'label').find do |el| |
4 |
160 |
matches_selector?(el, :text => label_exp) |
29 |
161 |
end |
|
162 |
||
163 |
label.attribute(:for) if label |
4 |
164 |
end |
|
165 |
||
166 |
def fetch_value(element, how) |
1 |
167 |
case how |
1408 |
168 |
when :text |
|
169 |
element.text |
301 |
170 |
when :tag_name |
|
171 |
element.tag_name |
172 |
172 |
when :href |
|
173 |
(href = element.attribute(:href)) && href.strip |
19 |
174 |
else |
|
175 |
element.attribute(how) |
916 |
176 |
end |
|
177 |
end |
|
178 |
||
179 |
def matches_selector?(element, selector) |
1 |
180 |
selector.all? do |how, what| |
1236 |
181 |
what === fetch_value(element, how) |
1236 |
182 |
end |
|
183 |
end |
|
184 |
||
185 |
def normalized_selector |
1 |
186 |
selector = {} |
2264 |
187 |
||
188 |
@selector.each do |how, what| |
2264 |
189 |
check_type(how, what) |
4648 |
190 |
||
191 |
how, what = normalize_selector(how, what) |
4607 |
192 |
selector[how] = what |
4564 |
193 |
end |
|
194 |
||
195 |
selector |
2180 |
196 |
end |
|
197 |
||
198 |
def normalize_selector(how, what) |
1 |
199 |
case how |
4607 |
200 |
when :tag_name, :text, :xpath, :index, :class, :for |
|
201 |
# include :class since the valid attribute is 'class_name' |
|
202 |
# include :for since the valid attribute is 'html_for' |
|
203 |
[how, what] |
3578 |
204 |
when :class_name |
|
205 |
[:class, what] |
2 |
206 |
when :caption |
|
207 |
[:text, what] |
3 |
208 |
else |
|
209 |
assert_valid_as_attribute how |
1024 |
210 |
[how, what] |
981 |
211 |
end |
|
212 |
end |
|
213 |
||
214 |
def delete_regexps_from(selector) |
1 |
215 |
rx_selector = {} |
305 |
216 |
||
217 |
selector.dup.each do |how, what| |
305 |
218 |
next unless what.kind_of?(Regexp) |
586 |
219 |
rx_selector[how] = what |
307 |
220 |
selector.delete how |
307 |
221 |
end |
|
222 |
||
223 |
rx_selector |
305 |
224 |
end |
|
225 |
||
226 |
def assert_valid_as_attribute(attribute) |
1 |
227 |
unless valid_attribute? attribute or attribute.to_s =~ /^data_.+$/ |
1024 |
228 |
raise MissingWayOfFindingObjectException, "invalid attribute: #{attribute.inspect}" |
43 |
229 |
end |
|
230 |
end |
|
231 |
||
232 |
def by_id |
1 |
233 |
return unless id = @selector[:id] and id.kind_of? String |
2378 |
234 |
||
235 |
selector = @selector.dup |
470 |
236 |
selector.delete(:id) |
470 |
237 |
||
238 |
tag_name = selector.delete(:tag_name) |
470 |
239 |
return unless selector.empty? # multiple attributes |
470 |
240 |
||
241 |
element = @wd.find_element(:id, id) |
414 |
242 |
return if tag_name && !tag_name_matches?(element, tag_name) |
300 |
243 |
||
244 |
element |
282 |
245 |
rescue WebDriver::Error::NoSuchElementError => wde |
|
246 |
nil |
114 |
247 |
end |
|
248 |
||
249 |
def all_elements |
1 |
250 |
@wd.find_elements(:xpath => ".//*") |
7 |
251 |
end |
|
252 |
||
253 |
def tag_name_matches?(element, tag_name) |
1 |
254 |
tag_name === element.tag_name |
1515 |
255 |
end |
|
256 |
||
257 |
def valid_attribute?(attribute) |
1 |
258 |
@valid_attributes && @valid_attributes.include?(attribute) |
1024 |
259 |
end |
|
260 |
||
261 |
def should_use_label_element? |
1 |
262 |
@selector[:tag_name] != "option" |
11 |
263 |
end |
|
264 |
||
265 |
def build_xpath(selectors) |
1 |
266 |
return if selectors.values.any? { |e| e.kind_of? Regexp } |
4653 |
267 |
||
268 |
xpath = ".//" |
1670 |
269 |
xpath << (selectors.delete(:tag_name) || '*').to_s |
1670 |
270 |
||
271 |
idx = selectors.delete(:index) |
1670 |
272 |
||
273 |
# the remaining entries should be attributes |
|
274 |
unless selectors.empty? |
1670 |
275 |
xpath << "[" << attribute_expression(selectors) << "]" |
739 |
276 |
end |
|
277 |
||
278 |
if idx |
1670 |
279 |
xpath << "[#{idx + 1}]" |
0 |
280 |
end |
|
281 |
||
282 |
p :xpath => xpath, :selectors => selectors if $DEBUG |
1670 |
283 |
||
284 |
xpath |
1670 |
285 |
end |
|
286 |
||
287 |
def attribute_expression(selectors) |
1 |
288 |
selectors.map do |key, val| |
1305 |
289 |
if val.kind_of?(Array) |
1158 |
290 |
"(" + val.map { |v| equal_pair(key, v) }.join(" or ") + ")" |
510 |
291 |
else |
|
292 |
equal_pair(key, val) |
1056 |
293 |
end |
|
294 |
end.join(" and ") |
|
295 |
end |
|
296 |
||
297 |
def equal_pair(key, value) |
1 |
298 |
# we assume :label means a corresponding label element, not the attribute |
|
299 |
if key == :label && should_use_label_element? |
1464 |
300 |
"@id=//label[normalize-space()=#{xpath_string(value)}]/@for" |
5 |
301 |
else |
|
302 |
"#{lhs_for(key)}=#{xpath_string(value)}" |
1459 |
303 |
end |
|
304 |
end |
|
305 |
||
306 |
def lhs_for(key) |
1 |
307 |
case key |
1447 |
308 |
when :text, 'text' |
|
309 |
'normalize-space()' |
59 |
310 |
when :href |
|
311 |
# TODO: change this behaviour? |
|
312 |
'normalize-space(@href)' |
5 |
313 |
else |
|
314 |
"@#{key.to_s.gsub("_", "-")}" |
1383 |
315 |
end |
|
316 |
end |
|
317 |
||
318 |
def validate_element(element) |
1 |
319 |
tn = @selector[:tag_name] |
1419 |
320 |
return if tn && !tag_name_matches?(element, tn) |
1419 |
321 |
||
322 |
if element.tag_name == 'input' |
1415 |
323 |
return if @selector[:type] && @selector[:type] != element.attribute(:type) |
330 |
324 |
end |
|
325 |
||
326 |
element |
1415 |
327 |
end |
|
328 |
||
329 |
def given_xpath(selector) |
1 |
330 |
return unless xpath = selector.delete(:xpath) |
2179 |
331 |
||
332 |
unless selector.empty? || can_be_combined_with_xpath?(selector) |
150 |
333 |
raise ArgumentError, ":xpath cannot be combined with other selectors (#{selector.inspect})" |
1 |
334 |
end |
|
335 |
||
336 |
xpath |
149 |
337 |
end |
|
338 |
||
339 |
def can_be_combined_with_xpath?(selector) |
1 |
340 |
# ouch - is this worth it? |
|
341 |
keys = selector.keys |
150 |
342 |
return true if keys == [:tag_name] |
150 |
343 |
||
344 |
if selector[:tag_name] == "input" |
35 |
345 |
return keys == [:tag_name, :type] || keys == [:type, :tag_name] |
34 |
346 |
end |
|
347 |
||
348 |
false |
1 |
349 |
end |
|
350 |
||
351 |
def xpath_string(value) |
1 |
352 |
if value.include? "'" |
1464 |
353 |
parts = value.split("'", -1).map { |part| "'#{part}'" } |
8 |
354 |
string = parts.join(%{,"'",}) |
2 |
355 |
||
356 |
"concat(#{string})" |
2 |
357 |
else |
|
358 |
"'#{value}'" |
1462 |
359 |
end |
|
360 |
end |
|
361 |
||
362 |
end # ElementLocator |
|
363 |
end # Watir |
./lib/watir-webdriver/locators/text_field_locator.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
module Watir |
1 |
2 |
class TextFieldLocator < ElementLocator |
1 |
3 |
||
4 |
NON_TEXT_TYPES = %w[file radio checkbox submit reset image button hidden url datetime date month week time datetime-local range color] |
1 |
5 |
# TODO: better way of finding input text fields? |
|
6 |
NEGATIVE_TYPE_EXPR = NON_TEXT_TYPES.map { |t| "@type!=#{t.inspect}" }.join(" and ") |
18 |
7 |
||
8 |
def locate_all |
1 |
9 |
find_all_by_multiple |
6 |
10 |
end |
|
11 |
||
12 |
private |
1 |
13 |
||
14 |
def build_xpath(selectors) |
1 |
15 |
return if selectors.values.any? { |e| e.kind_of? Regexp } |
288 |
16 |
||
17 |
selectors.delete(:tag_name) |
107 |
18 |
||
19 |
@building = :textarea |
107 |
20 |
textarea_attr_exp = attribute_expression(selectors) |
107 |
21 |
||
22 |
@building = :input |
107 |
23 |
input_attr_exp = attribute_expression(selectors) |
107 |
24 |
||
25 |
xpath = ".//input[(not(@type) or (#{NEGATIVE_TYPE_EXPR}))" |
107 |
26 |
xpath << " and #{input_attr_exp}" unless input_attr_exp.empty? |
107 |
27 |
xpath << "] " |
107 |
28 |
xpath << "| .//textarea" |
107 |
29 |
xpath << "[#{textarea_attr_exp}]" unless textarea_attr_exp.empty? |
107 |
30 |
||
31 |
p :build_xpath => xpath if $DEBUG |
107 |
32 |
||
33 |
xpath |
107 |
34 |
end |
|
35 |
||
36 |
def lhs_for(key) |
1 |
37 |
if @building == :input && key == :text |
92 |
38 |
"@value" |
2 |
39 |
elsif @building == :textarea && key == :value |
90 |
40 |
"text()" |
3 |
41 |
else |
|
42 |
super |
87 |
43 |
end |
|
44 |
end |
|
45 |
||
46 |
def matches_selector?(element, rx_selector) |
1 |
47 |
rx_selector = rx_selector.dup |
92 |
48 |
||
49 |
[:text, :value, :label].each do |key| |
92 |
50 |
if rx_selector.has_key?(key) |
276 |
51 |
correct_key = element.tag_name == 'input' ? :value : :text |
65 |
52 |
rx_selector[correct_key] = rx_selector.delete(key) |
65 |
53 |
end |
|
54 |
end |
|
55 |
||
56 |
super |
92 |
57 |
end |
|
58 |
||
59 |
VALID_TEXT_FIELD_TAGS = %w[input textarea] |
1 |
60 |
||
61 |
def tag_name_matches?(element, _) |
1 |
62 |
VALID_TEXT_FIELD_TAGS.include?(element.tag_name) |
105 |
63 |
end |
|
64 |
end # TextFieldLocator |
|
65 |
end # Watir |
./lib/watir-webdriver/row_container.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
module Watir |
1 |
2 |
module RowContainer |
1 |
3 |
||
4 |
def row(*args) |
1 |
5 |
row = tr(*args) |
38 |
6 |
row.locator_class = ChildRowLocator |
38 |
7 |
||
8 |
row |
38 |
9 |
end |
|
10 |
||
11 |
def rows(*args) |
1 |
12 |
rows = trs(*args) |
49 |
13 |
rows.locator_class = ChildRowLocator |
49 |
14 |
||
15 |
rows |
49 |
16 |
end |
|
17 |
|
|
18 |
# |
|
19 |
# The table as a 2D Array of strings with the text of each cell. |
|
20 |
# |
|
21 |
# @return [Array<Array<String>>] |
|
22 |
# |
|
23 |
||
24 |
def strings |
1 |
25 |
assert_exists |
5 |
26 |
||
27 |
rows.inject [] do |res, row| |
5 |
28 |
res << row.cells.map { |cell| cell.text } |
37 |
29 |
end |
|
30 |
end |
|
31 |
alias_method :to_a, :strings |
1 |
32 |
||
33 |
end |
|
34 |
end |
./lib/watir-webdriver/window_switching.rb96.3 % covered |
||
# | Hits | |
---|---|---|
1 |
module Watir |
1 |
2 |
module WindowSwitching |
1 |
3 |
||
4 |
class NoMatchingWindowFoundException < StandardError |
1 |
5 |
end |
|
6 |
||
7 |
def windows(*args) |
1 |
8 |
all = @driver.window_handles.map { |id| Window.new(@driver, id) } |
121 |
9 |
||
10 |
if args.empty? |
41 |
11 |
all |
38 |
12 |
else |
|
13 |
filter_windows(args, all, :select) |
3 |
14 |
end |
|
15 |
end |
|
16 |
||
17 |
def window(*args, &blk) |
1 |
18 |
win = filter_windows(args, windows, :find) |
30 |
19 |
||
20 |
if win && block_given? |
29 |
21 |
win.use(&blk) |
1 |
22 |
end |
|
23 |
||
24 |
win or raise NoMatchingWindowFoundException, args.inspect |
29 |
25 |
end |
|
26 |
||
27 |
private |
1 |
28 |
||
29 |
def filter_windows(args, all, method) |
1 |
30 |
sel = extract_selector(args) |
33 |
31 |
||
32 |
if sel.empty? |
33 |
33 |
all.find { |w| w.current? } |
8 |
34 |
end |
|
35 |
||
36 |
unless sel.keys.all? { |k| [:title, :url].include? k } |
62 |
37 |
raise ArgumentError, "invalid window selector: #{sel.inspect}" |
2 |
38 |
end |
|
39 |
||
40 |
all.send(method) do |win| |
31 |
41 |
sel.all? { |key, value| value === win.send(key) } |
108 |
42 |
end |
|
43 |
end |
|
44 |
end # WindowSwitching |
|
45 |
||
46 |
class Window |
1 |
47 |
def initialize(driver, id) |
1 |
48 |
@driver, @id = driver, id |
80 |
49 |
end |
|
50 |
||
51 |
def inspect |
1 |
52 |
'#<%s:0x%x id=%s>' % [self.class, hash*2, @id.to_s] |
0 |
53 |
end |
|
54 |
||
55 |
def ==(other) |
1 |
56 |
return false unless other.kind_of?(self.class) |
2 |
57 |
||
58 |
@id == other.id |
2 |
59 |
end |
|
60 |
alias_method :eql?, :== |
1 |
61 |
||
62 |
def hash |
1 |
63 |
@id.hash ^ self.class.hash |
0 |
64 |
end |
|
65 |
||
66 |
def current? |
1 |
67 |
@driver.window_handle == @id |
87 |
68 |
end |
|
69 |
||
70 |
def close |
1 |
71 |
use { @driver.close } |
34 |
72 |
end |
|
73 |
||
74 |
def title |
1 |
75 |
title = nil |
54 |
76 |
use { title = @driver.title } |
108 |
77 |
||
78 |
title |
54 |
79 |
end |
|
80 |
||
81 |
def url |
1 |
82 |
url = nil |
9 |
83 |
use { url = @driver.current_url } |
18 |
84 |
||
85 |
url |
9 |
86 |
end |
|
87 |
||
88 |
def use(&blk) |
1 |
89 |
if current? |
81 |
90 |
yield if block_given? |
33 |
91 |
return self |
33 |
92 |
end |
|
93 |
||
94 |
@driver.switch_to.window(@id, &blk) |
48 |
95 |
self |
48 |
96 |
end |
|
97 |
||
98 |
protected |
1 |
99 |
||
100 |
def id |
1 |
101 |
@id |
2 |
102 |
end |
|
103 |
||
104 |
end # Window |
|
105 |
end # Watir |
./lib/watir-webdriver/xpath_support.rb100.0 % covered |
||
# | Hits | |
---|---|---|
1 |
# encoding: utf-8 |
|
2 |
module Watir |
1 |
3 |
module XpathSupport |
1 |
4 |
include Selenium |
1 |
5 |
||
6 |
# |
|
7 |
# Find the first element matching the given XPath |
|
8 |
# |
|
9 |
||
10 |
def element_by_xpath(xpath) |
1 |
11 |
e = wd.find_element(:xpath, xpath) |
5 |
12 |
Watir.element_class_for(e.tag_name).new(self, :element => e) |
4 |
13 |
rescue WebDriver::Error::NoSuchElementError |
|
14 |
Element.new(self, :xpath => xpath) |
1 |
15 |
end |
|
16 |
||
17 |
# |
|
18 |
# Find all elements matching the given XPath |
|
19 |
# |
|
20 |
||
21 |
def elements_by_xpath(xpath) |
1 |
22 |
wd.find_elements(:xpath, xpath).map do |e| |
4 |
23 |
Watir.element_class_for(e.tag_name).new(self, :element => e) |
6 |
24 |
end |
|
25 |
end |
|
26 |
||
27 |
end # XpathSupport |
|
28 |
end # Watir |