page-object 2.2.2 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.coveralls.yml +1 -1
- data/.gitignore +8 -8
- data/.rspec +2 -2
- data/.ruby-gemset +1 -1
- data/.ruby-version +1 -1
- data/.travis.yml +17 -17
- data/ChangeLog +923 -888
- data/Gemfile +13 -13
- data/Guardfile +20 -20
- data/LICENSE +20 -20
- data/README.md +114 -114
- data/Rakefile +29 -29
- data/cucumber.yml +8 -8
- data/lib/page-object.rb +431 -420
- data/lib/page-object/accessors.rb +1201 -1175
- data/lib/page-object/element_locators.rb +21 -21
- data/lib/page-object/elements.rb +62 -61
- data/lib/page-object/elements/area.rb +9 -9
- data/lib/page-object/elements/audio.rb +9 -9
- data/lib/page-object/elements/bold.rb +9 -9
- data/lib/page-object/elements/button.rb +12 -12
- data/lib/page-object/elements/canvas.rb +10 -10
- data/lib/page-object/elements/check_box.rb +9 -9
- data/lib/page-object/elements/date_field.rb +10 -0
- data/lib/page-object/elements/div.rb +9 -9
- data/lib/page-object/elements/element.rb +212 -159
- data/lib/page-object/elements/file_field.rb +9 -9
- data/lib/page-object/elements/form.rb +9 -9
- data/lib/page-object/elements/heading.rb +14 -14
- data/lib/page-object/elements/hidden_field.rb +9 -9
- data/lib/page-object/elements/image.rb +10 -10
- data/lib/page-object/elements/italic.rb +9 -9
- data/lib/page-object/elements/label.rb +9 -9
- data/lib/page-object/elements/link.rb +9 -9
- data/lib/page-object/elements/list_item.rb +9 -9
- data/lib/page-object/elements/media.rb +11 -11
- data/lib/page-object/elements/option.rb +9 -9
- data/lib/page-object/elements/ordered_list.rb +43 -45
- data/lib/page-object/elements/paragraph.rb +9 -9
- data/lib/page-object/elements/radio_button.rb +9 -9
- data/lib/page-object/elements/select_list.rb +42 -42
- data/lib/page-object/elements/span.rb +9 -9
- data/lib/page-object/elements/table.rb +85 -68
- data/lib/page-object/elements/table_cell.rb +10 -10
- data/lib/page-object/elements/table_row.rb +52 -52
- data/lib/page-object/elements/text_area.rb +9 -9
- data/lib/page-object/elements/text_field.rb +10 -10
- data/lib/page-object/elements/unordered_list.rb +42 -44
- data/lib/page-object/elements/video.rb +9 -9
- data/lib/page-object/indexed_properties.rb +41 -41
- data/lib/page-object/javascript/angularjs.rb +14 -14
- data/lib/page-object/javascript/jquery.rb +14 -14
- data/lib/page-object/javascript/prototype.rb +14 -14
- data/lib/page-object/javascript/yui.rb +18 -18
- data/lib/page-object/javascript_framework_facade.rb +80 -80
- data/lib/page-object/locator_generator.rb +183 -182
- data/lib/page-object/nested_elements.rb +17 -17
- data/lib/page-object/page_factory.rb +108 -108
- data/lib/page-object/page_populator.rb +105 -95
- data/lib/page-object/platforms/watir.rb +50 -50
- data/lib/page-object/platforms/watir/page_object.rb +1155 -1124
- data/lib/page-object/section_collection.rb +16 -16
- data/lib/page-object/version.rb +4 -4
- data/lib/page-object/widgets.rb +98 -98
- data/page-object.gemspec +32 -32
- metadata +12 -12
@@ -1,9 +1,9 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Elements
|
3
|
-
class Span < Element
|
4
|
-
|
5
|
-
end
|
6
|
-
|
7
|
-
::PageObject::Elements.tag_to_class[:span] = ::PageObject::Elements::Span
|
8
|
-
end
|
9
|
-
end
|
1
|
+
module PageObject
|
2
|
+
module Elements
|
3
|
+
class Span < Element
|
4
|
+
|
5
|
+
end
|
6
|
+
|
7
|
+
::PageObject::Elements.tag_to_class[:span] = ::PageObject::Elements::Span
|
8
|
+
end
|
9
|
+
end
|
@@ -1,68 +1,85 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Elements
|
3
|
-
class Table < Element
|
4
|
-
include Enumerable
|
5
|
-
|
6
|
-
#
|
7
|
-
# iterator that yields with a PageObject::Elements::TableRow
|
8
|
-
#
|
9
|
-
# @return [PageObject::Elements::TableRow]
|
10
|
-
#
|
11
|
-
def each(&block)
|
12
|
-
row_items.each(&block)
|
13
|
-
end
|
14
|
-
|
15
|
-
alias_method :first_row, :first
|
16
|
-
|
17
|
-
#
|
18
|
-
# return the last row
|
19
|
-
#
|
20
|
-
# @return PageObject::Elements::TableRow
|
21
|
-
#
|
22
|
-
def last_row
|
23
|
-
self[-1]
|
24
|
-
end
|
25
|
-
|
26
|
-
#
|
27
|
-
# Return the PageObject::Elements::TableRow for the index provided. Index
|
28
|
-
# is zero based. If the index provided is a String then it
|
29
|
-
# will be matched with the text from any column. The text can be a substring of the full column text.
|
30
|
-
#
|
31
|
-
# @return [PageObject::Elements::TableRow]
|
32
|
-
#
|
33
|
-
def [](what)
|
34
|
-
idx = find_index(what)
|
35
|
-
idx && row_items[idx]
|
36
|
-
end
|
37
|
-
|
38
|
-
#
|
39
|
-
# Returns the number of rows in the table.
|
40
|
-
#
|
41
|
-
def rows
|
42
|
-
row_items.size
|
43
|
-
end
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
1
|
+
module PageObject
|
2
|
+
module Elements
|
3
|
+
class Table < Element
|
4
|
+
include Enumerable
|
5
|
+
|
6
|
+
#
|
7
|
+
# iterator that yields with a PageObject::Elements::TableRow
|
8
|
+
#
|
9
|
+
# @return [PageObject::Elements::TableRow]
|
10
|
+
#
|
11
|
+
def each(&block)
|
12
|
+
row_items.each(&block)
|
13
|
+
end
|
14
|
+
|
15
|
+
alias_method :first_row, :first
|
16
|
+
|
17
|
+
#
|
18
|
+
# return the last row
|
19
|
+
#
|
20
|
+
# @return PageObject::Elements::TableRow
|
21
|
+
#
|
22
|
+
def last_row
|
23
|
+
self[-1]
|
24
|
+
end
|
25
|
+
|
26
|
+
#
|
27
|
+
# Return the PageObject::Elements::TableRow for the index provided. Index
|
28
|
+
# is zero based. If the index provided is a String then it
|
29
|
+
# will be matched with the text from any column. The text can be a substring of the full column text.
|
30
|
+
#
|
31
|
+
# @return [PageObject::Elements::TableRow]
|
32
|
+
#
|
33
|
+
def [](what)
|
34
|
+
idx = find_index(what)
|
35
|
+
idx && row_items[idx]
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
# Returns the number of rows in the table.
|
40
|
+
#
|
41
|
+
def rows
|
42
|
+
row_items.size
|
43
|
+
end
|
44
|
+
|
45
|
+
#
|
46
|
+
# Returns the Array of values(String) in a column for the index provided. Index
|
47
|
+
# is zero based. If the index provided is a String then it
|
48
|
+
# will be matched with the text from the header. The text can be a substring of the full header text.
|
49
|
+
#
|
50
|
+
def column_values(what)
|
51
|
+
idx = find_index_of_header(what)
|
52
|
+
idx && row_items.drop(1).collect { |row| row.cell(index: idx).text }
|
53
|
+
end
|
54
|
+
|
55
|
+
protected
|
56
|
+
|
57
|
+
def row_items
|
58
|
+
meth = strategy == :descendants ? :trs : :rows
|
59
|
+
@row_items ||= element.send(meth).map do |obj|
|
60
|
+
::PageObject::Elements::TableRow.new(obj)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def strategy
|
65
|
+
:children
|
66
|
+
end
|
67
|
+
|
68
|
+
def find_index_of_header(what)
|
69
|
+
return what if what.is_a? Integer
|
70
|
+
row_items[0].cells.find_index do |cell|
|
71
|
+
cell.text.include? Regexp.escape(what)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def find_index(what)
|
76
|
+
return what if what.is_a? Integer
|
77
|
+
row_items.find_index do |row|
|
78
|
+
row.cell(text: /#{Regexp.escape(what)}/).exist?
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
::PageObject::Elements.tag_to_class[:table] = ::PageObject::Elements::Table
|
84
|
+
end
|
85
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Elements
|
3
|
-
class TableCell < Element
|
4
|
-
|
5
|
-
end
|
6
|
-
|
7
|
-
::PageObject::Elements.tag_to_class[:td] = ::PageObject::Elements::TableCell
|
8
|
-
::PageObject::Elements.tag_to_class[:th] = ::PageObject::Elements::TableCell
|
9
|
-
end
|
10
|
-
end
|
1
|
+
module PageObject
|
2
|
+
module Elements
|
3
|
+
class TableCell < Element
|
4
|
+
|
5
|
+
end
|
6
|
+
|
7
|
+
::PageObject::Elements.tag_to_class[:td] = ::PageObject::Elements::TableCell
|
8
|
+
::PageObject::Elements.tag_to_class[:th] = ::PageObject::Elements::TableCell
|
9
|
+
end
|
10
|
+
end
|
@@ -1,52 +1,52 @@
|
|
1
|
-
require 'watir/elements/html_elements'
|
2
|
-
|
3
|
-
module PageObject
|
4
|
-
module Elements
|
5
|
-
class TableRow < Element
|
6
|
-
include Enumerable
|
7
|
-
|
8
|
-
#
|
9
|
-
# iterator that yields with a PageObject::Elements::TableCell
|
10
|
-
#
|
11
|
-
def each(&block)
|
12
|
-
cell_items.each(&block)
|
13
|
-
end
|
14
|
-
|
15
|
-
#
|
16
|
-
# Return the PageObject::Elements::TableCell for the index provided. Index
|
17
|
-
# is zero based. If the index provided is a String then it
|
18
|
-
# will be matched with the text from the columns in the first row.
|
19
|
-
# The text can be a substring of the full column text.
|
20
|
-
#
|
21
|
-
def [](what)
|
22
|
-
idx = find_index(what)
|
23
|
-
idx && cell_items[idx]
|
24
|
-
end
|
25
|
-
|
26
|
-
#
|
27
|
-
# Returns the number of columns in the table.
|
28
|
-
#
|
29
|
-
def columns
|
30
|
-
cell_items.size
|
31
|
-
end
|
32
|
-
|
33
|
-
protected
|
34
|
-
|
35
|
-
def cell_items
|
36
|
-
@cell_items ||= element.cells.map do |obj|
|
37
|
-
::PageObject::Elements::TableCell.new(obj)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def find_index(what)
|
42
|
-
return what if what.is_a? Integer
|
43
|
-
|
44
|
-
parent(tag_name: 'table').headers.find_index do |header|
|
45
|
-
header.text.include? what
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
::PageObject::Elements.tag_to_class[:tr] = ::PageObject::Elements::TableRow
|
51
|
-
end
|
52
|
-
end
|
1
|
+
require 'watir/elements/html_elements'
|
2
|
+
|
3
|
+
module PageObject
|
4
|
+
module Elements
|
5
|
+
class TableRow < Element
|
6
|
+
include Enumerable
|
7
|
+
|
8
|
+
#
|
9
|
+
# iterator that yields with a PageObject::Elements::TableCell
|
10
|
+
#
|
11
|
+
def each(&block)
|
12
|
+
cell_items.each(&block)
|
13
|
+
end
|
14
|
+
|
15
|
+
#
|
16
|
+
# Return the PageObject::Elements::TableCell for the index provided. Index
|
17
|
+
# is zero based. If the index provided is a String then it
|
18
|
+
# will be matched with the text from the columns in the first row.
|
19
|
+
# The text can be a substring of the full column text.
|
20
|
+
#
|
21
|
+
def [](what)
|
22
|
+
idx = find_index(what)
|
23
|
+
idx && cell_items[idx]
|
24
|
+
end
|
25
|
+
|
26
|
+
#
|
27
|
+
# Returns the number of columns in the table.
|
28
|
+
#
|
29
|
+
def columns
|
30
|
+
cell_items.size
|
31
|
+
end
|
32
|
+
|
33
|
+
protected
|
34
|
+
|
35
|
+
def cell_items
|
36
|
+
@cell_items ||= element.cells.map do |obj|
|
37
|
+
::PageObject::Elements::TableCell.new(obj)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def find_index(what)
|
42
|
+
return what if what.is_a? Integer
|
43
|
+
|
44
|
+
parent(tag_name: 'table').headers.find_index do |header|
|
45
|
+
header.text.include? what
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
::PageObject::Elements.tag_to_class[:tr] = ::PageObject::Elements::TableRow
|
51
|
+
end
|
52
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Elements
|
3
|
-
class TextArea < Element
|
4
|
-
|
5
|
-
end
|
6
|
-
|
7
|
-
::PageObject::Elements.tag_to_class[:textarea] = ::PageObject::Elements::TextArea
|
8
|
-
end
|
9
|
-
end
|
1
|
+
module PageObject
|
2
|
+
module Elements
|
3
|
+
class TextArea < Element
|
4
|
+
|
5
|
+
end
|
6
|
+
|
7
|
+
::PageObject::Elements.tag_to_class[:textarea] = ::PageObject::Elements::TextArea
|
8
|
+
end
|
9
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Elements
|
3
|
-
class TextField < Element
|
4
|
-
|
5
|
-
end
|
6
|
-
|
7
|
-
::PageObject::Elements.type_to_class[:text] = ::PageObject::Elements::TextField
|
8
|
-
::PageObject::Elements.type_to_class[:password] = ::PageObject::Elements::TextField
|
9
|
-
end
|
10
|
-
end
|
1
|
+
module PageObject
|
2
|
+
module Elements
|
3
|
+
class TextField < Element
|
4
|
+
|
5
|
+
end
|
6
|
+
|
7
|
+
::PageObject::Elements.type_to_class[:text] = ::PageObject::Elements::TextField
|
8
|
+
::PageObject::Elements.type_to_class[:password] = ::PageObject::Elements::TextField
|
9
|
+
end
|
10
|
+
end
|
@@ -1,44 +1,42 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Elements
|
3
|
-
class UnorderedList < Element
|
4
|
-
include Enumerable
|
5
|
-
|
6
|
-
#
|
7
|
-
# iterator that yields with a PageObject::Elements::ListItem
|
8
|
-
#
|
9
|
-
# @return [PageObject::Elements::ListItem]
|
10
|
-
#
|
11
|
-
def each(&block)
|
12
|
-
list_items.each(&block)
|
13
|
-
end
|
14
|
-
|
15
|
-
#
|
16
|
-
# Return the PageObject::Elements::ListItem for the index provided. Index
|
17
|
-
# is zero based.
|
18
|
-
#
|
19
|
-
# @return [PageObject::Elements::ListItem]
|
20
|
-
#
|
21
|
-
def [](idx)
|
22
|
-
list_items[idx]
|
23
|
-
end
|
24
|
-
|
25
|
-
#
|
26
|
-
# Return the number of items contained in the unordered list
|
27
|
-
#
|
28
|
-
def items
|
29
|
-
list_items.size
|
30
|
-
end
|
31
|
-
|
32
|
-
#
|
33
|
-
# Return Array of ListItem objects that are children of the UnorderedList
|
34
|
-
#
|
35
|
-
def list_items
|
36
|
-
@list_items ||= children(tag_name: 'li')
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
1
|
+
module PageObject
|
2
|
+
module Elements
|
3
|
+
class UnorderedList < Element
|
4
|
+
include Enumerable
|
5
|
+
|
6
|
+
#
|
7
|
+
# iterator that yields with a PageObject::Elements::ListItem
|
8
|
+
#
|
9
|
+
# @return [PageObject::Elements::ListItem]
|
10
|
+
#
|
11
|
+
def each(&block)
|
12
|
+
list_items.each(&block)
|
13
|
+
end
|
14
|
+
|
15
|
+
#
|
16
|
+
# Return the PageObject::Elements::ListItem for the index provided. Index
|
17
|
+
# is zero based.
|
18
|
+
#
|
19
|
+
# @return [PageObject::Elements::ListItem]
|
20
|
+
#
|
21
|
+
def [](idx)
|
22
|
+
list_items[idx]
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# Return the number of items contained in the unordered list
|
27
|
+
#
|
28
|
+
def items
|
29
|
+
list_items.size
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# Return Array of ListItem objects that are children of the UnorderedList
|
34
|
+
#
|
35
|
+
def list_items
|
36
|
+
@list_items ||= children(tag_name: 'li')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
::PageObject::Elements.tag_to_class[:ul] = ::PageObject::Elements::UnorderedList
|
41
|
+
end
|
42
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Elements
|
3
|
-
class Video < Media
|
4
|
-
|
5
|
-
end
|
6
|
-
|
7
|
-
::PageObject::Elements.type_to_class[:video] = ::PageObject::Elements::Video
|
8
|
-
end
|
9
|
-
end
|
1
|
+
module PageObject
|
2
|
+
module Elements
|
3
|
+
class Video < Media
|
4
|
+
|
5
|
+
end
|
6
|
+
|
7
|
+
::PageObject::Elements.type_to_class[:video] = ::PageObject::Elements::Video
|
8
|
+
end
|
9
|
+
end
|