page-object 0.0.5 → 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. data/ChangeLog +46 -1
  2. data/README.md +2 -0
  3. data/cucumber.yml +2 -2
  4. data/features/button.feature +11 -2
  5. data/features/check_box.feature +7 -5
  6. data/features/div.feature +7 -15
  7. data/features/{element.feature → element_attributes.feature} +1 -1
  8. data/features/form.feature +7 -6
  9. data/features/hidden_field.feature +9 -1
  10. data/features/html/static_elements.html +6 -1
  11. data/features/image.feature +9 -9
  12. data/features/link.feature +8 -1
  13. data/features/list_item.feature +6 -13
  14. data/features/ordered_list.feature +9 -17
  15. data/features/radio_button.feature +7 -6
  16. data/features/select_list.feature +12 -10
  17. data/features/span.feature +7 -15
  18. data/features/step_definitions/accessor_steps.rb +101 -26
  19. data/features/step_definitions/element_steps.rb +5 -0
  20. data/features/support/page.rb +36 -0
  21. data/features/table.feature +6 -15
  22. data/features/table_cell.feature +6 -12
  23. data/features/text_area.feature +7 -6
  24. data/features/text_field.feature +7 -6
  25. data/features/unordered_list.feature +9 -17
  26. data/lib/page-object/accessors.rb +93 -76
  27. data/lib/page-object/elements.rb +1 -0
  28. data/lib/page-object/elements/element.rb +76 -6
  29. data/lib/page-object/elements/option.rb +7 -0
  30. data/lib/page-object/elements/select_list.rb +24 -1
  31. data/lib/page-object/page_factory.rb +3 -3
  32. data/lib/page-object/platforms/selenium_select_list.rb +29 -0
  33. data/lib/page-object/platforms/watir_select_list.rb +30 -0
  34. data/lib/page-object/selenium_page_object.rb +53 -3
  35. data/lib/page-object/version.rb +1 -1
  36. data/lib/page-object/watir_page_object.rb +20 -1
  37. data/page-object.gemspec +2 -2
  38. data/spec/page-object/accessors_spec.rb +2 -2
  39. data/spec/page-object/elements/button_spec.rb +1 -1
  40. data/spec/page-object/elements/check_box_spec.rb +1 -1
  41. data/spec/page-object/elements/div_spec.rb +1 -1
  42. data/spec/page-object/elements/hidden_field_spec.rb +1 -1
  43. data/spec/page-object/elements/image_spec.rb +1 -1
  44. data/spec/page-object/elements/link_spec.rb +1 -1
  45. data/spec/page-object/elements/list_item_spec.rb +1 -1
  46. data/spec/page-object/elements/ordered_list_spec.rb +1 -1
  47. data/spec/page-object/elements/radio_button_spec.rb +1 -1
  48. data/spec/page-object/elements/select_list_spec.rb +43 -2
  49. data/spec/page-object/elements/span_spec.rb +1 -1
  50. data/spec/page-object/elements/table_row_spec.rb +5 -1
  51. data/spec/page-object/elements/table_spec.rb +1 -1
  52. data/spec/page-object/elements/text_area_spec.rb +1 -1
  53. data/spec/page-object/elements/text_field_spec.rb +1 -1
  54. data/spec/page-object/elements/unordered_list_spec.rb +1 -1
  55. metadata +9 -6
@@ -1,3 +1,8 @@
1
+ When /^I select a link labeled "([^"]*)" and index "([^"]*)"$/ do |label, index|
2
+ @page.send "#{label.downcase}#{index}".to_sym
3
+ end
4
+
5
+
1
6
  When /^I retrieve a check box element$/ do
2
7
  @element = @page.cb_id_checkbox
3
8
  end
@@ -1,6 +1,10 @@
1
1
  class Page
2
2
  include PageObject
3
3
 
4
+ link(:hello0, {:text => "Hello", :index => 0})
5
+ link(:hello1, {:text => "Hello", :index => 1})
6
+ link(:hello2, {:text => "Hello", :index => 2})
7
+
4
8
  text_field(:text_field_id, :id => "text_field_id")
5
9
  text_field(:text_field_class, :class => "text_field_class")
6
10
  text_field(:text_field_name, :name => "text_field_name")
@@ -10,6 +14,8 @@ class Page
10
14
  text_field(:text_field_index, :index => 0)
11
15
  text_field(:text_field_text, :text => "")
12
16
  text_field(:text_field_value, :value => "")
17
+ text_field(:text_field_class_index, :class => "text_field_class", :index => 0)
18
+ text_field(:text_field_name_index, :name => "text_field_name", :index => 0)
13
19
 
14
20
  text_area(:text_area_id, :id => "text_area_id")
15
21
  text_area(:text_area_class, :class => "text_area_class")
@@ -20,6 +26,8 @@ class Page
20
26
  text_area(:text_area_index, :index => 0)
21
27
  text_area(:text_area_text, :text => "")
22
28
  text_area(:text_area_value, :value => "")
29
+ text_area(:text_area_class_index, :class => "text_area_class", :index => 0)
30
+ text_area(:text_area_name_index, :name => "text_area_name", :index => 0)
23
31
 
24
32
  hidden_field(:hidden_field_id, :id => "hidden_field_id")
25
33
  hidden_field(:hidden_field_class, :class => "hidden_field_class")
@@ -30,6 +38,8 @@ class Page
30
38
  hidden_field(:hidden_field_index, :index => 0)
31
39
  hidden_field(:hidden_field_text, :text => "")
32
40
  hidden_field(:hidden_field_value, :value => "")
41
+ hidden_field(:hidden_field_class_index, :class => "hidden_field_class", :index => 0)
42
+ hidden_field(:hidden_field_name_index, :name => "hidden_field_name", :index => 0)
33
43
 
34
44
  link(:google_search_id, :id => "link_id")
35
45
  link(:google_search_name, :name => "link_name")
@@ -48,18 +58,24 @@ class Page
48
58
  select_list(:sel_list_value, :value => "option1")
49
59
  select_list(:sel_list_xpath, :xpath => "//select")
50
60
  select_list(:sel_list_text, :text => "Test 1")
61
+ select_list(:sel_list_class_index, :class => "sel_list_class", :index => 0)
62
+ select_list(:sel_list_name_index, :name => "sel_list_name", :index => 0)
51
63
 
52
64
  checkbox(:cb_id, :id => 'cb_id')
53
65
  checkbox(:cb_name, :name => 'cb_name')
54
66
  checkbox(:cb_class, :class => 'cb_class')
55
67
  checkbox(:cb_index, :index => 0)
56
68
  checkbox(:cb_xpath, :xpath => "//input[@type='checkbox']")
69
+ checkbox(:cb_class_index, :class => "cb_class", :index => 0)
70
+ checkbox(:cb_name_index, :name => "cb_name", :index => 0)
57
71
 
58
72
  radio_button(:milk_id, :id => 'milk_id')
59
73
  radio_button(:milk_name, :name => 'milk_name')
60
74
  radio_button(:milk_class, :class => 'milk_class')
61
75
  radio_button(:milk_index, :index => 0)
62
76
  radio_button(:milk_xpath, :xpath => "//input[@type='radio']")
77
+ radio_button(:milk_class_index, :class => "milk_class", :index => 0)
78
+ radio_button(:milk_name_index, :name => "milk_name", :index => 0)
63
79
 
64
80
  radio_button(:butter_id, :id => 'butter_id')
65
81
 
@@ -68,24 +84,32 @@ class Page
68
84
  div(:div_class, :class => 'div_class')
69
85
  div(:div_index, :index => 0)
70
86
  div(:div_xpath, :xpath => '//div')
87
+ div(:div_class_index, :class => "div_class", :index => 0)
88
+ div(:div_name_index, :name => "div_name", :index => 0)
71
89
 
72
90
  span(:span_id, :id => 'span_id')
73
91
  span(:span_name, :name => 'span_name')
74
92
  span(:span_class, :class => 'span_class')
75
93
  span(:span_index, :index => 0)
76
94
  span(:span_xpath, :xpath => '//span')
95
+ span(:span_class_index, :class => "span_class", :index => 0)
96
+ span(:span_name_index, :name => "span_name", :index => 0)
77
97
 
78
98
  table(:table_id, :id => 'table_id')
79
99
  table(:table_name, :name => 'table_name')
80
100
  table(:table_class, :class => 'table_class')
81
101
  table(:table_index, :index => 0)
82
102
  table(:table_xpath, :xpath => '//table')
103
+ table(:table_class_index, :class => "table_class", :index => 0)
104
+ table(:table_name_index, :name => "table_name", :index => 0)
83
105
 
84
106
  cell(:cell_id, :id => 'cell_id')
85
107
  cell(:cell_name, :name => 'cell_name')
86
108
  cell(:cell_class, :class => 'cell_class')
87
109
  cell(:cell_index, :index => 3)
88
110
  cell(:cell_xpath, :xpath => '//table//tr[2]//td[2]')
111
+ cell(:cell_class_index, :class => "cell_class", :index => 0)
112
+ cell(:cell_name_index, :name => "cell_name", :index => 0)
89
113
 
90
114
  button(:button_id, :id => 'button_id')
91
115
  button(:button_name, :name => 'button_name')
@@ -93,34 +117,46 @@ class Page
93
117
  button(:button_index, :index => 0)
94
118
  button(:button_xpath, :xpath=> "//input[@type='submit']")
95
119
  button(:button_text, :text => 'Click Me')
120
+ button(:button_class_index, :class => "button_class", :index => 0)
121
+ button(:button_name_index, :name => "button_name", :index => 0)
96
122
 
97
123
  image(:image_id, :id => 'image_id')
98
124
  image(:image_name, :name => 'image_name')
99
125
  image(:image_class, :class => 'image_class')
100
126
  image(:image_index, :index => 0)
101
127
  image(:image_xpath, :xpath => '//img')
128
+ image(:image_class_index, :class => "image_class", :index => 0)
129
+ image(:image_name_index, :name => "image_name", :index => 0)
102
130
 
103
131
  form(:form_id, :id => 'form_id')
104
132
  form(:form_name, :id => 'form_name')
105
133
  form(:form_class, :class => 'form_class')
106
134
  form(:form_index, :index => 0)
107
135
  form(:form_xpath, :xpath => '//form')
136
+ form(:form_class_index, :class => "form_class", :index => 0)
137
+ form(:form_name_index, :name => "form_name", :index => 0)
108
138
 
109
139
  list_item(:li_id, :id => 'li_id')
110
140
  list_item(:li_name, :name => 'li_name')
111
141
  list_item(:li_class, :class => 'li_class')
112
142
  list_item(:li_index, :index => 0)
113
143
  list_item(:li_xpath, :xpath => '//li[1]')
144
+ list_item(:li_class_index, :class => "li_class", :index => 0)
145
+ list_item(:li_name_index, :name => "li_name", :index => 0)
114
146
 
115
147
  unordered_list(:ul_id, :id => 'ul_id')
116
148
  unordered_list(:ul_name, :name => 'ul_name')
117
149
  unordered_list(:ul_class, :class => 'ul_class')
118
150
  unordered_list(:ul_index, :index => 0)
119
151
  unordered_list(:ul_xpath, :xpath => '//ul')
152
+ unordered_list(:ul_class_index, :class => "ul_class", :index => 0)
153
+ unordered_list(:ul_name_index, :name => "ul_name", :index => 0)
120
154
 
121
155
  ordered_list(:ol_id, :id => 'ol_id')
122
156
  ordered_list(:ol_name, :name => 'ol_name')
123
157
  ordered_list(:ol_class, :class => 'ol_class')
124
158
  ordered_list(:ol_index, :index => 0)
125
159
  ordered_list(:ol_xpath, :xpath => '//ol')
160
+ ordered_list(:ol_class_index, :class => "ol_class", :index => 0)
161
+ ordered_list(:ol_name_index, :name => "ol_name", :index => 0)
126
162
  end
@@ -33,23 +33,14 @@ Feature: Table
33
33
  | id |
34
34
  | class |
35
35
  | xpath |
36
-
37
-
38
- @watir_only
39
- Scenario Outline: Locating table cells on the Page with watir
40
- When I retrieve a table element by "<search_by>"
41
- Then the data for row "1" should be "Data1" and "Data2"
42
-
43
- Scenarios:
44
- | search_by |
45
36
  | index |
37
+ | name |
46
38
 
47
-
48
- @selenium_only
49
- Scenario Outline: Locating table cells on the Page with selenium
50
- When I retrieve a table element by "<search_by>"
39
+ Scenario Outline: Locating table using multiple parameters
40
+ When I retrieve a table element by "<param1>" and "<param2>"
51
41
  Then the data for row "1" should be "Data1" and "Data2"
52
42
 
53
43
  Scenarios:
54
- | search_by |
55
- | name |
44
+ | param1 | param2 |
45
+ | class | index |
46
+ | name | index |
@@ -17,8 +17,8 @@ Feature: Table Cell
17
17
  | id |
18
18
  | class |
19
19
  | xpath |
20
+ | name |
20
21
 
21
-
22
22
  @watir_only
23
23
  Scenario Outline: Locating table cells on the Page with watir
24
24
  When I search for the table cell by "<search_by>"
@@ -28,18 +28,12 @@ Feature: Table Cell
28
28
  | search_by |
29
29
  | index |
30
30
 
31
- @selenium_only
32
- Scenario Outline: Locating table cells on the Page with watir
33
- When I search for the table cell by "<search_by>"
31
+ Scenario Outline: Locating table cell using multiple parameters
32
+ When I retrieve a table cell element by "<param1>" and "<param2>"
34
33
  Then the cell data should be 'Data4'
35
34
 
36
35
  Scenarios:
37
- | search_by |
38
- | name |
39
-
40
- Scenario: Retrieve a cell from a table by id
41
- When I retrieve table cell
42
- Then I should know it exists
43
- And I should know it is visible
44
-
36
+ | param1 | param2 |
37
+ | class | index |
38
+ | name | index |
45
39
 
@@ -20,13 +20,14 @@ Feature: Text Area
20
20
  | xpath |
21
21
  | css |
22
22
  | tag_name |
23
+ | index |
23
24
 
24
- @watir_only
25
- Scenario Outline: Locating text fields on Watir only
26
- When I search for the text area by "<search_by>"
25
+
26
+ Scenario Outline: Locating a text area using multiple parameters
27
+ When I search for the text area by "<param1>" and "<param2>"
27
28
  Then I should be able to type "I found it" into the area
28
29
 
29
30
  Scenarios:
30
- | search_by |
31
- | index |
32
-
31
+ | param1 | param2 |
32
+ | class | index |
33
+ | name | index |
@@ -22,15 +22,16 @@ Feature: Text Fields
22
22
  | xpath |
23
23
  | css |
24
24
  | tag_name |
25
-
26
- @watir_only
27
- Scenario Outline: Locating text fields on Watir only
28
- When I search for the text field by "<search_by>"
25
+ | index |
26
+
27
+ Scenario Outline: Locating a text field using multiple parameters
28
+ When I search for the text field by "<param1>" and "<param2>"
29
29
  Then I should be able to type "I found it" into the field
30
30
 
31
31
  Scenarios:
32
- | search_by |
33
- | index |
32
+ | param1 | param2 |
33
+ | class | index |
34
+ | name | index |
34
35
 
35
36
  Scenario: Retrieve a text field
36
37
  When I retrieve a text field
@@ -5,12 +5,12 @@ Feature: Unordered list
5
5
 
6
6
  Scenario: Getting the first element from the unordered list
7
7
  When I get the first item from the unordered list
8
- Then the list item's text should be "Item One"
8
+ Then the list items text should be "Item One"
9
9
 
10
10
  Scenario Outline: Locating unordered lists on the page
11
11
  When I search for the unordered list by "<search_by>"
12
12
  And I get the first item from the list
13
- Then the list item's text should be "Item One"
13
+ Then the list items text should be "Item One"
14
14
  And the list should contain 3 items
15
15
  And each item should contain "Item"
16
16
 
@@ -19,23 +19,15 @@ Feature: Unordered list
19
19
  | id |
20
20
  | class |
21
21
  | xpath |
22
-
23
- @watir_only
24
- Scenario Outline: Locating unordered lists in Watir only
25
- When I search for the unordered list by "<search_by>"
26
- And I get the first item from the list
27
- Then the list item's text should be "Item One"
28
-
29
- Scenarios:
30
- | search_by |
31
22
  | index |
23
+ | name |
32
24
 
33
- @selenium_only
34
- Scenario Outline: Locating unordered lists in Selenium only
35
- When I search for the unordered list by "<search_by>"
25
+ Scenario Outline: Locating unordered lists using multiple parameters
26
+ When I search for the unordered list by "<param1>" and "<param2>"
36
27
  And I get the first item from the list
37
- Then the list item's text should be "Item One"
28
+ Then the list items text should be "Item One"
38
29
 
39
30
  Scenarios:
40
- | search_by |
41
- | name |
31
+ | param1 | param2 |
32
+ | class | index |
33
+ | name | index |
@@ -32,11 +32,12 @@ module PageObject
32
32
  # # will generate 'first_name', 'first_name=' and 'first_name_text_field' methods
33
33
  #
34
34
  # @param [String] the name used for the generated methods
35
- # @param [Hash] identifier how we find a text_field. The valid keys are:
35
+ # @param [Hash] identifier how we find a text field. You can use a multiple paramaters
36
+ # by combining of any of the following except xpath. The valid keys are:
36
37
  # * :class => Watir and Selenium
37
38
  # * :css => Watir and Selenium
38
39
  # * :id => Watir and Selenium
39
- # * :index => Watir only
40
+ # * :index => Watir and Selenium
40
41
  # * :name => Watir and Selenium
41
42
  # * :tag_name => Watir and Selenium
42
43
  # * :text => Watir only
@@ -46,13 +47,13 @@ module PageObject
46
47
  #
47
48
  def text_field(name, identifier=nil, &block)
48
49
  define_method(name) do
49
- platform.text_field_value_for identifier
50
+ platform.text_field_value_for identifier.clone
50
51
  end
51
52
  define_method("#{name}=") do |value|
52
- platform.text_field_value_set(identifier, value)
53
+ platform.text_field_value_set(identifier.clone, value)
53
54
  end
54
55
  define_method("#{name}_text_field") do
55
- block ? block.call(browser) : platform.text_field_for(identifier)
56
+ block ? block.call(browser) : platform.text_field_for(identifier.clone)
56
57
  end
57
58
  end
58
59
 
@@ -65,11 +66,12 @@ module PageObject
65
66
  # # will generate 'user_id' and 'user_id_hidden_field' methods
66
67
  #
67
68
  # @param [String] the name used for the generated methods
68
- # @param [Hash] identifier how we find a hidden field. The valid keys are:
69
+ # @param [Hash] identifier how we find a hidden field. You can use a multiple paramaters
70
+ # by combining of any of the following except xpath. The valid keys are:
69
71
  # * :class => Watir and Selenium
70
72
  # * :css => Watir and Selenium
71
73
  # * :id => Watir and Selenium
72
- # * :index => Watir only
74
+ # * :index => Watir and Selenium
73
75
  # * :name => Watir and Selenium
74
76
  # * :tag_name => Watir and Selenium
75
77
  # * :text => Watir only
@@ -78,10 +80,10 @@ module PageObject
78
80
  #
79
81
  def hidden_field(name, identifier=nil, &block)
80
82
  define_method(name) do
81
- platform.hidden_field_value_for identifier
83
+ platform.hidden_field_value_for identifier.clone
82
84
  end
83
85
  define_method("#{name}_hidden_field") do
84
- block ? block.call(browser) : platform.hidden_field_for(identifier)
86
+ block ? block.call(browser) : platform.hidden_field_for(identifier.clone)
85
87
  end
86
88
  end
87
89
 
@@ -95,11 +97,12 @@ module PageObject
95
97
  # # will generate 'address', 'address=' and 'address_text_area methods
96
98
  #
97
99
  # @param [String] the name used for the generated methods
98
- # @param [Hash] identifier how we find a text area. The valid keys are:
100
+ # @param [Hash] identifier how we find a text area. You can use a multiple paramaters
101
+ # by combining of any of the following except xpath. The valid keys are:
99
102
  # * :class => Watir and Selenium
100
103
  # * :css => Watir and Selenium
101
104
  # * :id => Watir and Selenium
102
- # * :index => Watir only
105
+ # * :index => Watir and Selenium
103
106
  # * :name => Watir and Selenium
104
107
  # * :tag_name => Watir and Selenium
105
108
  # * :xpath => Watir and Selenium
@@ -107,13 +110,13 @@ module PageObject
107
110
  #
108
111
  def text_area(name, identifier=nil, &block)
109
112
  define_method(name) do
110
- platform.text_area_value_for identifier
113
+ platform.text_area_value_for identifier.clone
111
114
  end
112
115
  define_method("#{name}=") do |value|
113
- platform.text_area_value_set(identifier, value)
116
+ platform.text_area_value_set(identifier.clone, value)
114
117
  end
115
118
  define_method("#{name}_text_area") do
116
- block ? block.call(browser) : platform.text_area_for(identifier)
119
+ block ? block.call(browser) : platform.text_area_for(identifier.clone)
117
120
  end
118
121
  end
119
122
 
@@ -127,10 +130,11 @@ module PageObject
127
130
  # # will generate 'state', 'state=' and 'state_select_list' methods
128
131
  #
129
132
  # @param [String] the name used for the generated methods
130
- # @param [Hash] identifier how we find a select_list. The valid keys are:
133
+ # @param [Hash] identifier how we find a select list. You can use a multiple paramaters
134
+ # by combining of any of the following except xpath. The valid keys are:
131
135
  # * :class => Watir and Selenium
132
136
  # * :id => Watir and Selenium
133
- # * :index => Watir only
137
+ # * :index => Watir and Selenium
134
138
  # * :name => Watir and Selenium
135
139
  # * :text => Watir only
136
140
  # * :value => Watir only
@@ -139,13 +143,13 @@ module PageObject
139
143
  #
140
144
  def select_list(name, identifier=nil, &block)
141
145
  define_method(name) do
142
- platform.select_list_value_for identifier
146
+ platform.select_list_value_for identifier.clone
143
147
  end
144
148
  define_method("#{name}=") do |value|
145
- platform.select_list_value_set(identifier, value)
149
+ platform.select_list_value_set(identifier.clone, value)
146
150
  end
147
151
  define_method("#{name}_select_list") do
148
- block ? block.call(browser) : platform.select_list_for(identifier)
152
+ block ? block.call(browser) : platform.select_list_for(identifier.clone)
149
153
  end
150
154
  end
151
155
 
@@ -159,11 +163,12 @@ module PageObject
159
163
  # # will generate 'add_to_cart' and 'add_to_cart_link' methods
160
164
  #
161
165
  # @param [String] the name used for the generated methods
162
- # @param [Hash] identifier how we find a link. The valid keys are:
166
+ # @param [Hash] identifier how we find a link. You can use a multiple paramaters
167
+ # by combining of any of the following except xpath. The valid keys are:
163
168
  # * :class => Watir and Selenium
164
169
  # * :href => Watir only
165
170
  # * :id => Watir and Selenium
166
- # * :index => Watir only
171
+ # * :index => Watir and Selenium
167
172
  # * :link => Watir and Selenium
168
173
  # * :link_text => Watir and Selenium
169
174
  # * :name => Watir and Selenium
@@ -173,10 +178,10 @@ module PageObject
173
178
  #
174
179
  def link(name, identifier=nil, &block)
175
180
  define_method(name) do
176
- platform.click_link_for identifier
181
+ platform.click_link_for identifier.clone
177
182
  end
178
183
  define_method("#{name}_link") do
179
- block ? block.call(browser) : platform.link_for(identifier)
184
+ block ? block.call(browser) : platform.link_for(identifier.clone)
180
185
  end
181
186
  end
182
187
 
@@ -190,26 +195,27 @@ module PageObject
190
195
  # # will generate 'check_active', 'uncheck_active', 'active_checked?' and 'active_checkbox' methods
191
196
  #
192
197
  # @param [String] the name used for the generated methods
193
- # @param [Hash] identifier how we find a checkbox. The valid keys are:
198
+ # @param [Hash] identifier how we find a checkbox. You can use a multiple paramaters
199
+ # by combining of any of the following except xpath. The valid keys are:
194
200
  # * :class => Watir and Selenium
195
201
  # * :id => Watir and Selenium
196
- # * :index => Watir only
202
+ # * :index => Watir and Selenium
197
203
  # * :name => Watir and Selenium
198
204
  # * :xpath => Watir and Selenium
199
205
  # @param optional block to be invoked when element method is called
200
206
  #
201
207
  def checkbox(name, identifier=nil, &block)
202
208
  define_method("check_#{name}") do
203
- platform.check_checkbox(identifier)
209
+ platform.check_checkbox(identifier.clone)
204
210
  end
205
211
  define_method("uncheck_#{name}") do
206
- platform.uncheck_checkbox(identifier)
212
+ platform.uncheck_checkbox(identifier.clone)
207
213
  end
208
214
  define_method("#{name}_checked?") do
209
- platform.checkbox_checked?(identifier)
215
+ platform.checkbox_checked?(identifier.clone)
210
216
  end
211
217
  define_method("#{name}_checkbox") do
212
- block ? block.call(browser) : platform.checkbox_for(identifier)
218
+ block ? block.call(browser) : platform.checkbox_for(identifier.clone)
213
219
  end
214
220
  end
215
221
 
@@ -224,26 +230,27 @@ module PageObject
224
230
  # # will generate 'select_north', 'clear_north', 'north_selected?' and 'north_radio_button' methods
225
231
  #
226
232
  # @param [String] the name used for the generated methods
227
- # @param [Hash] identifier how we find a radio button. The valid keys are:
233
+ # @param [Hash] identifier how we find a radio button. You can use a multiple paramaters
234
+ # by combining of any of the following except xpath. The valid keys are:
228
235
  # * :class => Watir and Selenium
229
236
  # * :id => Watir and Selenium
230
- # * :index => Watir only
237
+ # * :index => Watir and Selenium
231
238
  # * :name => Watir and Selenium
232
239
  # * :xpath => Watir and Selenium
233
240
  # @param optional block to be invoked when element method is called
234
241
  #
235
242
  def radio_button(name, identifier=nil, &block)
236
243
  define_method("select_#{name}") do
237
- platform.select_radio(identifier)
244
+ platform.select_radio(identifier.clone)
238
245
  end
239
246
  define_method("clear_#{name}") do
240
- platform.clear_radio(identifier)
247
+ platform.clear_radio(identifier.clone)
241
248
  end
242
249
  define_method("#{name}_selected?") do
243
- platform.radio_selected?(identifier)
250
+ platform.radio_selected?(identifier.clone)
244
251
  end
245
252
  define_method("#{name}_radio_button") do
246
- block ? block.call(browser) : platform.radio_button_for(identifier)
253
+ block ? block.call(browser) : platform.radio_button_for(identifier.clone)
247
254
  end
248
255
  end
249
256
 
@@ -256,10 +263,11 @@ module PageObject
256
263
  # # will generate 'purchase' and 'purchase_button' methods
257
264
  #
258
265
  # @param [String] the name used for the generated methods
259
- # @param [Hash] identifier how we find a button. The valid keys are:
266
+ # @param [Hash] identifier how we find a button. You can use a multiple paramaters
267
+ # by combining of any of the following except xpath. The valid keys are:
260
268
  # * :class => Watir and Selenium
261
269
  # * :id => Watir and Selenium
262
- # * :index => Watir only
270
+ # * :index => Watir and Selenium
263
271
  # * :name => Watir and Selenium
264
272
  # * :text => Watir only
265
273
  # * :xpath => Watir and Selenium
@@ -267,10 +275,10 @@ module PageObject
267
275
  #
268
276
  def button(name, identifier=nil, &block)
269
277
  define_method(name) do
270
- platform.click_button_for identifier
278
+ platform.click_button_for identifier.clone
271
279
  end
272
280
  define_method("#{name}_button") do
273
- block ? block.call(browser) : platform.button_for(identifier)
281
+ block ? block.call(browser) : platform.button_for(identifier.clone)
274
282
  end
275
283
  end
276
284
 
@@ -283,20 +291,21 @@ module PageObject
283
291
  # # will generate 'message' and 'message_div' methods
284
292
  #
285
293
  # @param [String] the name used for the generated methods
286
- # @param [Hash] identifier how we find a div. The valid keys are:
294
+ # @param [Hash] identifier how we find a div. You can use a multiple paramaters
295
+ # by combining of any of the following except xpath. The valid keys are:
287
296
  # * :class => Watir and Selenium
288
297
  # * :id => Watir and Selenium
289
- # * :index => Watir only
290
- # * :name => Selenium only
298
+ # * :index => Watir and Selenium
299
+ # * :name => Watir and Selenium
291
300
  # * :xpath => Watir and Selenium
292
301
  # @param optional block to be invoked when element method is called
293
302
  #
294
303
  def div(name, identifier=nil, &block)
295
304
  define_method(name) do
296
- platform.div_text_for identifier
305
+ platform.div_text_for identifier.clone
297
306
  end
298
307
  define_method("#{name}_div") do
299
- block ? block.call(browser) : platform.div_for(identifier)
308
+ block ? block.call(browser) : platform.div_for(identifier.clone)
300
309
  end
301
310
  end
302
311
 
@@ -309,20 +318,21 @@ module PageObject
309
318
  # # will generate 'alert' and 'alert_span' methods
310
319
  #
311
320
  # @param [String] the name used for the generated methods
312
- # @param [Hash] identifier how we find a span. The valid keys are:
321
+ # @param [Hash] identifier how we find a span. You can use a multiple paramaters
322
+ # by combining of any of the following except xpath. The valid keys are:
313
323
  # * :class => Watir and Selenium
314
324
  # * :id => Watir and Selenium
315
- # * :index => Watir only
316
- # * :name => Selenium only
325
+ # * :index => Watir and Selenium
326
+ # * :name => Watir and Selenium
317
327
  # * :xpath => Watir and Selenium
318
328
  # @param optional block to be invoked when element method is called
319
329
  #
320
330
  def span(name, identifier=nil, &block)
321
331
  define_method(name) do
322
- platform.span_text_for identifier
332
+ platform.span_text_for identifier.clone
323
333
  end
324
334
  define_method("#{name}_span") do
325
- block ? block.call(browser) : platform.span_for(identifier)
335
+ block ? block.call(browser) : platform.span_for(identifier.clone)
326
336
  end
327
337
  end
328
338
 
@@ -334,17 +344,18 @@ module PageObject
334
344
  # # will generate a 'cart_table' method
335
345
  #
336
346
  # @param [String] the name used for the generated methods
337
- # @param [Hash] identifier how we find a table. The valid keys are:
347
+ # @param [Hash] identifier how we find a table. You can use a multiple paramaters
348
+ # by combining of any of the following except xpath. The valid keys are:
338
349
  # * :class => Watir and Selenium
339
350
  # * :id => Watir and Selenium
340
- # * :index => Watir only
341
- # * :name => Selenium only
351
+ # * :index => Watir and Selenium
352
+ # * :name => Watir and Selenium
342
353
  # * :xpath => Watir and Selenium
343
354
  # @param optional block to be invoked when element method is called
344
355
  #
345
356
  def table(name, identifier=nil, &block)
346
357
  define_method("#{name}_table") do
347
- block ? block.call(browser) : platform.table_for(identifier)
358
+ block ? block.call(browser) : platform.table_for(identifier.clone)
348
359
  end
349
360
  end
350
361
 
@@ -357,20 +368,21 @@ module PageObject
357
368
  # # will generate 'total' and 'total_cell' methods
358
369
  #
359
370
  # @param [String] the name used for the generated methods
360
- # @param [Hash] identifier how we find a cell. The valid keys are:
371
+ # @param [Hash] identifier how we find a cell. You can use a multiple paramaters
372
+ # by combining of any of the following except xpath. The valid keys are:
361
373
  # * :class => Watir and Selenium
362
374
  # * :id => Watir and Selenium
363
375
  # * :index => Watir only
364
- # * :name => Selenium only
376
+ # * :name => Watir and Selenium
365
377
  # * :xpath => Watir and Selenium
366
378
  # @param optional block to be invoked when element method is called
367
379
  #
368
380
  def cell(name, identifier=nil, &block)
369
381
  define_method("#{name}") do
370
- platform.cell_text_for identifier
382
+ platform.cell_text_for identifier.clone
371
383
  end
372
384
  define_method("#{name}_cell") do
373
- block ? block.call(browser) : platform.cell_for(identifier)
385
+ block ? block.call(browser) : platform.cell_for(identifier.clone)
374
386
  end
375
387
  end
376
388
 
@@ -382,17 +394,18 @@ module PageObject
382
394
  # # will generate a 'logo_image' method
383
395
  #
384
396
  # @param [String] the name used for the generated methods
385
- # @param [Hash] identifier how we find an image. The valid keys are:
397
+ # @param [Hash] identifier how we find an image. You can use a multiple paramaters
398
+ # by combining of any of the following except xpath. The valid keys are:
386
399
  # * :class => Watir and Selenium
387
400
  # * :id => Watir and Selenium
388
- # * :index => Watir only
401
+ # * :index => Watir and Selenium
389
402
  # * :name => Watir and Selenium
390
403
  # * :xpath => Watir and Selenium
391
404
  # @param optional block to be invoked when element method is called
392
405
  #
393
406
  def image(name, identifier=nil, &block)
394
407
  define_method("#{name}_image") do
395
- block ? block.call(browser) : platform.image_for(identifier)
408
+ block ? block.call(browser) : platform.image_for(identifier.clone)
396
409
  end
397
410
  end
398
411
 
@@ -404,16 +417,17 @@ module PageObject
404
417
  # # will generate a 'login_form' method
405
418
  #
406
419
  # @param [String] the name used for the generated methods
407
- # @param [Hash] identifier how we find a form. The valid keys are:
420
+ # @param [Hash] identifier how we find a form. You can use a multiple paramaters
421
+ # by combining of any of the following except xpath. The valid keys are:
408
422
  # * :class => Watir and Selenium
409
423
  # * :id => Watir and Selenium
410
- # * :index => Watir only
424
+ # * :index => Watir and Selenium
411
425
  # * :xpath => Watir and Selenium
412
426
  # @param optional block to be invoked when element method is called
413
427
  #
414
428
  def form(name, identifier=nil, &block)
415
429
  define_method("#{name}_form") do
416
- block ? block.call(browser) : platform.form_for(identifier)
430
+ block ? block.call(browser) : platform.form_for(identifier.clone)
417
431
  end
418
432
  end
419
433
 
@@ -426,20 +440,21 @@ module PageObject
426
440
  # # will generate 'item_one' and 'item_one_list_item' methods
427
441
  #
428
442
  # @param [String] the name used for the generated methods
429
- # @param [Hash] identifier how we find a list item. The valid keys are:
443
+ # @param [Hash] identifier how we find a list item. You can use a multiple paramaters
444
+ # by combining of any of the following except xpath. The valid keys are:
430
445
  # * :class => Watir and Selenium
431
446
  # * :id => Watir and Selenium
432
- # * :index => Watir only
433
- # * :name => Selenium only
447
+ # * :index => Watir and Selenium
448
+ # * :name => Watir and Selenium
434
449
  # * :xpath => Watir and Selenium
435
450
  # @param optional block to be invoked when element method is called
436
451
  #
437
452
  def list_item(name, identifier=nil, &block)
438
453
  define_method(name) do
439
- platform.list_item_text_for identifier
454
+ platform.list_item_text_for identifier.clone
440
455
  end
441
456
  define_method("#{name}_list_item") do
442
- block ? block.call(browser) : platform.list_item_for(identifier)
457
+ block ? block.call(browser) : platform.list_item_for(identifier.clone)
443
458
  end
444
459
  end
445
460
 
@@ -451,17 +466,18 @@ module PageObject
451
466
  # # will generate a 'menu_unordered_list' method
452
467
  #
453
468
  # @param [String] the name used for the generated methods
454
- # @param [Hash] identifier how we find an unordered list. The valid keys are:
469
+ # @param [Hash] identifier how we find an unordered list. You can use a multiple paramaters
470
+ # by combining of any of the following except xpath. The valid keys are:
455
471
  # * :class => Watir and Selenium
456
472
  # * :id => Watir and Selenium
457
- # * :index => Watir only
458
- # * :name => Selenium only
473
+ # * :index => Watir and Selenium
474
+ # * :name => Watir and Selenium
459
475
  # * :xpath => Watir and Selenium
460
476
  # @param optional block to be invoked when element method is called
461
477
  #
462
478
  def unordered_list(name, identifier=nil, &block)
463
479
  define_method("#{name}_unordered_list") do
464
- block ? block.call(browser) : platform.unordered_list_for(identifier)
480
+ block ? block.call(browser) : platform.unordered_list_for(identifier.clone)
465
481
  end
466
482
  end
467
483
 
@@ -473,17 +489,18 @@ module PageObject
473
489
  # # will generate a 'top_five_ordered_list' method
474
490
  #
475
491
  # @param [String] the name used for the generated methods
476
- # @param [Hash] identifier how we find an unordered list. The valid keys are:
492
+ # @param [Hash] identifier how we find an ordered list. You can use a multiple paramaters
493
+ # by combining of any of the following except xpath. The valid keys are:
477
494
  # * :class => Watir and Selenium
478
495
  # * :id => Watir and Selenium
479
- # * :index => Watir only
480
- # * :name => Selenium only
496
+ # * :index => Watir and Selenium
497
+ # * :name => Watir and Selenium
481
498
  # * :xpath => Watir and Selenium
482
499
  # @param optional block to be invoked when element method is called
483
500
  #
484
501
  def ordered_list(name, identifier=nil, &block)
485
502
  define_method("#{name}_ordered_list") do
486
- block ? block.call(browser) : platform.ordered_list_for(identifier)
503
+ block ? block.call(browser) : platform.ordered_list_for(identifier.clone)
487
504
  end
488
505
  end
489
506
  end