page-object 2.0.0 → 2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/ChangeLog +10 -0
- data/README.md +12 -0
- data/Rakefile +2 -12
- data/cucumber.yml +2 -4
- data/lib/page-object.rb +12 -20
- data/lib/page-object/accessors.rb +50 -363
- data/lib/page-object/elements/bold.rb +0 -1
- data/lib/page-object/elements/button.rb +0 -4
- data/lib/page-object/elements/check_box.rb +19 -7
- data/lib/page-object/elements/div.rb +0 -4
- data/lib/page-object/elements/element.rb +159 -90
- data/lib/page-object/elements/file_field.rb +5 -7
- data/lib/page-object/elements/form.rb +0 -8
- data/lib/page-object/elements/hidden_field.rb +1 -4
- data/lib/page-object/elements/image.rb +13 -7
- data/lib/page-object/elements/label.rb +0 -4
- data/lib/page-object/elements/link.rb +0 -13
- data/lib/page-object/elements/list_item.rb +0 -3
- data/lib/page-object/elements/ordered_list.rb +30 -5
- data/lib/page-object/elements/radio_button.rb +12 -7
- data/lib/page-object/elements/select_list.rb +40 -8
- data/lib/page-object/elements/span.rb +0 -3
- data/lib/page-object/elements/table.rb +26 -5
- data/lib/page-object/elements/table_cell.rb +0 -4
- data/lib/page-object/elements/table_row.rb +30 -5
- data/lib/page-object/elements/text_area.rb +7 -7
- data/lib/page-object/elements/text_field.rb +5 -11
- data/lib/page-object/elements/unordered_list.rb +30 -5
- data/lib/page-object/indexed_properties.rb +1 -0
- data/lib/page-object/platforms.rb +0 -1
- data/lib/page-object/platforms/watir.rb +26 -4
- data/lib/page-object/platforms/watir/page_object.rb +4 -4
- data/lib/page-object/version.rb +1 -1
- data/lib/page-object/widgets.rb +0 -1
- data/page-object.gemspec +1 -15
- metadata +5 -47
- data/lib/page-object/platforms/selenium_webdriver.rb +0 -30
- data/lib/page-object/platforms/selenium_webdriver/button.rb +0 -15
- data/lib/page-object/platforms/selenium_webdriver/check_box.rb +0 -29
- data/lib/page-object/platforms/selenium_webdriver/element.rb +0 -335
- data/lib/page-object/platforms/selenium_webdriver/file_field.rb +0 -16
- data/lib/page-object/platforms/selenium_webdriver/form.rb +0 -16
- data/lib/page-object/platforms/selenium_webdriver/image.rb +0 -28
- data/lib/page-object/platforms/selenium_webdriver/link.rb +0 -23
- data/lib/page-object/platforms/selenium_webdriver/ordered_list.rb +0 -41
- data/lib/page-object/platforms/selenium_webdriver/page_object.rb +0 -1297
- data/lib/page-object/platforms/selenium_webdriver/radio_button.rb +0 -22
- data/lib/page-object/platforms/selenium_webdriver/select_list.rb +0 -93
- data/lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb +0 -42
- data/lib/page-object/platforms/selenium_webdriver/table.rb +0 -42
- data/lib/page-object/platforms/selenium_webdriver/table_row.rb +0 -43
- data/lib/page-object/platforms/selenium_webdriver/text_area.rb +0 -17
- data/lib/page-object/platforms/selenium_webdriver/text_field.rb +0 -17
- data/lib/page-object/platforms/selenium_webdriver/unordered_list.rb +0 -37
- data/lib/page-object/platforms/watir/check_box.rb +0 -29
- data/lib/page-object/platforms/watir/element.rb +0 -295
- data/lib/page-object/platforms/watir/file_field.rb +0 -16
- data/lib/page-object/platforms/watir/form.rb +0 -16
- data/lib/page-object/platforms/watir/image.rb +0 -22
- data/lib/page-object/platforms/watir/link.rb +0 -15
- data/lib/page-object/platforms/watir/ordered_list.rb +0 -40
- data/lib/page-object/platforms/watir/radio_button.rb +0 -22
- data/lib/page-object/platforms/watir/select_list.rb +0 -74
- data/lib/page-object/platforms/watir/table.rb +0 -38
- data/lib/page-object/platforms/watir/table_row.rb +0 -37
- data/lib/page-object/platforms/watir/text_area.rb +0 -23
- data/lib/page-object/platforms/watir/text_field.rb +0 -16
- data/lib/page-object/platforms/watir/unordered_list.rb +0 -42
@@ -1,22 +0,0 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Platforms
|
3
|
-
module WatirWebDriver
|
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
|
@@ -1,40 +0,0 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Platforms
|
3
|
-
module WatirWebDriver
|
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
|
-
Object::PageObject::Elements::ListItem.new(children[idx], :platform => @platform.class::PLATFORM_NAME)
|
14
|
-
end
|
15
|
-
|
16
|
-
#
|
17
|
-
# Return the number of items contained in the ordered list
|
18
|
-
#
|
19
|
-
def items
|
20
|
-
children.size
|
21
|
-
end
|
22
|
-
|
23
|
-
#
|
24
|
-
# Return the ListItem objects that are children of the OrderedList
|
25
|
-
#
|
26
|
-
def list_items
|
27
|
-
children.collect do |obj|
|
28
|
-
Object::PageObject::Elements::ListItem.new(obj, :platform => :watir)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def children
|
35
|
-
element.ols(:xpath => child_xpath)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Platforms
|
3
|
-
module WatirWebDriver
|
4
|
-
module RadioButton
|
5
|
-
|
6
|
-
#
|
7
|
-
# select the radiobutton
|
8
|
-
#
|
9
|
-
def select
|
10
|
-
element.set
|
11
|
-
end
|
12
|
-
|
13
|
-
#
|
14
|
-
# return if it is selected
|
15
|
-
#
|
16
|
-
def selected?
|
17
|
-
element.set?
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Platforms
|
3
|
-
module WatirWebDriver
|
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
|
-
# Select a value from the list
|
18
|
-
#
|
19
|
-
def select(value)
|
20
|
-
element.select(value)
|
21
|
-
end
|
22
|
-
|
23
|
-
#
|
24
|
-
# Select the option(s) whose value attribute matches the given
|
25
|
-
# string
|
26
|
-
#
|
27
|
-
def select_value(value)
|
28
|
-
element.select_value(value)
|
29
|
-
end
|
30
|
-
|
31
|
-
#
|
32
|
-
# Return an array of Options contained in the select list.
|
33
|
-
#
|
34
|
-
# @return [array of PageObject::Elements::Option]
|
35
|
-
#
|
36
|
-
def options
|
37
|
-
element.options.map { |e| ::PageObject::Elements::Option.new(e, :platform => @platform.class::PLATFORM_NAME) }
|
38
|
-
end
|
39
|
-
|
40
|
-
#
|
41
|
-
# @return [Array<String>] An array of strings representing the text of the currently selected options.
|
42
|
-
#
|
43
|
-
def selected_options
|
44
|
-
element.selected_options.map { |e| e.text }.compact
|
45
|
-
end
|
46
|
-
|
47
|
-
#
|
48
|
-
# @return [Array<String>] An array of strings representing the value of the currently selected options.
|
49
|
-
#
|
50
|
-
def selected_values
|
51
|
-
element.selected_options.map { |e| e.value }.compact
|
52
|
-
end
|
53
|
-
|
54
|
-
#
|
55
|
-
# Returns true if the select list has one or more options where text or label matches the given value.
|
56
|
-
#
|
57
|
-
# @param [String, Regexp] value A value.
|
58
|
-
# @return [Boolean]
|
59
|
-
def include?(value)
|
60
|
-
element.include? value
|
61
|
-
end
|
62
|
-
|
63
|
-
#
|
64
|
-
# Returns true if any of the selected options' text or label match the given value.
|
65
|
-
#
|
66
|
-
# @param [String, Regexp] value A value.
|
67
|
-
# @return [Boolean]
|
68
|
-
def selected?(value)
|
69
|
-
element.selected? value
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Platforms
|
3
|
-
module WatirWebDriver
|
4
|
-
|
5
|
-
module Table
|
6
|
-
|
7
|
-
#
|
8
|
-
# Return the PageObject::Elements::TableRow for the index provided. Index
|
9
|
-
# is zero based. If the index provided is a String then it
|
10
|
-
# will be matched with the text from any column. The text can be a substring of the full column text.
|
11
|
-
#
|
12
|
-
# @return [PageObject::Elements::TableRow]
|
13
|
-
#
|
14
|
-
def [](idx)
|
15
|
-
idx = find_index_by_title(idx) if idx.kind_of?(String)
|
16
|
-
return nil unless idx
|
17
|
-
initialize_row(element[idx], :platform => @platform.class::PLATFORM_NAME)
|
18
|
-
end
|
19
|
-
|
20
|
-
#
|
21
|
-
# Returns the number of rows in the table.
|
22
|
-
#
|
23
|
-
def rows
|
24
|
-
element.wd.find_elements(:xpath, child_xpath).size
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def find_index_by_title(row_title)
|
30
|
-
element.rows.find_index do |row|
|
31
|
-
row.cells.any? { |col| col.text.include? row_title }
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Platforms
|
3
|
-
module WatirWebDriver
|
4
|
-
module TableRow
|
5
|
-
|
6
|
-
#
|
7
|
-
# Return the PageObject::Elements::TableCell for the index provided. Index
|
8
|
-
# is zero based. If the index provided is a String then it
|
9
|
-
# will be matched with the text from the columns in the first row.
|
10
|
-
# The text can be a substring of the full column text.
|
11
|
-
#
|
12
|
-
def [](idx)
|
13
|
-
idx = find_index_by_title(idx) if idx.kind_of?(String)
|
14
|
-
return nil unless idx && columns >= idx + 1
|
15
|
-
initialize_cell(element[idx], :platform => @platform.class::PLATFORM_NAME)
|
16
|
-
end
|
17
|
-
|
18
|
-
#
|
19
|
-
# Returns the number of columns in the table.
|
20
|
-
#
|
21
|
-
def columns
|
22
|
-
element.wd.find_elements(:xpath, child_xpath).size
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def find_index_by_title(title)
|
28
|
-
table = element.parent
|
29
|
-
table = table.parent if table.tag_name == 'tbody'
|
30
|
-
first_row = table[0]
|
31
|
-
first_row.cells.find_index {|column| column.text.include? title }
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Platforms
|
3
|
-
module WatirWebDriver
|
4
|
-
|
5
|
-
module TextArea
|
6
|
-
|
7
|
-
#
|
8
|
-
# Set the value of the TextArea
|
9
|
-
#
|
10
|
-
def value=(new_value)
|
11
|
-
element.set(new_value)
|
12
|
-
end
|
13
|
-
|
14
|
-
#
|
15
|
-
# Clear the TextArea
|
16
|
-
#
|
17
|
-
def clear
|
18
|
-
element.wd.clear
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Platforms
|
3
|
-
module WatirWebDriver
|
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
|
-
Object::PageObject::Elements::ListItem.new(children[idx], :platform => @platform.class::PLATFORM_NAME)
|
14
|
-
end
|
15
|
-
|
16
|
-
#
|
17
|
-
# Return the number of items contained in the unordered list
|
18
|
-
#
|
19
|
-
def items
|
20
|
-
children.size
|
21
|
-
end
|
22
|
-
|
23
|
-
#
|
24
|
-
# Return the ListItem objects that are children of the
|
25
|
-
# UnorderedList
|
26
|
-
#
|
27
|
-
def list_items
|
28
|
-
children.collect do |obj|
|
29
|
-
Object::PageObject::Elements::ListItem.new(obj, :platform => :watir)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
def children
|
36
|
-
element.uls(:xpath => child_xpath)
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|