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
@@ -119,7 +119,7 @@ When /^I search for the radio button by "([^"]*)" and "([^"]*)"$/ do |param1, pa
|
|
119
119
|
@how = "#{param1}_#{param2}"
|
120
120
|
end
|
121
121
|
|
122
|
-
When /^I select the radio button$/ do
|
122
|
+
When /^I select the radio button$/ do
|
123
123
|
@page.send "select_milk_#{@how}".to_sym
|
124
124
|
end
|
125
125
|
|
@@ -217,7 +217,7 @@ Then /^I should see the hidden field contains "([^\"]*)"$/ do |text|
|
|
217
217
|
end
|
218
218
|
|
219
219
|
When /^I search for the hidden field by "([^\"]*)"$/ do |how|
|
220
|
-
|
220
|
+
@element = @page.send "hidden_field_#{how}_hidden_field"
|
221
221
|
end
|
222
222
|
|
223
223
|
Then /^hidden field element should contains "([^\"]*)"$/ do |text|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class FramePage
|
2
|
+
include PageObject
|
3
|
+
end
|
4
|
+
|
5
|
+
Given /^I am on the frame elements page$/ do
|
6
|
+
@page = FramePage.new(@browser)
|
7
|
+
@page.navigate_to(UrlHelper.frame_elements)
|
8
|
+
end
|
9
|
+
|
10
|
+
When /^I switch to a frame using id "([^"]*)"$/ do |id|
|
11
|
+
@page.switch_to_frame(id)
|
12
|
+
end
|
13
|
+
|
14
|
+
Then /^I should see "([^"]*)" in the frame$/ do |text|
|
15
|
+
@page.text.should include text
|
16
|
+
end
|
17
|
+
|
18
|
+
When /^I switch to a frame using index "([^"]*)"$/ do |index|
|
19
|
+
@page.switch_to_frame(index.to_i)
|
20
|
+
end
|
21
|
+
|
@@ -1,6 +1,5 @@
|
|
1
|
-
|
2
1
|
Then /^the page should contain the text "([^\"]*)"$/ do |text|
|
3
|
-
@page.text.should include text
|
2
|
+
@page.text.should include text
|
4
3
|
end
|
5
4
|
|
6
5
|
Then /^the page should contain the html "([^\"]*)"$/ do |html|
|
@@ -49,3 +48,26 @@ Then /^I should be able to get the message and default value$/ do
|
|
49
48
|
@msg[:default_value].should == 'John Doe'
|
50
49
|
end
|
51
50
|
|
51
|
+
When /^I open a second window$/ do
|
52
|
+
@page.open_window
|
53
|
+
end
|
54
|
+
|
55
|
+
class SecondPage
|
56
|
+
include PageObject
|
57
|
+
end
|
58
|
+
|
59
|
+
Then /^I should be able to attach to a page object using title$/ do
|
60
|
+
@second_page = SecondPage.new(@browser)
|
61
|
+
@second_page.attach_to_window(:title => "Success")
|
62
|
+
end
|
63
|
+
|
64
|
+
Then /^I should be able to attach to a page object using url$/ do
|
65
|
+
@second_page = SecondPage.new(@browser)
|
66
|
+
@second_page.attach_to_window(:url => "success.html")
|
67
|
+
end
|
68
|
+
|
69
|
+
Then /^I should be able to refresh the page$/ do
|
70
|
+
@page.refresh
|
71
|
+
end
|
72
|
+
|
73
|
+
|
data/features/support/env.rb
CHANGED
@@ -6,13 +6,27 @@ require 'selenium-webdriver'
|
|
6
6
|
|
7
7
|
require 'page-object'
|
8
8
|
|
9
|
+
|
10
|
+
|
9
11
|
Before do
|
10
|
-
@browser =
|
11
|
-
@browser = Selenium::WebDriver.for :firefox if ENV['DRIVER'] == 'SELENIUM'
|
12
|
+
@browser = PageObject::PersistantBrowser.get_browser
|
12
13
|
end
|
13
|
-
|
14
|
-
|
15
|
-
@browser.close
|
14
|
+
at_exit do
|
15
|
+
PageObject::PersistantBrowser.quit
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
module PageObject
|
19
|
+
module PersistantBrowser
|
20
|
+
@@browser = false
|
21
|
+
def self.get_browser
|
22
|
+
if !@@browser
|
23
|
+
@@browser = Watir::Browser.new :firefox if ENV['DRIVER'] == 'WATIR'
|
24
|
+
@@browser = Selenium::WebDriver.for :firefox if ENV['DRIVER'] == 'SELENIUM'
|
25
|
+
end
|
26
|
+
return @@browser
|
27
|
+
end
|
28
|
+
def self.quit
|
29
|
+
@@browser.quit
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/features/support/page.rb
CHANGED
@@ -50,7 +50,7 @@ class Page
|
|
50
50
|
link(:google_search_href, :href => "success.html")
|
51
51
|
link(:google_search_text, :text => "Google Search")
|
52
52
|
link(:google_search_index, :index => 0)
|
53
|
-
|
53
|
+
|
54
54
|
select_list(:sel_list_id, :id => "sel_list_id")
|
55
55
|
select_list(:sel_list_class, :class => "sel_list_class")
|
56
56
|
select_list(:sel_list_index, :index => 0)
|
@@ -76,17 +76,18 @@ class Page
|
|
76
76
|
radio_button(:milk_xpath, :xpath => "//input[@type='radio']")
|
77
77
|
radio_button(:milk_class_index, :class => "milk_class", :index => 0)
|
78
78
|
radio_button(:milk_name_index, :name => "milk_name", :index => 0)
|
79
|
-
|
79
|
+
|
80
80
|
radio_button(:butter_id, :id => 'butter_id')
|
81
|
-
|
81
|
+
|
82
82
|
div(:div_id, :id => 'div_id')
|
83
83
|
div(:div_name, :name => 'div_name')
|
84
84
|
div(:div_class, :class => 'div_class')
|
85
|
+
div(:div_text, :text => 'page-object rocks!')
|
85
86
|
div(:div_index, :index => 0)
|
86
87
|
div(:div_xpath, :xpath => '//div')
|
87
88
|
div(:div_class_index, :class => "div_class", :index => 0)
|
88
89
|
div(:div_name_index, :name => "div_name", :index => 0)
|
89
|
-
|
90
|
+
|
90
91
|
span(:span_id, :id => 'span_id')
|
91
92
|
span(:span_name, :name => 'span_name')
|
92
93
|
span(:span_class, :class => 'span_class')
|
@@ -94,7 +95,7 @@ class Page
|
|
94
95
|
span(:span_xpath, :xpath => '//span')
|
95
96
|
span(:span_class_index, :class => "span_class", :index => 0)
|
96
97
|
span(:span_name_index, :name => "span_name", :index => 0)
|
97
|
-
|
98
|
+
|
98
99
|
table(:table_id, :id => 'table_id')
|
99
100
|
table(:table_name, :name => 'table_name')
|
100
101
|
table(:table_class, :class => 'table_class')
|
@@ -102,7 +103,7 @@ class Page
|
|
102
103
|
table(:table_xpath, :xpath => '//table')
|
103
104
|
table(:table_class_index, :class => "table_class", :index => 0)
|
104
105
|
table(:table_name_index, :name => "table_name", :index => 0)
|
105
|
-
|
106
|
+
|
106
107
|
cell(:cell_id, :id => 'cell_id')
|
107
108
|
cell(:cell_name, :name => 'cell_name')
|
108
109
|
cell(:cell_class, :class => 'cell_class')
|
@@ -110,7 +111,7 @@ class Page
|
|
110
111
|
cell(:cell_xpath, :xpath => '//table//tr[2]//td[2]')
|
111
112
|
cell(:cell_class_index, :class => "cell_class", :index => 0)
|
112
113
|
cell(:cell_name_index, :name => "cell_name", :index => 0)
|
113
|
-
|
114
|
+
|
114
115
|
button(:button_id, :id => 'button_id')
|
115
116
|
button(:button_name, :name => 'button_name')
|
116
117
|
button(:button_class, :class => 'button_class')
|
@@ -119,7 +120,7 @@ class Page
|
|
119
120
|
button(:button_text, :text => 'Click Me')
|
120
121
|
button(:button_class_index, :class => "button_class", :index => 0)
|
121
122
|
button(:button_name_index, :name => "button_name", :index => 0)
|
122
|
-
|
123
|
+
|
123
124
|
image(:image_id, :id => 'image_id')
|
124
125
|
image(:image_name, :name => 'image_name')
|
125
126
|
image(:image_class, :class => 'image_class')
|
@@ -135,7 +136,7 @@ class Page
|
|
135
136
|
form(:form_xpath, :xpath => '//form')
|
136
137
|
form(:form_class_index, :class => "form_class", :index => 0)
|
137
138
|
form(:form_name_index, :name => "form_name", :index => 0)
|
138
|
-
|
139
|
+
|
139
140
|
list_item(:li_id, :id => 'li_id')
|
140
141
|
list_item(:li_name, :name => 'li_name')
|
141
142
|
list_item(:li_class, :class => 'li_class')
|
@@ -143,7 +144,7 @@ class Page
|
|
143
144
|
list_item(:li_xpath, :xpath => '//li[1]')
|
144
145
|
list_item(:li_class_index, :class => "li_class", :index => 0)
|
145
146
|
list_item(:li_name_index, :name => "li_name", :index => 0)
|
146
|
-
|
147
|
+
|
147
148
|
unordered_list(:ul_id, :id => 'ul_id')
|
148
149
|
unordered_list(:ul_name, :name => 'ul_name')
|
149
150
|
unordered_list(:ul_class, :class => 'ul_class')
|
@@ -159,8 +160,10 @@ class Page
|
|
159
160
|
ordered_list(:ol_xpath, :xpath => '//ol')
|
160
161
|
ordered_list(:ol_class_index, :class => "ol_class", :index => 0)
|
161
162
|
ordered_list(:ol_name_index, :name => "ol_name", :index => 0)
|
162
|
-
|
163
|
+
|
163
164
|
button(:alert_button, :id => 'alert_button')
|
164
165
|
button(:confirm_button, :id => 'confirm_button')
|
165
166
|
button(:prompt_button, :id => 'prompt_button')
|
167
|
+
|
168
|
+
link(:open_window, :text => 'New Window')
|
166
169
|
end
|
data/features/table.feature
CHANGED
@@ -2,19 +2,19 @@ Feature: Table
|
|
2
2
|
In order to interact with tables
|
3
3
|
Testers will need access and interrogation ability
|
4
4
|
|
5
|
-
|
5
|
+
|
6
6
|
Background:
|
7
7
|
Given I am on the static elements page
|
8
|
-
|
8
|
+
|
9
9
|
Scenario: Retrieve a table
|
10
10
|
When I retrieve a table element
|
11
11
|
Then I should know it is visible
|
12
|
-
|
12
|
+
|
13
13
|
@watir_only
|
14
14
|
Scenario: Determine if a table exists
|
15
15
|
When I retrieve a table element
|
16
16
|
Then I should know it exists
|
17
|
-
|
17
|
+
|
18
18
|
Scenario: Retrieve the data from a table
|
19
19
|
When I retrieve a table element
|
20
20
|
Then the data for row "1" should be "Data1" and "Data2"
|
@@ -23,7 +23,7 @@ Feature: Table
|
|
23
23
|
And each row should contain "Data"
|
24
24
|
And row "1" should have "2" columns
|
25
25
|
And each column should contain "Data"
|
26
|
-
|
26
|
+
|
27
27
|
Scenario Outline: Locating table cells on the Page
|
28
28
|
When I retrieve a table element by "<search_by>"
|
29
29
|
Then the data for row "1" should be "Data1" and "Data2"
|
@@ -32,7 +32,7 @@ Feature: Table
|
|
32
32
|
| search_by |
|
33
33
|
| id |
|
34
34
|
| class |
|
35
|
-
| xpath |
|
35
|
+
| xpath |
|
36
36
|
| index |
|
37
37
|
| name |
|
38
38
|
|
@@ -41,6 +41,6 @@ Feature: Table
|
|
41
41
|
Then the data for row "1" should be "Data1" and "Data2"
|
42
42
|
|
43
43
|
Scenarios:
|
44
|
-
| param1
|
45
|
-
| class
|
46
|
-
| name
|
44
|
+
| param1 | param2 |
|
45
|
+
| class | index |
|
46
|
+
| name | index |
|
data/features/table_cell.feature
CHANGED
@@ -7,7 +7,7 @@ Feature: Table Cell
|
|
7
7
|
Scenario: Retrieving the text from a table cell
|
8
8
|
When I retrieve the data from the table cell
|
9
9
|
Then the cell data should be 'Data4'
|
10
|
-
|
10
|
+
|
11
11
|
Scenario Outline: Locating table cells on the Page
|
12
12
|
When I search for the table cell by "<search_by>"
|
13
13
|
Then the cell data should be 'Data4'
|
@@ -16,9 +16,9 @@ Feature: Table Cell
|
|
16
16
|
| search_by |
|
17
17
|
| id |
|
18
18
|
| class |
|
19
|
-
| xpath |
|
19
|
+
| xpath |
|
20
20
|
| name |
|
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>"
|
@@ -33,7 +33,7 @@ Feature: Table Cell
|
|
33
33
|
Then the cell data should be 'Data4'
|
34
34
|
|
35
35
|
Scenarios:
|
36
|
-
| param1
|
37
|
-
| class
|
38
|
-
| name
|
36
|
+
| param1 | param2 |
|
37
|
+
| class | index |
|
38
|
+
| name | index |
|
39
39
|
|
data/features/text_area.feature
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
Feature: Text Area
|
2
2
|
|
3
|
-
|
3
|
+
|
4
4
|
Background:
|
5
5
|
Given I am on the static elements page
|
6
|
-
|
6
|
+
|
7
7
|
Scenario: Setting and getting a value from a text area
|
8
8
|
When I type "abcdefghijklmnop" into the text area
|
9
9
|
Then the text area should contain "abcdefghijklmnop"
|
@@ -17,7 +17,7 @@ Feature: Text Area
|
|
17
17
|
| id |
|
18
18
|
| class |
|
19
19
|
| name |
|
20
|
-
| xpath |
|
20
|
+
| xpath |
|
21
21
|
| css |
|
22
22
|
| tag_name |
|
23
23
|
| index |
|
@@ -28,6 +28,6 @@ Feature: Text Area
|
|
28
28
|
Then I should be able to type "I found it" into the area
|
29
29
|
|
30
30
|
Scenarios:
|
31
|
-
| param1
|
32
|
-
| class
|
33
|
-
| name
|
31
|
+
| param1 | param2 |
|
32
|
+
| class | index |
|
33
|
+
| name | index |
|
data/features/text_field.feature
CHANGED
@@ -2,10 +2,10 @@ Feature: Text Fields
|
|
2
2
|
In order to interact with text fields
|
3
3
|
Testers will need access and interrogation ability
|
4
4
|
|
5
|
-
|
5
|
+
|
6
6
|
Background:
|
7
7
|
Given I am on the static elements page
|
8
|
-
|
8
|
+
|
9
9
|
Scenario: Setting and getting a value from a text field
|
10
10
|
When I type "abcDEF" into the text field
|
11
11
|
Then the text field should contain "abcDEF"
|
@@ -19,19 +19,19 @@ Feature: Text Fields
|
|
19
19
|
| id |
|
20
20
|
| class |
|
21
21
|
| name |
|
22
|
-
| xpath |
|
22
|
+
| xpath |
|
23
23
|
| css |
|
24
24
|
| tag_name |
|
25
25
|
| index |
|
26
|
-
|
26
|
+
|
27
27
|
Scenario Outline: Locating a text field using multiple parameters
|
28
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
|
-
| param1
|
33
|
-
| class
|
34
|
-
| name
|
32
|
+
| param1 | param2 |
|
33
|
+
| class | index |
|
34
|
+
| name | index |
|
35
35
|
|
36
36
|
Scenario: Retrieve a text field
|
37
37
|
When I retrieve a text field
|
@@ -2,7 +2,7 @@ Feature: Unordered list
|
|
2
2
|
|
3
3
|
Background:
|
4
4
|
Given I am on the static elements page
|
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
8
|
Then the list items text should be "Item One"
|
@@ -13,12 +13,12 @@ Feature: Unordered list
|
|
13
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
|
+
|
17
17
|
Scenarios:
|
18
18
|
| search_by |
|
19
19
|
| id |
|
20
20
|
| class |
|
21
|
-
| xpath |
|
21
|
+
| xpath |
|
22
22
|
| index |
|
23
23
|
| name |
|
24
24
|
|
@@ -28,6 +28,6 @@ Feature: Unordered list
|
|
28
28
|
Then the list items text should be "Item One"
|
29
29
|
|
30
30
|
Scenarios:
|
31
|
-
| param1
|
32
|
-
| class
|
33
|
-
| name
|
31
|
+
| param1 | param2 |
|
32
|
+
| class | index |
|
33
|
+
| name | index |
|
data/lib/page-object.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
2
1
|
require 'page-object/version'
|
3
2
|
require 'page-object/accessors'
|
3
|
+
require 'page-object/platforms'
|
4
4
|
|
5
5
|
#
|
6
6
|
# Module that when included adds functionality to a page object. This module
|
@@ -31,6 +31,7 @@ require 'page-object/accessors'
|
|
31
31
|
# @see PageObject::Accessors to see what class level methods are added to this module at runtime.
|
32
32
|
#
|
33
33
|
module PageObject
|
34
|
+
include LoadsPlatform
|
34
35
|
# @return [Watir::Browser or Selenium::WebDriver::Driver] the platform browser passed to the constructor
|
35
36
|
attr_reader :browser
|
36
37
|
# @return [PageObject::WatirPageObject or PageObject::SeleniumPageObject] the platform page object
|
@@ -52,7 +53,7 @@ module PageObject
|
|
52
53
|
def self.included(cls)
|
53
54
|
cls.extend PageObject::Accessors
|
54
55
|
end
|
55
|
-
|
56
|
+
|
56
57
|
#
|
57
58
|
# navigate to the provided url
|
58
59
|
#
|
@@ -61,7 +62,7 @@ module PageObject
|
|
61
62
|
def navigate_to(url)
|
62
63
|
platform.navigate_to(url)
|
63
64
|
end
|
64
|
-
|
65
|
+
|
65
66
|
#
|
66
67
|
# Returns the text of the current page
|
67
68
|
#
|
@@ -82,7 +83,7 @@ module PageObject
|
|
82
83
|
def title
|
83
84
|
platform.title
|
84
85
|
end
|
85
|
-
|
86
|
+
|
86
87
|
#
|
87
88
|
# Wait until the block returns true or times out
|
88
89
|
#
|
@@ -98,7 +99,7 @@ module PageObject
|
|
98
99
|
def wait_until(timeout = 30, message = nil, &block)
|
99
100
|
platform.wait_until(timeout, message, &block)
|
100
101
|
end
|
101
|
-
|
102
|
+
|
102
103
|
#
|
103
104
|
# Override the normal alert popup so it does not occurr.
|
104
105
|
#
|
@@ -113,7 +114,7 @@ module PageObject
|
|
113
114
|
def alert(&block)
|
114
115
|
platform.alert(&block)
|
115
116
|
end
|
116
|
-
|
117
|
+
|
117
118
|
#
|
118
119
|
# Override the normal confirm popup so it does not occurr.
|
119
120
|
#
|
@@ -129,7 +130,7 @@ module PageObject
|
|
129
130
|
def confirm(response, &block)
|
130
131
|
platform.confirm(response, &block)
|
131
132
|
end
|
132
|
-
|
133
|
+
|
133
134
|
#
|
134
135
|
# Override the normal promp popup so it does not occurr.
|
135
136
|
#
|
@@ -146,18 +147,41 @@ module PageObject
|
|
146
147
|
def prompt(answer, &block)
|
147
148
|
platform.prompt(answer, &block)
|
148
149
|
end
|
150
|
+
|
151
|
+
#
|
152
|
+
# Attach to a running window. You can locate the window using either
|
153
|
+
# the window's title or url.
|
154
|
+
#
|
155
|
+
# @example
|
156
|
+
# page.attach_to_window(:title => "other window's title")
|
157
|
+
#
|
158
|
+
# @param [Hash] either :title or :url of the other window. The url does not need to
|
159
|
+
# be the entire url - it can just be the page name like index.html
|
160
|
+
#
|
161
|
+
def attach_to_window(identifier)
|
162
|
+
platform.attach_to_window(identifier)
|
163
|
+
end
|
164
|
+
|
165
|
+
#
|
166
|
+
# Switch to a frame within the current context.
|
167
|
+
#
|
168
|
+
# @param [String or Fixnum] you can pass the index (zero based) or id for the frame
|
169
|
+
# you wish to switch to.
|
170
|
+
#
|
171
|
+
def switch_to_frame(identifier)
|
172
|
+
platform.switch_to_frame identifier
|
173
|
+
end
|
174
|
+
|
175
|
+
#
|
176
|
+
# Refresh to current page
|
177
|
+
#
|
178
|
+
def refresh
|
179
|
+
platform.refresh
|
180
|
+
end
|
149
181
|
|
150
182
|
private
|
151
183
|
|
152
184
|
def include_platform_driver(browser)
|
153
|
-
|
154
|
-
require 'page-object/watir_page_object'
|
155
|
-
@platform = PageObject::WatirPageObject.new(browser)
|
156
|
-
elsif browser.is_a? Selenium::WebDriver::Driver
|
157
|
-
require 'page-object/selenium_page_object'
|
158
|
-
@platform = PageObject::SeleniumPageObject.new(browser)
|
159
|
-
else
|
160
|
-
raise ArgumentError, "expect Watir::Browser or Selenium::WebDriver::Driver"
|
161
|
-
end
|
185
|
+
@platform = load_platform(browser, PageObject::Platforms.get)
|
162
186
|
end
|
163
187
|
end
|