page-object 0.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.rvmrc +1 -1
- data/ChangeLog +12 -6
- data/README.md +1 -1
- data/Rakefile +3 -19
- data/features/async.feature +8 -8
- data/features/button.feature +7 -7
- data/features/check_box.feature +8 -8
- data/features/div.feature +7 -6
- data/features/element_attributes.feature +14 -14
- data/features/form.feature +5 -5
- data/features/frames.feature +12 -0
- data/features/hidden_field.feature +5 -5
- data/features/html/frame_1.html +18 -0
- data/features/html/frame_2.html +16 -0
- data/features/html/frames.html +11 -0
- data/features/html/iframes.html +12 -0
- data/features/html/static_elements.html +50 -42
- data/features/html/success.html +5 -5
- data/features/image.feature +11 -11
- data/features/link.feature +1 -1
- data/features/list_item.feature +5 -5
- data/features/ordered_list.feature +6 -6
- data/features/page_level_actions.feature +16 -5
- data/features/radio_button.feature +12 -12
- data/features/select_list.feature +12 -12
- data/features/span.feature +5 -5
- data/features/step_definitions/accessor_steps.rb +2 -2
- data/features/step_definitions/async_steps.rb +1 -1
- data/features/step_definitions/element_steps.rb +1 -1
- data/features/step_definitions/frames_steps.rb +21 -0
- data/features/step_definitions/page_level_actions_steps.rb +24 -2
- data/features/step_definitions/page_traversal_steps.rb +0 -1
- data/features/support/env.rb +20 -6
- data/features/support/page.rb +14 -11
- data/features/support/url_helper.rb +4 -0
- data/features/table.feature +9 -9
- data/features/table_cell.feature +6 -6
- data/features/text_area.feature +6 -6
- data/features/text_field.feature +7 -7
- data/features/unordered_list.feature +6 -6
- data/lib/page-object.rb +40 -16
- data/lib/page-object/accessors.rb +15 -15
- data/lib/page-object/elements.rb +0 -1
- data/lib/page-object/elements/button.rb +24 -24
- data/lib/page-object/elements/div.rb +8 -3
- data/lib/page-object/elements/element.rb +27 -28
- data/lib/page-object/elements/form.rb +7 -7
- data/lib/page-object/elements/hidden_field.rb +5 -5
- data/lib/page-object/elements/image.rb +8 -8
- data/lib/page-object/elements/link.rb +9 -9
- data/lib/page-object/elements/list_item.rb +1 -1
- data/lib/page-object/elements/option.rb +1 -1
- data/lib/page-object/elements/ordered_list.rb +13 -13
- data/lib/page-object/elements/select_list.rb +6 -6
- data/lib/page-object/elements/span.rb +2 -2
- data/lib/page-object/elements/table.rb +11 -11
- data/lib/page-object/elements/table_row.rb +9 -9
- data/lib/page-object/elements/text_area.rb +4 -4
- data/lib/page-object/elements/text_field.rb +4 -4
- data/lib/page-object/elements/unordered_list.rb +13 -13
- data/lib/page-object/loads_platform.rb +24 -0
- data/lib/page-object/page_factory.rb +3 -3
- data/lib/page-object/platforms.rb +18 -0
- data/lib/page-object/platforms/selenium.rb +16 -0
- data/lib/page-object/platforms/selenium/button.rb +15 -0
- data/lib/page-object/platforms/selenium/element.rb +168 -0
- data/lib/page-object/platforms/selenium/form.rb +16 -0
- data/lib/page-object/platforms/selenium/image.rb +28 -0
- data/lib/page-object/platforms/selenium/link.rb +16 -0
- data/lib/page-object/platforms/selenium/ordered_list.rb +33 -0
- data/lib/page-object/platforms/selenium/page_object.rb +524 -0
- data/lib/page-object/platforms/selenium/select_list.rb +32 -0
- data/lib/page-object/platforms/selenium/table.rb +40 -0
- data/lib/page-object/platforms/selenium/table_row.rb +32 -0
- data/lib/page-object/platforms/selenium/unordered_list.rb +33 -0
- data/lib/page-object/platforms/watir.rb +16 -0
- data/lib/page-object/platforms/watir/element.rb +154 -0
- data/lib/page-object/platforms/watir/form.rb +16 -0
- data/lib/page-object/platforms/watir/image.rb +22 -0
- data/lib/page-object/platforms/watir/ordered_list.rb +32 -0
- data/lib/page-object/{watir_page_object.rb → platforms/watir/page_object.rb} +62 -35
- data/lib/page-object/platforms/watir/select_list.rb +33 -0
- data/lib/page-object/platforms/watir/table.rb +27 -0
- data/lib/page-object/platforms/watir/table_row.rb +24 -0
- data/lib/page-object/platforms/watir/unordered_list.rb +33 -0
- data/lib/page-object/version.rb +1 -1
- data/page-object.gemspec +13 -13
- data/spec/page-object/accessors_spec.rb +142 -108
- data/spec/page-object/elements/button_spec.rb +33 -33
- data/spec/page-object/elements/check_box_spec.rb +1 -1
- data/spec/page-object/elements/div_spec.rb +3 -3
- data/spec/page-object/elements/element_spec.rb +51 -41
- data/spec/page-object/elements/form_spec.rb +3 -3
- data/spec/page-object/elements/hidden_field_spec.rb +3 -3
- data/spec/page-object/elements/image_spec.rb +7 -7
- data/spec/page-object/elements/link_spec.rb +8 -8
- data/spec/page-object/elements/list_item_spec.rb +1 -1
- data/spec/page-object/elements/ordered_list_spec.rb +9 -9
- data/spec/page-object/elements/radio_button_spec.rb +1 -1
- data/spec/page-object/elements/select_list_spec.rb +2 -2
- data/spec/page-object/elements/span_spec.rb +1 -1
- data/spec/page-object/elements/table_row_spec.rb +6 -6
- data/spec/page-object/elements/table_spec.rb +9 -9
- data/spec/page-object/elements/text_area_spec.rb +3 -3
- data/spec/page-object/elements/text_field_spec.rb +3 -3
- data/spec/page-object/elements/unordered_list_spec.rb +10 -10
- data/spec/page-object/loads_platform_spec.rb +38 -0
- data/spec/page-object/page-object_spec.rb +70 -10
- data/spec/page-object/page_factory_spec.rb +3 -3
- data/spec/page-object/{selenium_page_object_spec.rb → platforms/selenium/selenium_page_object_spec.rb} +10 -3
- data/spec/page-object/platforms/selenium_spec.rb +26 -0
- data/spec/page-object/platforms/watir_spec.rb +27 -0
- data/spec/spec_helper.rb +18 -5
- metadata +48 -26
- data/lib/page-object/platforms/selenium_button.rb +0 -13
- data/lib/page-object/platforms/selenium_element.rb +0 -142
- data/lib/page-object/platforms/selenium_form.rb +0 -14
- data/lib/page-object/platforms/selenium_image.rb +0 -26
- data/lib/page-object/platforms/selenium_link.rb +0 -13
- data/lib/page-object/platforms/selenium_ordered_list.rb +0 -31
- data/lib/page-object/platforms/selenium_select_list.rb +0 -29
- data/lib/page-object/platforms/selenium_table.rb +0 -38
- data/lib/page-object/platforms/selenium_table_row.rb +0 -29
- data/lib/page-object/platforms/selenium_unordered_list.rb +0 -31
- data/lib/page-object/platforms/watir_element.rb +0 -136
- data/lib/page-object/platforms/watir_form.rb +0 -14
- data/lib/page-object/platforms/watir_image.rb +0 -20
- data/lib/page-object/platforms/watir_ordered_list.rb +0 -30
- data/lib/page-object/platforms/watir_select_list.rb +0 -30
- data/lib/page-object/platforms/watir_table.rb +0 -24
- data/lib/page-object/platforms/watir_table_row.rb +0 -22
- data/lib/page-object/platforms/watir_unordered_list.rb +0 -31
- data/lib/page-object/selenium_page_object.rb +0 -486
@@ -0,0 +1,32 @@
|
|
1
|
+
module PageObject
|
2
|
+
module Platforms
|
3
|
+
module Selenium
|
4
|
+
module SelectList
|
5
|
+
|
6
|
+
#
|
7
|
+
# Return the PageObject::Elements::Option for the index provided. Index
|
8
|
+
# is zero based.
|
9
|
+
#
|
10
|
+
# @return [PageObject::Elements::Option]
|
11
|
+
#
|
12
|
+
def [](idx)
|
13
|
+
options[idx]
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# Return an array of Options contained in the select lit.
|
18
|
+
#
|
19
|
+
# @return [array of PageObject::Elements::Option]
|
20
|
+
def options
|
21
|
+
options = @element.find_elements(:xpath, child_xpath)
|
22
|
+
elements = []
|
23
|
+
options.each do |opt|
|
24
|
+
elements << Object::PageObject::Elements::Option.new(opt, :platform => :selenium)
|
25
|
+
end
|
26
|
+
elements
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module PageObject
|
2
|
+
module Platforms
|
3
|
+
module Selenium
|
4
|
+
module Table
|
5
|
+
|
6
|
+
#
|
7
|
+
# Return the PageObject::Elements::TableRow for the index provided. Index
|
8
|
+
# is zero based.
|
9
|
+
#
|
10
|
+
# @return [PageObject::Elements::TableRow]
|
11
|
+
#
|
12
|
+
def [](idx)
|
13
|
+
eles = table_rows
|
14
|
+
Object::PageObject::Elements::TableRow.new(eles[idx], :platform => :selenium)
|
15
|
+
end
|
16
|
+
|
17
|
+
#
|
18
|
+
# Returns the number of rows in the table.
|
19
|
+
#
|
20
|
+
def rows
|
21
|
+
table_rows.size
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# override PageObject::Platforms::SeleniumElement because exists? is not
|
26
|
+
# available on a table element in Selenium.
|
27
|
+
#
|
28
|
+
def exists?
|
29
|
+
raise "exists? not available on table element"
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def table_rows
|
35
|
+
@element.find_elements(:xpath, child_xpath)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module PageObject
|
2
|
+
module Platforms
|
3
|
+
module Selenium
|
4
|
+
|
5
|
+
module TableRow
|
6
|
+
|
7
|
+
#
|
8
|
+
# Return the PageObject::Elements::TableCell for the index provided. Index
|
9
|
+
# is zero based.
|
10
|
+
#
|
11
|
+
def [](idx)
|
12
|
+
els = table_cells
|
13
|
+
Object::PageObject::Elements::TableCell.new(els[idx], :platform => :selenium)
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# Returns the number of columns in the table.
|
18
|
+
#
|
19
|
+
def columns
|
20
|
+
table_cells.size
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def table_cells
|
26
|
+
element.find_elements(:xpath, child_xpath)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module PageObject
|
2
|
+
module Platforms
|
3
|
+
module Selenium
|
4
|
+
module UnorderedList
|
5
|
+
|
6
|
+
#
|
7
|
+
# Return the PageObject::Elements::ListItem for the index provided. Index
|
8
|
+
# is zero based.
|
9
|
+
#
|
10
|
+
# @return [PageObject::Elements::ListItem]
|
11
|
+
#
|
12
|
+
def [](idx)
|
13
|
+
eles = list_items
|
14
|
+
Object::PageObject::Elements::ListItem.new(eles[idx], :platform => :selenium)
|
15
|
+
end
|
16
|
+
|
17
|
+
#
|
18
|
+
# Return the number of items contained in the unordered list
|
19
|
+
#
|
20
|
+
def items
|
21
|
+
list_items.size
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def list_items
|
27
|
+
element.find_elements(:xpath, child_xpath)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module PageObject
|
2
|
+
module Platforms
|
3
|
+
module Watir
|
4
|
+
def self.create_page_object(browser)
|
5
|
+
require 'page-object/platforms/watir/page_object'
|
6
|
+
PageObject::WatirPageObject.new(browser)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.is_for?(browser)
|
10
|
+
browser.is_a?(Object::Watir::Browser)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
PageObject::Platforms.register(:watir, PageObject::Platforms::Watir)
|
@@ -0,0 +1,154 @@
|
|
1
|
+
module PageObject
|
2
|
+
module Platforms
|
3
|
+
#
|
4
|
+
# Watir implementation of the common functionality found across all elements
|
5
|
+
#
|
6
|
+
module Watir
|
7
|
+
module Element
|
8
|
+
|
9
|
+
#
|
10
|
+
# return true if an element is visible
|
11
|
+
#
|
12
|
+
def visible?
|
13
|
+
@element.present?
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# return true if an element exists
|
18
|
+
#
|
19
|
+
def exists?
|
20
|
+
@element.exists?
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# Get the text for the element
|
25
|
+
#
|
26
|
+
# @return [String]
|
27
|
+
#
|
28
|
+
def text
|
29
|
+
@element.text
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# Get the value of this element
|
34
|
+
#
|
35
|
+
# @return [String]
|
36
|
+
#
|
37
|
+
def value
|
38
|
+
@element.value
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# compare this element to another to determine if they are equal
|
43
|
+
#
|
44
|
+
def ==(other)
|
45
|
+
@element == other.element
|
46
|
+
end
|
47
|
+
|
48
|
+
#
|
49
|
+
# Get the tag name of this element
|
50
|
+
#
|
51
|
+
# @return [String]
|
52
|
+
#
|
53
|
+
def tag_name
|
54
|
+
@element.tag_name
|
55
|
+
end
|
56
|
+
|
57
|
+
#
|
58
|
+
# Get the value of a the given attribute of the element. Will return the current value, even if
|
59
|
+
# this has been modified after the page has been loaded. More exactly, this method will return
|
60
|
+
# the value of the given attribute, unless that attribute is not present, in which case the
|
61
|
+
# value of the property with the same name is returned. If neither value is set, nil is
|
62
|
+
# returned. The "style" attribute is converted as best can be to a text representation with a
|
63
|
+
# trailing semi-colon. The following are deemed to be "boolean" attributes, and will
|
64
|
+
# return either "true" or "false":
|
65
|
+
#
|
66
|
+
# async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked,
|
67
|
+
# defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate,
|
68
|
+
# iscontenteditable, ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, novalidate,
|
69
|
+
# nowrap, open, paused, pubdate, readonly, required, reversed, scoped, seamless, seeking,
|
70
|
+
# selected, spellcheck, truespeed, willvalidate
|
71
|
+
#
|
72
|
+
# Finally, the following commonly mis-capitalized attribute/property names are evaluated as
|
73
|
+
# expected:
|
74
|
+
#
|
75
|
+
# class, readonly
|
76
|
+
#
|
77
|
+
# @param [String]
|
78
|
+
# attribute name
|
79
|
+
# @return [String,nil]
|
80
|
+
# attribute value
|
81
|
+
#
|
82
|
+
def attribute(attribute_name)
|
83
|
+
@element.attribute_value attribute_name
|
84
|
+
end
|
85
|
+
|
86
|
+
#
|
87
|
+
# Click this element
|
88
|
+
#
|
89
|
+
def click
|
90
|
+
@element.click
|
91
|
+
end
|
92
|
+
|
93
|
+
#
|
94
|
+
# Waits until the element is present
|
95
|
+
#
|
96
|
+
# @param [Integer] (defaults to: 5) seconds to wait before timing out
|
97
|
+
#
|
98
|
+
def when_present(timeout=5)
|
99
|
+
@element.wait_until_present(timeout)
|
100
|
+
end
|
101
|
+
|
102
|
+
#
|
103
|
+
# Waits until the element is visible
|
104
|
+
#
|
105
|
+
# @param [Integer] (defaults to: 5) seconds to wait before timing out
|
106
|
+
#
|
107
|
+
def when_visible(timeout=5)
|
108
|
+
Object::Watir::Wait.until(timeout, "Element was not visible in #{timeout} seconds") do
|
109
|
+
visible?
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
#
|
114
|
+
# Waits until the element is not visible
|
115
|
+
#
|
116
|
+
# @param [Integer] (defaults to: 5) seconds to wait before timing out
|
117
|
+
#
|
118
|
+
def when_not_visible(timeout=5)
|
119
|
+
Object::Watir::Wait.while(timeout, "Element still visible after #{timeout} seconds") do
|
120
|
+
visible?
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
#
|
125
|
+
# Waits until the block returns true
|
126
|
+
#
|
127
|
+
# @param [Integer] (defaults to: 5) seconds to wait before timing out
|
128
|
+
# @param [String] the message to display if the event timeouts
|
129
|
+
# @param the block to execute when the event occurrs
|
130
|
+
#
|
131
|
+
def wait_until(timeout=5, message=nil, &block)
|
132
|
+
Object::Watir::Wait.until(timeout, message, &block)
|
133
|
+
end
|
134
|
+
|
135
|
+
#
|
136
|
+
# Send keystrokes to this element
|
137
|
+
#
|
138
|
+
# @param [String, Symbol, Array]
|
139
|
+
#
|
140
|
+
# Examples:
|
141
|
+
#
|
142
|
+
# element.send_keys "foo" #=> value: 'foo'
|
143
|
+
# element.send_keys "tet", :arrow_left, "s" #=> value: 'test'
|
144
|
+
# element.send_keys [:control, 'a'], :space #=> value: ' '
|
145
|
+
#
|
146
|
+
# @see Selenium::WebDriver::Keys::KEYS
|
147
|
+
#
|
148
|
+
def send_keys(*args)
|
149
|
+
@element.send_keys(*args)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module PageObject
|
2
|
+
module Platforms
|
3
|
+
module Watir
|
4
|
+
module Image
|
5
|
+
|
6
|
+
#
|
7
|
+
# Return the width of the image.
|
8
|
+
#
|
9
|
+
def width
|
10
|
+
@element.width
|
11
|
+
end
|
12
|
+
|
13
|
+
#
|
14
|
+
# Return the height of the image
|
15
|
+
#
|
16
|
+
def height
|
17
|
+
@element.height
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module PageObject
|
2
|
+
module Platforms
|
3
|
+
module Watir
|
4
|
+
module OrderedList
|
5
|
+
|
6
|
+
#
|
7
|
+
# Return the PageObject::Elements::ListItem for the index provided. Index
|
8
|
+
# is zero based.
|
9
|
+
#
|
10
|
+
# @return [PageObject::Elements::ListItem]
|
11
|
+
#
|
12
|
+
def [](idx)
|
13
|
+
eles = list_items
|
14
|
+
PageObject::Elements::ListItem.new(eles[idx], :platform => :watir)
|
15
|
+
end
|
16
|
+
|
17
|
+
#
|
18
|
+
# Return the number of items contained in the ordered list
|
19
|
+
#
|
20
|
+
def items
|
21
|
+
list_items.size
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def list_items
|
27
|
+
element.wd.find_elements(:xpath, child_xpath)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -9,8 +9,10 @@ module PageObject
|
|
9
9
|
# and use the methods dynamically added from the PageObject::Accessors module.
|
10
10
|
#
|
11
11
|
class WatirPageObject
|
12
|
+
attr_reader :browser
|
13
|
+
|
12
14
|
def initialize(browser)
|
13
|
-
@browser = browser
|
15
|
+
@browser = browser
|
14
16
|
end
|
15
17
|
|
16
18
|
#
|
@@ -44,14 +46,14 @@ module PageObject
|
|
44
46
|
def title
|
45
47
|
@browser.title
|
46
48
|
end
|
47
|
-
|
49
|
+
|
48
50
|
#
|
49
51
|
# platform method to wait for a block to return true
|
50
52
|
# See PageObject#wait_until
|
51
53
|
def wait_until(timeout, message = nil, &block)
|
52
54
|
@browser.wait_until(timeout, message, &block)
|
53
55
|
end
|
54
|
-
|
56
|
+
|
55
57
|
#
|
56
58
|
# platform method to handle an alert popup
|
57
59
|
# See PageObject#alert
|
@@ -59,7 +61,7 @@ module PageObject
|
|
59
61
|
def alert(&block)
|
60
62
|
@browser.alert(&block)
|
61
63
|
end
|
62
|
-
|
64
|
+
|
63
65
|
#
|
64
66
|
# platform method to handle a confirm popup
|
65
67
|
# See PageObject#confirm
|
@@ -67,7 +69,7 @@ module PageObject
|
|
67
69
|
def confirm(response, &block)
|
68
70
|
@browser.confirm(response, &block)
|
69
71
|
end
|
70
|
-
|
72
|
+
|
71
73
|
#
|
72
74
|
# platform method to handle a prompt popup
|
73
75
|
# See PageObject#prompt
|
@@ -75,6 +77,31 @@ module PageObject
|
|
75
77
|
def prompt(answer, &block)
|
76
78
|
@browser.prompt(answer, &block)
|
77
79
|
end
|
80
|
+
|
81
|
+
#
|
82
|
+
# platform method to handle attaching to a running window
|
83
|
+
# See PageObject#attach_to_window
|
84
|
+
#
|
85
|
+
def attach_to_window(identifier)
|
86
|
+
win_id = {identifier.keys.first => /#{Regexp.escape(identifier.values.first)}/}
|
87
|
+
@browser.window(win_id).use
|
88
|
+
end
|
89
|
+
|
90
|
+
#
|
91
|
+
# platform method to handle switching to a frame
|
92
|
+
# See PageObject#switch_to_frame
|
93
|
+
#
|
94
|
+
def switch_to_frame(identifier)
|
95
|
+
@browser.wd.switch_to.frame(identifier)
|
96
|
+
end
|
97
|
+
|
98
|
+
#
|
99
|
+
# platform method to refresh the page
|
100
|
+
# See PageObject#refresh
|
101
|
+
#
|
102
|
+
def refresh
|
103
|
+
@browser.refresh
|
104
|
+
end
|
78
105
|
|
79
106
|
#
|
80
107
|
# platform method to get the value stored in a text field
|
@@ -84,7 +111,7 @@ module PageObject
|
|
84
111
|
identifier = Elements::TextField.watir_identifier_for identifier
|
85
112
|
@browser.text_field(identifier).value
|
86
113
|
end
|
87
|
-
|
114
|
+
|
88
115
|
#
|
89
116
|
# platform method to set the value for a text field
|
90
117
|
# See PageObject::Accessors#text_field
|
@@ -93,7 +120,7 @@ module PageObject
|
|
93
120
|
identifier = Elements::TextField.watir_identifier_for identifier
|
94
121
|
@browser.text_field(identifier).set(value)
|
95
122
|
end
|
96
|
-
|
123
|
+
|
97
124
|
#
|
98
125
|
# platform method to retrieve a text field element
|
99
126
|
# See PageObject::Accessors#text_field
|
@@ -103,7 +130,7 @@ module PageObject
|
|
103
130
|
element = @browser.text_field(identifier)
|
104
131
|
Elements::TextField.new(element, :platform => :watir)
|
105
132
|
end
|
106
|
-
|
133
|
+
|
107
134
|
#
|
108
135
|
# platform method to get the value stored in a hidden field
|
109
136
|
# See PageObject::Accessors#hidden_field
|
@@ -112,7 +139,7 @@ module PageObject
|
|
112
139
|
identifier = Elements::HiddenField.watir_identifier_for identifier
|
113
140
|
@browser.hidden(identifier).value
|
114
141
|
end
|
115
|
-
|
142
|
+
|
116
143
|
#
|
117
144
|
# platform method to retrieve a hidden field element
|
118
145
|
# See PageObject::Accessors#hidden_field
|
@@ -121,8 +148,8 @@ module PageObject
|
|
121
148
|
identifier = Elements::HiddenField.watir_identifier_for identifier
|
122
149
|
element = @browser.hidden(identifier)
|
123
150
|
Elements::HiddenField.new(element, :platform => :watir)
|
124
|
-
end
|
125
|
-
|
151
|
+
end
|
152
|
+
|
126
153
|
#
|
127
154
|
# platform method to set text in a textarea
|
128
155
|
# See PageObject::Accessors#text_area
|
@@ -131,7 +158,7 @@ module PageObject
|
|
131
158
|
identifier = Elements::TextArea.watir_identifier_for identifier
|
132
159
|
@browser.textarea(identifier).send_keys(value)
|
133
160
|
end
|
134
|
-
|
161
|
+
|
135
162
|
#
|
136
163
|
# platform method to get the text from a textarea
|
137
164
|
# See PageObject::Accessors#text_area
|
@@ -140,7 +167,7 @@ module PageObject
|
|
140
167
|
identifier = Elements::TextArea.watir_identifier_for identifier
|
141
168
|
@browser.textarea(identifier).value
|
142
169
|
end
|
143
|
-
|
170
|
+
|
144
171
|
#
|
145
172
|
# platform method to get the text area element
|
146
173
|
# See PageObject::Accessors#text_area
|
@@ -150,7 +177,7 @@ module PageObject
|
|
150
177
|
element = @browser.textarea(identifier)
|
151
178
|
Elements::TextArea.new(element, :platform => :watir)
|
152
179
|
end
|
153
|
-
|
180
|
+
|
154
181
|
#
|
155
182
|
# platform method to get the currently selected value from a select list
|
156
183
|
# See PageObject::Accessors#select_list
|
@@ -159,7 +186,7 @@ module PageObject
|
|
159
186
|
identifier = Elements::SelectList.watir_identifier_for identifier
|
160
187
|
@browser.select_list(identifier).value
|
161
188
|
end
|
162
|
-
|
189
|
+
|
163
190
|
#
|
164
191
|
# platform method to select a value from a select list
|
165
192
|
# See PageObject::Accessors#select_list
|
@@ -168,7 +195,7 @@ module PageObject
|
|
168
195
|
identifier = Elements::SelectList.watir_identifier_for identifier
|
169
196
|
@browser.select_list(identifier).select(value)
|
170
197
|
end
|
171
|
-
|
198
|
+
|
172
199
|
#
|
173
200
|
# platform method to return the select list element
|
174
201
|
# See PageObject::Accessors#select_list
|
@@ -178,7 +205,7 @@ module PageObject
|
|
178
205
|
element = @browser.select_list(identifier)
|
179
206
|
Elements::SelectList.new(element, :platform => :watir)
|
180
207
|
end
|
181
|
-
|
208
|
+
|
182
209
|
#
|
183
210
|
# platform method to click a link
|
184
211
|
# See PageObject::Accessors#link
|
@@ -187,7 +214,7 @@ module PageObject
|
|
187
214
|
identifier = Elements::Link.watir_identifier_for identifier
|
188
215
|
@browser.link(identifier).click if identifier
|
189
216
|
end
|
190
|
-
|
217
|
+
|
191
218
|
#
|
192
219
|
# platform method to return a PageObject::Elements::Link object
|
193
220
|
# see PageObject::Accessors#link
|
@@ -224,7 +251,7 @@ module PageObject
|
|
224
251
|
identifier = Elements::CheckBox.watir_identifier_for identifier
|
225
252
|
@browser.checkbox(identifier).set?
|
226
253
|
end
|
227
|
-
|
254
|
+
|
228
255
|
#
|
229
256
|
# platform method to return a PageObject::Elements::CheckBox element
|
230
257
|
# See PageObject::Accessors#checkbox
|
@@ -261,7 +288,7 @@ module PageObject
|
|
261
288
|
identifier = Elements::RadioButton.watir_identifier_for identifier
|
262
289
|
@browser.radio(identifier).set?
|
263
290
|
end
|
264
|
-
|
291
|
+
|
265
292
|
#
|
266
293
|
# platform method to return a PageObject::Eements::RadioButton element
|
267
294
|
# See PageObject::Accessors#radio_button
|
@@ -271,7 +298,7 @@ module PageObject
|
|
271
298
|
element = @browser.radio(identifier)
|
272
299
|
PageObject::Elements::RadioButton.new(element, :platform => :watir)
|
273
300
|
end
|
274
|
-
|
301
|
+
|
275
302
|
#
|
276
303
|
# platform method to return the text for a div
|
277
304
|
# See PageObject::Accessors#div
|
@@ -281,7 +308,7 @@ module PageObject
|
|
281
308
|
identifier = Elements::Div.watir_identifier_for identifier
|
282
309
|
@browser.div(identifier).text
|
283
310
|
end
|
284
|
-
|
311
|
+
|
285
312
|
#
|
286
313
|
# platform method to return a PageObject::Elements::Div element
|
287
314
|
# See PageObject::Accessors#div
|
@@ -292,7 +319,7 @@ module PageObject
|
|
292
319
|
element = @browser.div(identifier)
|
293
320
|
PageObject::Elements::Div.new(element, :platform => :watir)
|
294
321
|
end
|
295
|
-
|
322
|
+
|
296
323
|
#
|
297
324
|
# platform method to return the text for a span
|
298
325
|
# See PageObject::Accessors#span
|
@@ -302,7 +329,7 @@ module PageObject
|
|
302
329
|
identifier = Elements::Span.watir_identifier_for identifier
|
303
330
|
@browser.span(identifier).text
|
304
331
|
end
|
305
|
-
|
332
|
+
|
306
333
|
#
|
307
334
|
# platform method to return a PageObject::Elements::Span element
|
308
335
|
# See PageObject::Accessors#span
|
@@ -313,7 +340,7 @@ module PageObject
|
|
313
340
|
element = @browser.span(identifier)
|
314
341
|
PageObject::Elements::Span.new(element, :platform => :watir)
|
315
342
|
end
|
316
|
-
|
343
|
+
|
317
344
|
#
|
318
345
|
# platform method to click a button
|
319
346
|
# See PageObject::Accessors#button
|
@@ -322,7 +349,7 @@ module PageObject
|
|
322
349
|
identifier = Elements::Button.watir_identifier_for identifier
|
323
350
|
@browser.button(identifier).click
|
324
351
|
end
|
325
|
-
|
352
|
+
|
326
353
|
#
|
327
354
|
# platform method to retrieve a button element
|
328
355
|
# See PageObject::Accessors#button
|
@@ -332,7 +359,7 @@ module PageObject
|
|
332
359
|
element = @browser.button(identifier)
|
333
360
|
PageObject::Elements::Button.new(element, :platform => :watir)
|
334
361
|
end
|
335
|
-
|
362
|
+
|
336
363
|
#
|
337
364
|
# platform method to retrieve a table element
|
338
365
|
# See PageObject::Accessors#table
|
@@ -343,7 +370,7 @@ module PageObject
|
|
343
370
|
element = @browser.table(identifier)
|
344
371
|
PageObject::Elements::Table.new(element, :platform => :watir)
|
345
372
|
end
|
346
|
-
|
373
|
+
|
347
374
|
#
|
348
375
|
# platform method to retrieve the text from a table cell
|
349
376
|
# See PageObject::Accessors#cell
|
@@ -353,7 +380,7 @@ module PageObject
|
|
353
380
|
identifier = Elements::TableCell.watir_identifier_for identifier
|
354
381
|
@browser.td(identifier).text
|
355
382
|
end
|
356
|
-
|
383
|
+
|
357
384
|
#
|
358
385
|
# platform method to retrieve a table cell element
|
359
386
|
# See PageObject::Accessors#cell
|
@@ -364,7 +391,7 @@ module PageObject
|
|
364
391
|
element = @browser.td(identifier)
|
365
392
|
PageObject::Elements::TableCell.new(element, :platform => :watir)
|
366
393
|
end
|
367
|
-
|
394
|
+
|
368
395
|
#
|
369
396
|
# platform method to retrieve an image element
|
370
397
|
# See PageObject::Accessors#image
|
@@ -374,7 +401,7 @@ module PageObject
|
|
374
401
|
element = @browser.image(identifier)
|
375
402
|
PageObject::Elements::Image.new(element, :platform => :watir)
|
376
403
|
end
|
377
|
-
|
404
|
+
|
378
405
|
#
|
379
406
|
# platform method to retrieve a form element
|
380
407
|
# See PageObject::Accessors#form
|
@@ -384,7 +411,7 @@ module PageObject
|
|
384
411
|
element = @browser.form(identifier)
|
385
412
|
PageObject::Elements::Form.new(element, :platform => :watir)
|
386
413
|
end
|
387
|
-
|
414
|
+
|
388
415
|
#
|
389
416
|
# platform method to retrieve the text from a list item
|
390
417
|
# See PageObject::Accessors#list_item
|
@@ -394,7 +421,7 @@ module PageObject
|
|
394
421
|
identifier = Elements::ListItem.watir_identifier_for identifier
|
395
422
|
@browser.li(identifier).text
|
396
423
|
end
|
397
|
-
|
424
|
+
|
398
425
|
#
|
399
426
|
# platform method to retrieve a list item element
|
400
427
|
# See PageObject::Accessors#list_item
|
@@ -416,7 +443,7 @@ module PageObject
|
|
416
443
|
element = @browser.ul(identifier)
|
417
444
|
PageObject::Elements::UnorderedList.new(element, :platform => :watir)
|
418
445
|
end
|
419
|
-
|
446
|
+
|
420
447
|
#
|
421
448
|
# platform method to retrieve an ordered list element
|
422
449
|
# See PageObject::Accessors#ordered_list
|
@@ -429,7 +456,7 @@ module PageObject
|
|
429
456
|
end
|
430
457
|
|
431
458
|
private
|
432
|
-
|
459
|
+
|
433
460
|
def add_tagname_if_needed identifier, tag
|
434
461
|
return identifier if identifier.length < 2 and not identifier[:name]
|
435
462
|
identifier[:tag_name] = tag if identifier[:name]
|