page-object 2.0.0 → 2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -2
  3. data/ChangeLog +10 -0
  4. data/README.md +12 -0
  5. data/Rakefile +2 -12
  6. data/cucumber.yml +2 -4
  7. data/lib/page-object.rb +12 -20
  8. data/lib/page-object/accessors.rb +50 -363
  9. data/lib/page-object/elements/bold.rb +0 -1
  10. data/lib/page-object/elements/button.rb +0 -4
  11. data/lib/page-object/elements/check_box.rb +19 -7
  12. data/lib/page-object/elements/div.rb +0 -4
  13. data/lib/page-object/elements/element.rb +159 -90
  14. data/lib/page-object/elements/file_field.rb +5 -7
  15. data/lib/page-object/elements/form.rb +0 -8
  16. data/lib/page-object/elements/hidden_field.rb +1 -4
  17. data/lib/page-object/elements/image.rb +13 -7
  18. data/lib/page-object/elements/label.rb +0 -4
  19. data/lib/page-object/elements/link.rb +0 -13
  20. data/lib/page-object/elements/list_item.rb +0 -3
  21. data/lib/page-object/elements/ordered_list.rb +30 -5
  22. data/lib/page-object/elements/radio_button.rb +12 -7
  23. data/lib/page-object/elements/select_list.rb +40 -8
  24. data/lib/page-object/elements/span.rb +0 -3
  25. data/lib/page-object/elements/table.rb +26 -5
  26. data/lib/page-object/elements/table_cell.rb +0 -4
  27. data/lib/page-object/elements/table_row.rb +30 -5
  28. data/lib/page-object/elements/text_area.rb +7 -7
  29. data/lib/page-object/elements/text_field.rb +5 -11
  30. data/lib/page-object/elements/unordered_list.rb +30 -5
  31. data/lib/page-object/indexed_properties.rb +1 -0
  32. data/lib/page-object/platforms.rb +0 -1
  33. data/lib/page-object/platforms/watir.rb +26 -4
  34. data/lib/page-object/platforms/watir/page_object.rb +4 -4
  35. data/lib/page-object/version.rb +1 -1
  36. data/lib/page-object/widgets.rb +0 -1
  37. data/page-object.gemspec +1 -15
  38. metadata +5 -47
  39. data/lib/page-object/platforms/selenium_webdriver.rb +0 -30
  40. data/lib/page-object/platforms/selenium_webdriver/button.rb +0 -15
  41. data/lib/page-object/platforms/selenium_webdriver/check_box.rb +0 -29
  42. data/lib/page-object/platforms/selenium_webdriver/element.rb +0 -335
  43. data/lib/page-object/platforms/selenium_webdriver/file_field.rb +0 -16
  44. data/lib/page-object/platforms/selenium_webdriver/form.rb +0 -16
  45. data/lib/page-object/platforms/selenium_webdriver/image.rb +0 -28
  46. data/lib/page-object/platforms/selenium_webdriver/link.rb +0 -23
  47. data/lib/page-object/platforms/selenium_webdriver/ordered_list.rb +0 -41
  48. data/lib/page-object/platforms/selenium_webdriver/page_object.rb +0 -1297
  49. data/lib/page-object/platforms/selenium_webdriver/radio_button.rb +0 -22
  50. data/lib/page-object/platforms/selenium_webdriver/select_list.rb +0 -93
  51. data/lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb +0 -42
  52. data/lib/page-object/platforms/selenium_webdriver/table.rb +0 -42
  53. data/lib/page-object/platforms/selenium_webdriver/table_row.rb +0 -43
  54. data/lib/page-object/platforms/selenium_webdriver/text_area.rb +0 -17
  55. data/lib/page-object/platforms/selenium_webdriver/text_field.rb +0 -17
  56. data/lib/page-object/platforms/selenium_webdriver/unordered_list.rb +0 -37
  57. data/lib/page-object/platforms/watir/check_box.rb +0 -29
  58. data/lib/page-object/platforms/watir/element.rb +0 -295
  59. data/lib/page-object/platforms/watir/file_field.rb +0 -16
  60. data/lib/page-object/platforms/watir/form.rb +0 -16
  61. data/lib/page-object/platforms/watir/image.rb +0 -22
  62. data/lib/page-object/platforms/watir/link.rb +0 -15
  63. data/lib/page-object/platforms/watir/ordered_list.rb +0 -40
  64. data/lib/page-object/platforms/watir/radio_button.rb +0 -22
  65. data/lib/page-object/platforms/watir/select_list.rb +0 -74
  66. data/lib/page-object/platforms/watir/table.rb +0 -38
  67. data/lib/page-object/platforms/watir/table_row.rb +0 -37
  68. data/lib/page-object/platforms/watir/text_area.rb +0 -23
  69. data/lib/page-object/platforms/watir/text_field.rb +0 -16
  70. data/lib/page-object/platforms/watir/unordered_list.rb +0 -42
@@ -1,16 +0,0 @@
1
- module PageObject
2
- module Platforms
3
- module WatirWebDriver
4
-
5
- module FileField
6
-
7
- #
8
- # Set the value of the FileField
9
- #
10
- def value=(new_value)
11
- element.set(new_value)
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- module PageObject
2
- module Platforms
3
- module WatirWebDriver
4
- module Form
5
-
6
- #
7
- # Submit the form.
8
- #
9
- def submit
10
- element.submit
11
- end
12
-
13
- end
14
- end
15
- end
16
- end
@@ -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,15 +0,0 @@
1
- module PageObject
2
- module Platforms
3
- module WatirWebDriver
4
- module Link
5
-
6
- #
7
- # return the href for the link
8
- #
9
- def href
10
- element.href
11
- end
12
- end
13
- end
14
- end
15
- 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,16 +0,0 @@
1
- module PageObject
2
- module Platforms
3
- module WatirWebDriver
4
-
5
- module TextField
6
-
7
- #
8
- # Set the value of the TextField
9
- #
10
- def value=(new_value)
11
- element.set(new_value)
12
- end
13
- end
14
- end
15
- end
16
- 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