page-object 0.5.3 → 0.5.4
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.
- data/ChangeLog +10 -1
- data/features/async.feature +11 -4
- data/features/file_field.feature +30 -0
- data/features/form.feature +1 -0
- data/features/html/async.html +21 -0
- data/features/html/nested_elements.html +3 -1
- data/features/html/static_elements.html +4 -2
- data/features/image.feature +2 -0
- data/features/nested_elements.feature +4 -0
- data/features/step_definitions/async_steps.rb +31 -0
- data/features/step_definitions/file_field_steps.rb +19 -0
- data/features/step_definitions/nested_elements_steps.rb +16 -7
- data/features/support/page.rb +13 -0
- data/features/support/url_helper.rb +4 -0
- data/features/text_field.feature +3 -2
- data/lib/page-object/accessors.rb +35 -1
- data/lib/page-object/element_locators.rb +19 -1
- data/lib/page-object/elements.rb +1 -0
- data/lib/page-object/elements/element.rb +20 -0
- data/lib/page-object/elements/file_field.rb +35 -0
- data/lib/page-object/elements/form.rb +8 -0
- data/lib/page-object/elements/image.rb +8 -0
- data/lib/page-object/elements/text_field.rb +2 -2
- data/lib/page-object/nested_elements.rb +4 -0
- data/lib/page-object/page_populator.rb +2 -2
- data/lib/page-object/platforms/selenium_webdriver/check_box.rb +2 -2
- data/lib/page-object/platforms/selenium_webdriver/element.rb +19 -14
- data/lib/page-object/platforms/selenium_webdriver/file_field.rb +16 -0
- data/lib/page-object/platforms/selenium_webdriver/page_object.rb +30 -2
- data/lib/page-object/platforms/watir_webdriver/element.rb +19 -14
- data/lib/page-object/platforms/watir_webdriver/file_field.rb +16 -0
- data/lib/page-object/platforms/watir_webdriver/page_object.rb +22 -1
- data/lib/page-object/version.rb +1 -1
- data/spec/page-object/accessors_spec.rb +45 -0
- data/spec/page-object/element_locators_spec.rb +7 -1
- data/spec/page-object/elements/element_spec.rb +1 -10
- data/spec/page-object/elements/file_field_spec.rb +35 -0
- data/spec/page-object/elements/image_spec.rb +3 -3
- data/spec/page-object/elements/text_field_spec.rb +3 -3
- data/spec/page-object/page_populator_spec.rb +6 -0
- metadata +23 -12
data/ChangeLog
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
=== Version 0.5.
|
|
1
|
+
=== Version 0.5.4 / 2011-12-18
|
|
2
|
+
* Enhancements
|
|
3
|
+
* Added deprecation warning to the method_missing method on Element. This ability will be removed in 0.6
|
|
4
|
+
* Added full support for file_field element
|
|
5
|
+
* Added ability to find TextField by :title
|
|
6
|
+
* Added ability to find Form by :action
|
|
7
|
+
* Added ability to find Image by :alt
|
|
8
|
+
* Added ability to find Image by :src
|
|
9
|
+
|
|
10
|
+
=== Version 0.5.3 / 2011-12-11
|
|
2
11
|
* Enhancements
|
|
3
12
|
* Added new module PagePopulator with single method populate_page_with
|
|
4
13
|
* Updated to use selenium-webdriver 2.15.0
|
data/features/async.feature
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
Feature: Handling Asynch calls
|
|
2
2
|
|
|
3
|
-
Background:
|
|
4
|
-
Given I am on the static elements page
|
|
5
|
-
|
|
6
3
|
Scenario: Link element methods
|
|
4
|
+
Given I am on the static elements page
|
|
7
5
|
When I retrieve a link element
|
|
8
6
|
Then I should be able to wait until it is present
|
|
9
7
|
And I should be able to wait until it is visible
|
|
10
8
|
And I should be able to wait until it is not visible
|
|
11
|
-
And I should be able to wait until a block returns true
|
|
9
|
+
And I should be able to wait until a block returns true
|
|
10
|
+
|
|
11
|
+
Scenario: Click a button when it is visible
|
|
12
|
+
Given I am on the async elements page
|
|
13
|
+
When I make the button invisible
|
|
14
|
+
Then I should be able to click it when it becomses visible
|
|
15
|
+
|
|
16
|
+
Scenario: Wait until something is not visible
|
|
17
|
+
Given I am on the async elements page
|
|
18
|
+
Then I should be able to wait until the button becomes invisible
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Feature: File Field
|
|
2
|
+
|
|
3
|
+
Background:
|
|
4
|
+
Given I am on the static elements page
|
|
5
|
+
|
|
6
|
+
Scenario: Setting the value on the file field
|
|
7
|
+
When I set the file field to the step definition file
|
|
8
|
+
Then its' value should equal that file
|
|
9
|
+
|
|
10
|
+
Scenario Outline: Locating file fields on the Page
|
|
11
|
+
When I search for the file field by "<search_by>"
|
|
12
|
+
Then I should be able to set the file field
|
|
13
|
+
|
|
14
|
+
Examples:
|
|
15
|
+
| search_by |
|
|
16
|
+
| id |
|
|
17
|
+
| class |
|
|
18
|
+
| name |
|
|
19
|
+
| xpath |
|
|
20
|
+
| title |
|
|
21
|
+
| index |
|
|
22
|
+
|
|
23
|
+
Scenario Outline: Locating file fields using multiple parameters
|
|
24
|
+
When I search for the file field by "<param1>" and "<param2>"
|
|
25
|
+
Then I should be able to set the file field
|
|
26
|
+
|
|
27
|
+
Examples:
|
|
28
|
+
| param1 | param2 |
|
|
29
|
+
| class | index |
|
|
30
|
+
| name | index |
|
data/features/form.feature
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<title>Async Page</title>
|
|
4
|
+
<script type="text/javascript">
|
|
5
|
+
function unhide() {
|
|
6
|
+
document.getElementById("target").style.display="block";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function hide() {
|
|
10
|
+
document.getElementById("target").style.display="none";
|
|
11
|
+
}
|
|
12
|
+
</script>
|
|
13
|
+
</head>
|
|
14
|
+
<body>
|
|
15
|
+
<input type="button" id="target" value="Target"/>
|
|
16
|
+
<input type="button" onclick="setTimeout(function() {hide();}, 2000);" value="Hide Button"/>
|
|
17
|
+
<input type="button" onclick="setTimeout(function() {unhide();}, 2000);" value="Unhide Button"/>
|
|
18
|
+
</body>
|
|
19
|
+
</html>
|
|
20
|
+
|
|
21
|
+
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<p id='p_id' name='p_name' class='p_class'>Static Elements Page</p>
|
|
7
7
|
|
|
8
8
|
<input id="text_field_id" name="text_field_name" class="text_field_class"
|
|
9
|
-
size="40" type="text"/>
|
|
9
|
+
title="text_field_title" size="40" type="text"/>
|
|
10
10
|
|
|
11
11
|
<input id="hidden_field_id" name="hidden_field_name" class="hidden_field_class"
|
|
12
12
|
size="40" type="hidden" value="12345"/>
|
|
@@ -52,11 +52,13 @@
|
|
|
52
52
|
<input value="Disabled" disabled="true" type ="submit"/>
|
|
53
53
|
</form>
|
|
54
54
|
|
|
55
|
-
<img src="images/circle.png" id="image_id" name="image_name" class="image_class">
|
|
55
|
+
<img src="images/circle.png" id="image_id" name="image_name" class="image_class", alt="image_alt">
|
|
56
56
|
|
|
57
57
|
<form id="form_id" class="form_class" name="form_name" action="/">
|
|
58
58
|
</form>
|
|
59
59
|
|
|
60
|
+
<input type="file" name="file_field_name" id="file_field_id" class="file_field_class" title="file_field_title" />
|
|
61
|
+
|
|
60
62
|
<ul id="ul_id" name="ul_name" class="ul_class">
|
|
61
63
|
<li id="li_id" name="li_name" class="li_class">Item One</li>
|
|
62
64
|
<li>Item Two</li>
|
data/features/image.feature
CHANGED
|
@@ -26,6 +26,10 @@ Feature: Nested Elements
|
|
|
26
26
|
Scenario: Finding a select list within a div
|
|
27
27
|
When I search for a select list located in a div
|
|
28
28
|
Then I should be able to select "Test 2" in the nested select list
|
|
29
|
+
|
|
30
|
+
Scenario: Finding a file field within a div
|
|
31
|
+
When I search for a file field located in a div
|
|
32
|
+
Then I should be able to set the nested file field
|
|
29
33
|
|
|
30
34
|
Scenario: Finding a checkbox within a div
|
|
31
35
|
When I search for a checkbox located in a div
|
|
@@ -29,3 +29,34 @@ Then /^I should be able to wait until a block returns true$/ do
|
|
|
29
29
|
@element.visible?
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
|
+
|
|
33
|
+
class AsyncPage
|
|
34
|
+
include PageObject
|
|
35
|
+
button(:target, :value => 'Target')
|
|
36
|
+
button(:hide, :value => 'Hide Button')
|
|
37
|
+
button(:unhide, :value => 'Unhide Button')
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
Given /^I am on the async elements page$/ do
|
|
41
|
+
@page = AsyncPage.new(@browser)
|
|
42
|
+
@page.navigate_to(UrlHelper.async)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
When /^I make the button invisible$/ do
|
|
46
|
+
@page.hide
|
|
47
|
+
sleep 2
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
Then /^I should be able to click it when it becomses visible$/ do
|
|
51
|
+
@page.unhide
|
|
52
|
+
@page.target_element.when_visible do
|
|
53
|
+
@page.target
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
Then /^I should be able to wait until the button becomes invisible$/ do
|
|
58
|
+
@page.hide
|
|
59
|
+
@page.target_element.when_not_visible do
|
|
60
|
+
@page.target_element.attribute("block").should == "none"
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
When /^I set the file field to the step definition file$/ do
|
|
2
|
+
@page.file_field_id = __FILE__
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
Then /^its\' value should equal that file$/ do
|
|
6
|
+
@page.file_field_id_element.value.should == __FILE__
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
When /^I search for the file field by "([^\"]*)"$/ do |how|
|
|
10
|
+
@how = how
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
When /^I search for the file field by "([^\"]*)" and "([^\"]*)"$/ do |param1, param2|
|
|
14
|
+
@how = "#{param1}_#{param2}"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
Then /^I should be able to set the file field$/ do
|
|
18
|
+
@page.send "file_field_#{@how}=", __FILE__
|
|
19
|
+
end
|
|
@@ -26,6 +26,7 @@ class NestedElementsPage
|
|
|
26
26
|
h5(:nested_h5) { |page| page.outer_div_element.h5_element }
|
|
27
27
|
h6(:nested_h6) { |page| page.outer_div_element.h6_element }
|
|
28
28
|
paragraph(:nested_paragraph) { |page| page.outer_div_element.paragraph_element }
|
|
29
|
+
file_field(:nested_file_field) { |page| page.outer_div_element.file_field_element }
|
|
29
30
|
end
|
|
30
31
|
|
|
31
32
|
Given /^I am on the nested elements page$/ do
|
|
@@ -127,7 +128,7 @@ When /^I search the second table cell located in a table in a div$/ do
|
|
|
127
128
|
@cell = @page.nested_cell_element
|
|
128
129
|
end
|
|
129
130
|
|
|
130
|
-
Then /^the nested table cell should contain "([
|
|
131
|
+
Then /^the nested table cell should contain "([^\"]*)"$/ do |value|
|
|
131
132
|
@cell.text.should == value
|
|
132
133
|
end
|
|
133
134
|
|
|
@@ -135,11 +136,11 @@ When /^I search for an image located in a div$/ do
|
|
|
135
136
|
@image = @page.nested_image_element
|
|
136
137
|
end
|
|
137
138
|
|
|
138
|
-
Then /^the nested image should be "([
|
|
139
|
+
Then /^the nested image should be "([^\"]*)" pixels wide$/ do |width|
|
|
139
140
|
@image.width.should == width.to_i
|
|
140
141
|
end
|
|
141
142
|
|
|
142
|
-
Then /^the nested image should be "([
|
|
143
|
+
Then /^the nested image should be "([^\"]*)" pixels tall$/ do |height|
|
|
143
144
|
@image.height.should == height.to_i
|
|
144
145
|
end
|
|
145
146
|
|
|
@@ -155,7 +156,7 @@ When /^I search for an ordered list located in a div$/ do
|
|
|
155
156
|
@list = @page.nested_ordered_list_element
|
|
156
157
|
end
|
|
157
158
|
|
|
158
|
-
Then /^the first nested list items text should be "([
|
|
159
|
+
Then /^the first nested list items text should be "([^\"]*)"$/ do |value|
|
|
159
160
|
@list[0].text.should == value
|
|
160
161
|
end
|
|
161
162
|
|
|
@@ -167,7 +168,7 @@ When /^I search for a list item nested in an ordered list in a div$/ do
|
|
|
167
168
|
@li = @page.nested_list_item_element
|
|
168
169
|
end
|
|
169
170
|
|
|
170
|
-
Then /^I should see the nested list items text should be "([
|
|
171
|
+
Then /^I should see the nested list items text should be "([^\"]*)"$/ do |value|
|
|
171
172
|
@li.text.should == value
|
|
172
173
|
end
|
|
173
174
|
|
|
@@ -175,7 +176,7 @@ When /^I search for a h(\d+) located in a div$/ do |num|
|
|
|
175
176
|
@header = @page.send "nested_h#{num}_element"
|
|
176
177
|
end
|
|
177
178
|
|
|
178
|
-
Then /^I should see the nested h(\d+)s text should be "([
|
|
179
|
+
Then /^I should see the nested h(\d+)s text should be "([^\"]*)"$/ do |num, value|
|
|
179
180
|
@header.text.should == value
|
|
180
181
|
end
|
|
181
182
|
|
|
@@ -183,6 +184,14 @@ When /^I search for a paragraph located in a div$/ do
|
|
|
183
184
|
@para = @page.nested_paragraph_element
|
|
184
185
|
end
|
|
185
186
|
|
|
186
|
-
Then /^I should see the nested paragraphs text should be "([
|
|
187
|
+
Then /^I should see the nested paragraphs text should be "([^\"]*)"$/ do |value|
|
|
187
188
|
@para.text.should == value
|
|
188
189
|
end
|
|
190
|
+
|
|
191
|
+
When /^I search for a file field located in a div$/ do
|
|
192
|
+
@ff = @page.nested_file_field_element
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
Then /^I should be able to set the nested file field$/ do
|
|
196
|
+
@ff.value = __FILE__
|
|
197
|
+
end
|
data/features/support/page.rb
CHANGED
|
@@ -14,6 +14,7 @@ class Page
|
|
|
14
14
|
text_field(:text_field_index, :index => 0)
|
|
15
15
|
text_field(:text_field_text, :text => "")
|
|
16
16
|
text_field(:text_field_value, :value => "")
|
|
17
|
+
text_field(:text_field_title, :title => 'text_field_title')
|
|
17
18
|
text_field(:text_field_class_index, :class => "text_field_class", :index => 0)
|
|
18
19
|
text_field(:text_field_name_index, :name => "text_field_name", :index => 0)
|
|
19
20
|
|
|
@@ -145,6 +146,8 @@ class Page
|
|
|
145
146
|
image(:image_class, :class => 'image_class')
|
|
146
147
|
image(:image_index, :index => 0)
|
|
147
148
|
image(:image_xpath, :xpath => '//img')
|
|
149
|
+
image(:image_alt, :alt => 'image_alt')
|
|
150
|
+
image(:image_src, :src => 'images/circle.png')
|
|
148
151
|
image(:image_class_index, :class => "image_class", :index => 0)
|
|
149
152
|
image(:image_name_index, :name => "image_name", :index => 0)
|
|
150
153
|
|
|
@@ -153,6 +156,7 @@ class Page
|
|
|
153
156
|
form(:form_class, :class => 'form_class')
|
|
154
157
|
form(:form_index, :index => 0)
|
|
155
158
|
form(:form_xpath, :xpath => '//form')
|
|
159
|
+
form(:form_action, :action => "success.html")
|
|
156
160
|
form(:form_class_index, :class => "form_class", :index => 0)
|
|
157
161
|
form(:form_name_index, :name => "form_name", :index => 0)
|
|
158
162
|
|
|
@@ -239,6 +243,15 @@ class Page
|
|
|
239
243
|
button(:alert_button, :id => 'alert_button')
|
|
240
244
|
button(:confirm_button, :id => 'confirm_button')
|
|
241
245
|
button(:prompt_button, :id => 'prompt_button')
|
|
246
|
+
|
|
247
|
+
file_field(:file_field_id, :id => 'file_field_id')
|
|
248
|
+
file_field(:file_field_name, :name => 'file_field_name')
|
|
249
|
+
file_field(:file_field_class, :class => 'file_field_class')
|
|
250
|
+
file_field(:file_field_index, :index => 0)
|
|
251
|
+
file_field(:file_field_title, :title => 'file_field_title')
|
|
252
|
+
file_field(:file_field_class_index, :class => 'file_field_class', :index => 0)
|
|
253
|
+
file_field(:file_field_name_index, :name => 'file_field_name', :index => 0)
|
|
254
|
+
file_field(:file_field_xpath, :xpath => "//input[@type='file']")
|
|
242
255
|
|
|
243
256
|
link(:open_window, :text => 'New Window')
|
|
244
257
|
end
|
data/features/text_field.feature
CHANGED
|
@@ -14,7 +14,7 @@ Feature: Text Fields
|
|
|
14
14
|
When I search for the text field by "<search_by>"
|
|
15
15
|
Then I should be able to type "I found it" into the field
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
Examples:
|
|
18
18
|
| search_by |
|
|
19
19
|
| id |
|
|
20
20
|
| class |
|
|
@@ -23,12 +23,13 @@ Feature: Text Fields
|
|
|
23
23
|
| css |
|
|
24
24
|
| tag_name |
|
|
25
25
|
| index |
|
|
26
|
+
| title |
|
|
26
27
|
|
|
27
28
|
Scenario Outline: Locating a text field using multiple parameters
|
|
28
29
|
When I search for the text field by "<param1>" and "<param2>"
|
|
29
30
|
Then I should be able to type "I found it" into the field
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
Examples:
|
|
32
33
|
| param1 | param2 |
|
|
33
34
|
| class | index |
|
|
34
35
|
| name | index |
|
|
@@ -63,6 +63,7 @@ module PageObject
|
|
|
63
63
|
# * :name => Watir and Selenium
|
|
64
64
|
# * :tag_name => Watir and Selenium
|
|
65
65
|
# * :text => Watir only
|
|
66
|
+
# * :title => Watir and Selenium
|
|
66
67
|
# * :value => Watir only
|
|
67
68
|
# * :xpath => Watir and Selenium
|
|
68
69
|
# @param optional block to be invoked when element method is called
|
|
@@ -73,7 +74,7 @@ module PageObject
|
|
|
73
74
|
self.send("#{name}_element").value
|
|
74
75
|
end
|
|
75
76
|
define_method("#{name}=") do |value|
|
|
76
|
-
|
|
77
|
+
return platform.text_field_value_set(identifier.clone, value) unless block_given?
|
|
77
78
|
self.send("#{name}_element").value = value
|
|
78
79
|
end
|
|
79
80
|
define_method("#{name}_element") do
|
|
@@ -466,10 +467,12 @@ module PageObject
|
|
|
466
467
|
# @param [String] the name used for the generated methods
|
|
467
468
|
# @param [Hash] identifier how we find an image. You can use a multiple paramaters
|
|
468
469
|
# by combining of any of the following except xpath. The valid keys are:
|
|
470
|
+
# * :alt => Watir and Selenium
|
|
469
471
|
# * :class => Watir and Selenium
|
|
470
472
|
# * :id => Watir and Selenium
|
|
471
473
|
# * :index => Watir and Selenium
|
|
472
474
|
# * :name => Watir and Selenium
|
|
475
|
+
# * :src => Watir and Selenium
|
|
473
476
|
# * :xpath => Watir and Selenium
|
|
474
477
|
# @param optional block to be invoked when element method is called
|
|
475
478
|
#
|
|
@@ -491,6 +494,7 @@ module PageObject
|
|
|
491
494
|
# @param [String] the name used for the generated methods
|
|
492
495
|
# @param [Hash] identifier how we find a form. You can use a multiple paramaters
|
|
493
496
|
# by combining of any of the following except xpath. The valid keys are:
|
|
497
|
+
# * :action => Watir and Selenium
|
|
494
498
|
# * :class => Watir and Selenium
|
|
495
499
|
# * :id => Watir and Selenium
|
|
496
500
|
# * :index => Watir and Selenium
|
|
@@ -787,5 +791,35 @@ module PageObject
|
|
|
787
791
|
end
|
|
788
792
|
alias_method "#{name}_paragraph".to_sym, "#{name}_element".to_sym
|
|
789
793
|
end
|
|
794
|
+
|
|
795
|
+
#
|
|
796
|
+
# adds a method to set the file for a file field and to retrieve
|
|
797
|
+
# the file field element
|
|
798
|
+
#
|
|
799
|
+
# @example
|
|
800
|
+
# file_field(:the_file, :id => 'file_to_upload')
|
|
801
|
+
# # will generate a 'the_file=' and 'the_file_element' method
|
|
802
|
+
#
|
|
803
|
+
# @param [String] the name used for the generated methods
|
|
804
|
+
# @param [Hash] identifier how we find a file_field. You can use a multiple paramaters
|
|
805
|
+
# by combining of any of the following except xpath. The valid keys are:
|
|
806
|
+
# * :class => Watir and Selenium
|
|
807
|
+
# * :id => Watir and Selenium
|
|
808
|
+
# * :index => Watir and Selenium
|
|
809
|
+
# * :name => Watir and Selenium
|
|
810
|
+
# * :title => Watir and Selenium
|
|
811
|
+
# * :xpath => Watir and Selenium
|
|
812
|
+
# @param optional block to be invoked when element method is called
|
|
813
|
+
#
|
|
814
|
+
def file_field(name, identifier=nil, &block)
|
|
815
|
+
define_method("#{name}=") do |value|
|
|
816
|
+
return platform.file_field_value_set(identifier.clone, value) unless block_given?
|
|
817
|
+
self.send("#{name}_element").value = value
|
|
818
|
+
end
|
|
819
|
+
define_method("#{name}_element") do
|
|
820
|
+
return call_block(&block) if block_given?
|
|
821
|
+
platform.file_field_for(identifier.clone)
|
|
822
|
+
end
|
|
823
|
+
end
|
|
790
824
|
end
|
|
791
825
|
end
|
|
@@ -13,6 +13,8 @@ module PageObject
|
|
|
13
13
|
# * :text => Watir only
|
|
14
14
|
# * :value => Watir and Selenium
|
|
15
15
|
# * :xpath => Watir and Selenium
|
|
16
|
+
# * :src => Watir and Selenium (image button only)
|
|
17
|
+
# * :alt => Watir and Selenium (image button only)
|
|
16
18
|
#
|
|
17
19
|
def button_element(identifier)
|
|
18
20
|
platform.button_for(identifier.clone)
|
|
@@ -30,6 +32,7 @@ module PageObject
|
|
|
30
32
|
# * :name => Watir and Selenium
|
|
31
33
|
# * :tag_name => Watir and Selenium
|
|
32
34
|
# * :text => Watir only
|
|
35
|
+
# * :title => Watir and Selenium
|
|
33
36
|
# * :value => Watir only
|
|
34
37
|
# * :xpath => Watir and Selenium
|
|
35
38
|
#
|
|
@@ -377,6 +380,21 @@ module PageObject
|
|
|
377
380
|
#
|
|
378
381
|
def paragraph_element(identifier)
|
|
379
382
|
platform.paragraph_for(identifier.clone)
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
#
|
|
386
|
+
# Finds a paragraph
|
|
387
|
+
#
|
|
388
|
+
# @param [Hash] identifier how we find a paragraph. You can use a multiple paramaters
|
|
389
|
+
# by combining of any of the following except xpath. The valid keys are:
|
|
390
|
+
# * :class => Watir and Selenium
|
|
391
|
+
# * :id => Watir and Selenium
|
|
392
|
+
# * :index => Watir and Selenium
|
|
393
|
+
# * :name => Watir and Selenium
|
|
394
|
+
# * :title => Watir and Selenium
|
|
395
|
+
# * :xpath => Watir and Selenium
|
|
396
|
+
def file_field_element(identifier)
|
|
397
|
+
platform.file_field_for(identifier.clone)
|
|
380
398
|
end
|
|
381
399
|
end
|
|
382
|
-
end
|
|
400
|
+
end
|
data/lib/page-object/elements.rb
CHANGED
|
@@ -23,6 +23,20 @@ module PageObject
|
|
|
23
23
|
def click
|
|
24
24
|
@element.click
|
|
25
25
|
end
|
|
26
|
+
|
|
27
|
+
#
|
|
28
|
+
# double click the element
|
|
29
|
+
#
|
|
30
|
+
def double_click
|
|
31
|
+
@element.double_click
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
#
|
|
35
|
+
# return true if the element is enabled
|
|
36
|
+
#
|
|
37
|
+
def enabled?
|
|
38
|
+
@element.enabled?
|
|
39
|
+
end
|
|
26
40
|
|
|
27
41
|
#
|
|
28
42
|
# get the value of the given CSS property
|
|
@@ -67,6 +81,12 @@ module PageObject
|
|
|
67
81
|
# delegate calls to driver element
|
|
68
82
|
def method_missing(*args, &block)
|
|
69
83
|
m = args.shift
|
|
84
|
+
puts "*** DEPRECATION WARNING"
|
|
85
|
+
puts "*** You are calling a method named #{m}."
|
|
86
|
+
puts "*** This method does not exist in page-object so it is being passed to the driver."
|
|
87
|
+
puts "*** This feature will be removed in the near future."
|
|
88
|
+
puts "*** Please change your code to call the correct page-object method."
|
|
89
|
+
puts "*** If you are using functionality that does not exist in page-object please request it be added."
|
|
70
90
|
begin
|
|
71
91
|
element.send m, *args, &block
|
|
72
92
|
rescue Exception => e
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
module PageObject
|
|
3
|
+
module Elements
|
|
4
|
+
class FileField < Element
|
|
5
|
+
|
|
6
|
+
def initialize(element, platform)
|
|
7
|
+
@element = element
|
|
8
|
+
include_platform_for platform
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
protected
|
|
12
|
+
|
|
13
|
+
def self.watir_finders
|
|
14
|
+
super + [:title]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.selenium_finders
|
|
18
|
+
super + [:title]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def include_platform_for platform
|
|
22
|
+
super
|
|
23
|
+
if platform[:platform] == :watir_webdriver
|
|
24
|
+
require 'page-object/platforms/watir_webdriver/file_field'
|
|
25
|
+
self.class.send :include, PageObject::Platforms::WatirWebDriver::FileField
|
|
26
|
+
elsif platform[:platform] == :selenium_webdriver
|
|
27
|
+
require 'page-object/platforms/selenium_webdriver/file_field'
|
|
28
|
+
self.class.send :include, PageObject::Platforms::SeleniumWebDriver::FileField
|
|
29
|
+
else
|
|
30
|
+
raise ArgumentError, "expect platform to be :watir_webdriver or :selenium_webdriver"
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -11,7 +11,7 @@ module PageObject
|
|
|
11
11
|
protected
|
|
12
12
|
|
|
13
13
|
def self.watir_finders
|
|
14
|
-
super + [:tag_name]
|
|
14
|
+
super + [:tag_name, :title]
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def self.watir_mapping
|
|
@@ -19,7 +19,7 @@ module PageObject
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def self.selenium_finders
|
|
22
|
-
super + [:css]
|
|
22
|
+
super + [:css, :title]
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def self.selenium_mapping
|
|
@@ -3,7 +3,7 @@ module PageObject
|
|
|
3
3
|
|
|
4
4
|
#
|
|
5
5
|
# This method will populate all matched page TextFields,
|
|
6
|
-
# TextAreas, SelectLists, Checkboxes, and Radio Buttons from the
|
|
6
|
+
# TextAreas, SelectLists, FileFields, Checkboxes, and Radio Buttons from the
|
|
7
7
|
# Hash passed as an argument. The way it find an element is by
|
|
8
8
|
# matching the Hash key to the name you provided when declaring
|
|
9
9
|
# the element on your page.
|
|
@@ -26,7 +26,7 @@ module PageObject
|
|
|
26
26
|
#
|
|
27
27
|
# @param [Hash] the data to use to populate this page. The key
|
|
28
28
|
# can be either a string or a symbol. The value must be a string
|
|
29
|
-
# for TextField, TextArea, and
|
|
29
|
+
# for TextField, TextArea, SelectList, and FileField and must be true or
|
|
30
30
|
# false for a Checkbox or RadioButton.
|
|
31
31
|
#
|
|
32
32
|
def populate_page_with(data)
|
|
@@ -7,14 +7,14 @@ module PageObject
|
|
|
7
7
|
# check the checkbox
|
|
8
8
|
#
|
|
9
9
|
def check
|
|
10
|
-
element.click unless selected?
|
|
10
|
+
element.click unless element.selected?
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
#
|
|
14
14
|
# uncheck the checkbox
|
|
15
15
|
#
|
|
16
16
|
def uncheck
|
|
17
|
-
element.click if selected?
|
|
17
|
+
element.click if element.selected?
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
#
|
|
@@ -55,22 +55,27 @@ module PageObject
|
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
#
|
|
58
|
-
# Get the value of a the given attribute of the element.
|
|
59
|
-
#
|
|
60
|
-
#
|
|
61
|
-
#
|
|
62
|
-
#
|
|
63
|
-
#
|
|
64
|
-
#
|
|
65
|
-
#
|
|
66
|
-
#
|
|
67
|
-
#
|
|
68
|
-
#
|
|
69
|
-
#
|
|
58
|
+
# Get the value of a the given attribute of the element. Will
|
|
59
|
+
# return the current value, even if this has been modified
|
|
60
|
+
# after the page has been loaded. More exactly, this method
|
|
61
|
+
# will return the value of the given attribute, unless that
|
|
62
|
+
# attribute is not present, in which case the value of the
|
|
63
|
+
# property with the same name is returned. If neither value is
|
|
64
|
+
# set, nil is returned. The "style" attribute is converted as
|
|
65
|
+
# best can be to a text representation with a trailing
|
|
66
|
+
# semi-colon. The following are deemed to be "boolean"
|
|
67
|
+
# attributes, and will return either "true" or "false":
|
|
68
|
+
#
|
|
69
|
+
# async, autofocus, autoplay, checked, compact, complete,
|
|
70
|
+
# controls, declare, defaultchecked, defaultselected, defer,
|
|
71
|
+
# disabled, draggable, ended, formnovalidate, hidden, indeterminate,
|
|
72
|
+
# iscontenteditable, ismap, itemscope, loop, multiple, muted,
|
|
73
|
+
# nohref, noresize, noshade, novalidate, nowrap, open, paused,
|
|
74
|
+
# pubdate, readonly, required, reversed, scoped, seamless, seeking,
|
|
70
75
|
# selected, spellcheck, truespeed, willvalidate
|
|
71
76
|
#
|
|
72
|
-
# Finally, the following commonly mis-capitalized
|
|
73
|
-
# expected:
|
|
77
|
+
# Finally, the following commonly mis-capitalized
|
|
78
|
+
# attribute/property names are evaluated as expected:
|
|
74
79
|
#
|
|
75
80
|
# class, readonly
|
|
76
81
|
#
|
|
@@ -739,7 +739,7 @@ module PageObject
|
|
|
739
739
|
how, what, frame_identifiers = parse_identifiers(identifier, Elements::Paragraph, 'p')
|
|
740
740
|
switch_to_frame(frame_identifiers)
|
|
741
741
|
value = @browser.find_element(how, what).text
|
|
742
|
-
@browser.switch_to.default_content
|
|
742
|
+
@browser.switch_to.default_content unless frame_identifiers.nil?
|
|
743
743
|
value
|
|
744
744
|
end
|
|
745
745
|
|
|
@@ -753,7 +753,30 @@ module PageObject
|
|
|
753
753
|
element = @browser.find_element(how, what)
|
|
754
754
|
@browser.switch_to.default_content unless frame_identifiers.nil?
|
|
755
755
|
::PageObject::Elements::Paragraph.new(element, :platform => :selenium_webdriver)
|
|
756
|
-
end
|
|
756
|
+
end
|
|
757
|
+
|
|
758
|
+
#
|
|
759
|
+
# platform method to set the file on a file_field element
|
|
760
|
+
# See PageObject::Accessors#file_field
|
|
761
|
+
#
|
|
762
|
+
def file_field_value_set(identifier, value)
|
|
763
|
+
how, what, frame_identifiers = parse_identifiers(identifier, Elements::FileField, 'input', :type => 'file')
|
|
764
|
+
switch_to_frame(frame_identifiers)
|
|
765
|
+
@browser.find_element(how, what).send_keys(value)
|
|
766
|
+
@browser.switch_to.default_content unless frame_identifiers.nil?
|
|
767
|
+
end
|
|
768
|
+
|
|
769
|
+
#
|
|
770
|
+
# platform method to retrieve a file_field element
|
|
771
|
+
# See PageObject::Accessors#file_field
|
|
772
|
+
#
|
|
773
|
+
def file_field_for(identifier)
|
|
774
|
+
how, what, frame_identifiers = parse_identifiers(identifier, Elements::FileField, 'input', :type => 'file')
|
|
775
|
+
switch_to_frame(frame_identifiers)
|
|
776
|
+
element = @browser.find_element(how, what)
|
|
777
|
+
@browser.switch_to.default_content unless frame_identifiers.nil?
|
|
778
|
+
::PageObject::Elements::FileField.new(element, :platform => :selenium_webdriver)
|
|
779
|
+
end
|
|
757
780
|
|
|
758
781
|
private
|
|
759
782
|
|
|
@@ -783,7 +806,12 @@ module PageObject
|
|
|
783
806
|
return false if identifier[:value] and tag == 'input' and additional[:type] == 'submit'
|
|
784
807
|
return false if identifier[:src] and tag == 'input' and additional[:type] == 'submit'
|
|
785
808
|
return false if identifier[:alt] and tag == 'input' and additional[:type] == 'submit'
|
|
809
|
+
return false if identifier[:title] and tag == 'input' and additional[:type] == 'text'
|
|
786
810
|
return false if identifier[:value] and tag == 'input' and additional[:type] == 'radio'
|
|
811
|
+
return false if identifier[:title] and tag == 'input' and additional[:type] == 'file'
|
|
812
|
+
return false if identifier[:action] and tag == 'form'
|
|
813
|
+
return false if identifier[:alt] and tag == 'img'
|
|
814
|
+
return false if identifier[:src] and tag == 'img'
|
|
787
815
|
true
|
|
788
816
|
end
|
|
789
817
|
|
|
@@ -55,22 +55,27 @@ module PageObject
|
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
#
|
|
58
|
-
# Get the value of a the given attribute of the element.
|
|
59
|
-
#
|
|
60
|
-
#
|
|
61
|
-
#
|
|
62
|
-
#
|
|
63
|
-
#
|
|
64
|
-
#
|
|
65
|
-
#
|
|
66
|
-
#
|
|
67
|
-
#
|
|
68
|
-
#
|
|
69
|
-
#
|
|
58
|
+
# Get the value of a the given attribute of the element. Will
|
|
59
|
+
# return the current value, even if this has been modified
|
|
60
|
+
# after the page has been loaded. More exactly, this method
|
|
61
|
+
# will return the value of the given attribute, unless that
|
|
62
|
+
# attribute is not present, in which case the value of the
|
|
63
|
+
# property with the same name is returned. If neither value is
|
|
64
|
+
# set, nil is returned. The "style" attribute is converted as
|
|
65
|
+
# best can be to a text representation with a trailing
|
|
66
|
+
# semi-colon. The following are deemed to be "boolean"
|
|
67
|
+
# attributes, and will return either "true" or "false":
|
|
68
|
+
#
|
|
69
|
+
# async, autofocus, autoplay, checked, compact, complete,
|
|
70
|
+
# controls, declare, defaultchecked, defaultselected, defer,
|
|
71
|
+
# disabled, draggable, ended, formnovalidate, hidden, indeterminate,
|
|
72
|
+
# iscontenteditable, ismap, itemscope, loop, multiple, muted,
|
|
73
|
+
# nohref, noresize, noshade, novalidate, nowrap, open, paused,
|
|
74
|
+
# pubdate, readonly, required, reversed, scoped, seamless, seeking,
|
|
70
75
|
# selected, spellcheck, truespeed, willvalidate
|
|
71
76
|
#
|
|
72
|
-
# Finally, the following commonly mis-capitalized
|
|
73
|
-
# expected:
|
|
77
|
+
# Finally, the following commonly mis-capitalized
|
|
78
|
+
# attribute/property names are evaluated as expected:
|
|
74
79
|
#
|
|
75
80
|
# class, readonly
|
|
76
81
|
#
|
|
@@ -704,7 +704,28 @@ module PageObject
|
|
|
704
704
|
element = @browser.instance_eval "#{nested_frames(frame_identifiers)}p(identifier)"
|
|
705
705
|
switch_to_default_content(frame_identifiers)
|
|
706
706
|
::PageObject::Elements::Paragraph.new(element, :platform => :watir_webdriver)
|
|
707
|
-
end
|
|
707
|
+
end
|
|
708
|
+
|
|
709
|
+
#
|
|
710
|
+
# platform method to set the file on a file_field element
|
|
711
|
+
# See PageObject::Accessors#file_field
|
|
712
|
+
#
|
|
713
|
+
def file_field_value_set(identifier, value)
|
|
714
|
+
identifier, frame_identifiers = parse_identifiers(identifier, Elements::FileField)
|
|
715
|
+
@browser.instance_eval "#{nested_frames(frame_identifiers)}file_field(identifier).set(value)"
|
|
716
|
+
switch_to_default_content(frame_identifiers)
|
|
717
|
+
end
|
|
718
|
+
|
|
719
|
+
#
|
|
720
|
+
# platform method to retrieve a file_field element
|
|
721
|
+
# See PageObject::Accessors#file_field
|
|
722
|
+
#
|
|
723
|
+
def file_field_for(identifier)
|
|
724
|
+
identifier, frame_identifiers = parse_identifiers(identifier, Elements::FileField)
|
|
725
|
+
element = @browser.instance_eval "#{nested_frames(frame_identifiers)}file_field(identifier)"
|
|
726
|
+
switch_to_default_content(frame_identifiers)
|
|
727
|
+
::PageObject::Elements::FileField.new(element, :platform => :watir_webdriver)
|
|
728
|
+
end
|
|
708
729
|
|
|
709
730
|
private
|
|
710
731
|
|
data/lib/page-object/version.rb
CHANGED
|
@@ -28,6 +28,7 @@ class AccessorsTestPageObject
|
|
|
28
28
|
h5(:heading5, :id => 'main_heading')
|
|
29
29
|
h6(:heading6, :id => 'main_heading')
|
|
30
30
|
paragraph(:first_para, :id => 'first')
|
|
31
|
+
file_field(:upload_me, :id => 'the_file')
|
|
31
32
|
end
|
|
32
33
|
|
|
33
34
|
class BlockPageObject
|
|
@@ -107,6 +108,9 @@ class BlockPageObject
|
|
|
107
108
|
paragraph :first_para do |element|
|
|
108
109
|
"p"
|
|
109
110
|
end
|
|
111
|
+
file_field :a_file do |element|
|
|
112
|
+
"file_field"
|
|
113
|
+
end
|
|
110
114
|
end
|
|
111
115
|
|
|
112
116
|
describe PageObject::Accessors do
|
|
@@ -1176,4 +1180,45 @@ describe PageObject::Accessors do
|
|
|
1176
1180
|
end
|
|
1177
1181
|
end
|
|
1178
1182
|
end
|
|
1183
|
+
|
|
1184
|
+
describe "file_field accessors" do
|
|
1185
|
+
context "when called on a page object" do
|
|
1186
|
+
it "should generate accessor methods" do
|
|
1187
|
+
watir_page_object.should respond_to(:upload_me=)
|
|
1188
|
+
watir_page_object.should respond_to(:upload_me_element)
|
|
1189
|
+
end
|
|
1190
|
+
|
|
1191
|
+
it "should call a block on the element method when present" do
|
|
1192
|
+
block_page_object.a_file_element.should == "file_field"
|
|
1193
|
+
end
|
|
1194
|
+
end
|
|
1195
|
+
|
|
1196
|
+
context "watir implementation" do
|
|
1197
|
+
it "should set the file name" do
|
|
1198
|
+
watir_browser.should_receive(:file_field).and_return(watir_browser)
|
|
1199
|
+
watir_browser.should_receive(:set).with('some_file')
|
|
1200
|
+
watir_page_object.upload_me = 'some_file'
|
|
1201
|
+
end
|
|
1202
|
+
|
|
1203
|
+
it "should retrieve a text field element" do
|
|
1204
|
+
watir_browser.should_receive(:file_field).and_return(watir_browser)
|
|
1205
|
+
element = watir_page_object.upload_me_element
|
|
1206
|
+
element.should be_instance_of PageObject::Elements::FileField
|
|
1207
|
+
end
|
|
1208
|
+
end
|
|
1209
|
+
|
|
1210
|
+
context "selenium implementation" do
|
|
1211
|
+
it "should set the file name" do
|
|
1212
|
+
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
|
1213
|
+
selenium_browser.should_receive(:send_keys).with('some_file')
|
|
1214
|
+
selenium_page_object.upload_me = 'some_file'
|
|
1215
|
+
end
|
|
1216
|
+
|
|
1217
|
+
it "should retrieve a file_field element" do
|
|
1218
|
+
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
|
1219
|
+
element = selenium_page_object.upload_me_element
|
|
1220
|
+
element.should be_instance_of PageObject::Elements::FileField
|
|
1221
|
+
end
|
|
1222
|
+
end
|
|
1223
|
+
end
|
|
1179
1224
|
end
|
|
@@ -152,4 +152,10 @@ describe PageObject::ElementLocators do
|
|
|
152
152
|
element = watir_page_object.paragraph_element(:id => 'blah')
|
|
153
153
|
element.should be_instance_of PageObject::Elements::Paragraph
|
|
154
154
|
end
|
|
155
|
-
|
|
155
|
+
|
|
156
|
+
it "should find a file field element" do
|
|
157
|
+
watir_browser.should_receive(:file_field).with(:id => 'blah').and_return(watir_browser)
|
|
158
|
+
element = watir_page_object.file_field_element(:id => 'blah')
|
|
159
|
+
element.should be_instance_of PageObject::Elements::FileField
|
|
160
|
+
end
|
|
161
|
+
end
|
|
@@ -4,15 +4,6 @@ require 'page-object/elements'
|
|
|
4
4
|
|
|
5
5
|
describe "Element class methods" do
|
|
6
6
|
|
|
7
|
-
context "when handling unknown requests" do
|
|
8
|
-
it "should delegate to the driver element" do
|
|
9
|
-
watir_driver = double('watir')
|
|
10
|
-
watir_element = PageObject::Elements::Element.new(watir_driver, :platform => :watir_webdriver)
|
|
11
|
-
watir_driver.should_receive(:do_this)
|
|
12
|
-
watir_element.do_this
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
7
|
context "when building the identifiers for Watir" do
|
|
17
8
|
it "should build xpath when finding elements by name where not supported" do
|
|
18
9
|
['table', 'span', 'div', 'td', 'li', 'ol', 'ul'].each do |tag|
|
|
@@ -85,4 +76,4 @@ describe "Element class methods" do
|
|
|
85
76
|
end
|
|
86
77
|
end
|
|
87
78
|
end
|
|
88
|
-
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'page-object/elements'
|
|
3
|
+
|
|
4
|
+
describe PageObject::Elements::FileField do
|
|
5
|
+
|
|
6
|
+
describe "when mapping how to find an element" do
|
|
7
|
+
let(:filefield) { PageObject::Elements::FileField }
|
|
8
|
+
|
|
9
|
+
it "should map watir types to same" do
|
|
10
|
+
[:class, :id, :index, :name, :xpath, :title].each do |t|
|
|
11
|
+
identifier = filefield.watir_identifier_for t => 'value'
|
|
12
|
+
identifier.keys.first.should == t
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "should map selenium types to same" do
|
|
17
|
+
[:class, :id, :index, :name, :xpath, :title].each do |t|
|
|
18
|
+
key, value = filefield.selenium_identifier_for t => 'value'
|
|
19
|
+
key.should == t
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe "interface" do
|
|
25
|
+
let(:filefield) { double('file_field') }
|
|
26
|
+
|
|
27
|
+
context "for selenium" do
|
|
28
|
+
it "should set its' value" do
|
|
29
|
+
selenium_file_field = PageObject::Elements::FileField.new(filefield, :platform => :selenium_webdriver)
|
|
30
|
+
filefield.should_receive(:send_keys).with('a file')
|
|
31
|
+
selenium_file_field.value = 'a file'
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -6,14 +6,14 @@ describe PageObject::Elements::Image do
|
|
|
6
6
|
|
|
7
7
|
describe "when mapping how to find an element" do
|
|
8
8
|
it "should map watir types to same" do
|
|
9
|
-
[:class, :id, :index, :name, :xpath].each do |t|
|
|
9
|
+
[:class, :id, :index, :name, :xpath, :alt, :src].each do |t|
|
|
10
10
|
identifier = image.watir_identifier_for t => 'value'
|
|
11
11
|
identifier.keys.first.should == t
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it "should map selenium types to same" do
|
|
16
|
-
[:class, :id, :index, :name, :xpath].each do |t|
|
|
16
|
+
[:class, :id, :index, :name, :xpath, :alt, :src].each do |t|
|
|
17
17
|
key, value = image.selenium_identifier_for t => 'value'
|
|
18
18
|
key.should == t
|
|
19
19
|
end
|
|
@@ -59,4 +59,4 @@ describe PageObject::Elements::Image do
|
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
|
-
end
|
|
62
|
+
end
|
|
@@ -7,7 +7,7 @@ describe PageObject::Elements::TextField do
|
|
|
7
7
|
let(:textfield) { PageObject::Elements::TextField }
|
|
8
8
|
|
|
9
9
|
it "should map watir types to same" do
|
|
10
|
-
[:class, :id, :index, :name, :tag_name, :xpath].each do |t|
|
|
10
|
+
[:class, :id, :index, :name, :tag_name, :title, :xpath].each do |t|
|
|
11
11
|
identifier = textfield.watir_identifier_for t => 'value'
|
|
12
12
|
identifier.keys.first.should == t
|
|
13
13
|
end
|
|
@@ -19,7 +19,7 @@ describe PageObject::Elements::TextField do
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
it "should map selenium types to same" do
|
|
22
|
-
[:class, :css, :id, :name, :xpath, :index].each do |t|
|
|
22
|
+
[:class, :css, :id, :name, :title, :xpath, :index].each do |t|
|
|
23
23
|
key, value = textfield.selenium_identifier_for t => 'value'
|
|
24
24
|
key.should == t
|
|
25
25
|
end
|
|
@@ -42,4 +42,4 @@ describe PageObject::Elements::TextField do
|
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
|
-
end
|
|
45
|
+
end
|
|
@@ -6,6 +6,7 @@ class PageObjectTestPageObject
|
|
|
6
6
|
text_field(:tf, :id => 'id')
|
|
7
7
|
text_area(:ta, :id => 'id')
|
|
8
8
|
select_list(:sl, :id => 'id')
|
|
9
|
+
file_field(:ff, :id => 'id')
|
|
9
10
|
checkbox(:cb, :id => 'id')
|
|
10
11
|
radio_button(:rb, :id => 'id')
|
|
11
12
|
end
|
|
@@ -34,6 +35,11 @@ describe PageObject::PagePopulator do
|
|
|
34
35
|
page_object.populate_page_with('sa' => 'value')
|
|
35
36
|
end
|
|
36
37
|
|
|
38
|
+
it "should set a value in a file field" do
|
|
39
|
+
page_object.should_receive(:ff=).with('value')
|
|
40
|
+
page_object.populate_page_with('ff' => 'value')
|
|
41
|
+
end
|
|
42
|
+
|
|
37
43
|
it "should check a checkbox to true is specified" do
|
|
38
44
|
page_object.should_receive(:check_cb)
|
|
39
45
|
page_object.populate_page_with('cb' => true)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: page-object
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.4
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,11 +9,11 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2011-12-
|
|
12
|
+
date: 2011-12-18 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: watir-webdriver
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &70274033036520 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ! '>='
|
|
@@ -21,10 +21,10 @@ dependencies:
|
|
|
21
21
|
version: 0.4.1
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
24
|
+
version_requirements: *70274033036520
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
26
|
name: selenium-webdriver
|
|
27
|
-
requirement: &
|
|
27
|
+
requirement: &70274033035700 !ruby/object:Gem::Requirement
|
|
28
28
|
none: false
|
|
29
29
|
requirements:
|
|
30
30
|
- - ! '>='
|
|
@@ -32,10 +32,10 @@ dependencies:
|
|
|
32
32
|
version: 2.15.0
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
|
-
version_requirements: *
|
|
35
|
+
version_requirements: *70274033035700
|
|
36
36
|
- !ruby/object:Gem::Dependency
|
|
37
37
|
name: rspec
|
|
38
|
-
requirement: &
|
|
38
|
+
requirement: &70274033031880 !ruby/object:Gem::Requirement
|
|
39
39
|
none: false
|
|
40
40
|
requirements:
|
|
41
41
|
- - ! '>='
|
|
@@ -43,10 +43,10 @@ dependencies:
|
|
|
43
43
|
version: 2.6.0
|
|
44
44
|
type: :development
|
|
45
45
|
prerelease: false
|
|
46
|
-
version_requirements: *
|
|
46
|
+
version_requirements: *70274033031880
|
|
47
47
|
- !ruby/object:Gem::Dependency
|
|
48
48
|
name: cucumber
|
|
49
|
-
requirement: &
|
|
49
|
+
requirement: &70274033031160 !ruby/object:Gem::Requirement
|
|
50
50
|
none: false
|
|
51
51
|
requirements:
|
|
52
52
|
- - ! '>='
|
|
@@ -54,10 +54,10 @@ dependencies:
|
|
|
54
54
|
version: 1.1.0
|
|
55
55
|
type: :development
|
|
56
56
|
prerelease: false
|
|
57
|
-
version_requirements: *
|
|
57
|
+
version_requirements: *70274033031160
|
|
58
58
|
- !ruby/object:Gem::Dependency
|
|
59
59
|
name: yard
|
|
60
|
-
requirement: &
|
|
60
|
+
requirement: &70274033030460 !ruby/object:Gem::Requirement
|
|
61
61
|
none: false
|
|
62
62
|
requirements:
|
|
63
63
|
- - ! '>='
|
|
@@ -65,7 +65,7 @@ dependencies:
|
|
|
65
65
|
version: 0.7.2
|
|
66
66
|
type: :development
|
|
67
67
|
prerelease: false
|
|
68
|
-
version_requirements: *
|
|
68
|
+
version_requirements: *70274033030460
|
|
69
69
|
description: Page Object DSL that works with both Watir and Selenium
|
|
70
70
|
email:
|
|
71
71
|
- jeff.morgan@leandog.com
|
|
@@ -88,10 +88,12 @@ files:
|
|
|
88
88
|
- features/check_box.feature
|
|
89
89
|
- features/div.feature
|
|
90
90
|
- features/element.feature
|
|
91
|
+
- features/file_field.feature
|
|
91
92
|
- features/form.feature
|
|
92
93
|
- features/frames.feature
|
|
93
94
|
- features/headings.feature
|
|
94
95
|
- features/hidden_field.feature
|
|
96
|
+
- features/html/async.html
|
|
95
97
|
- features/html/frame_1.html
|
|
96
98
|
- features/html/frame_2.html
|
|
97
99
|
- features/html/frame_3.html
|
|
@@ -126,6 +128,7 @@ files:
|
|
|
126
128
|
- features/step_definitions/check_box_steps.rb
|
|
127
129
|
- features/step_definitions/div_steps.rb
|
|
128
130
|
- features/step_definitions/element_steps.rb
|
|
131
|
+
- features/step_definitions/file_field_steps.rb
|
|
129
132
|
- features/step_definitions/form_steps.rb
|
|
130
133
|
- features/step_definitions/frames_steps.rb
|
|
131
134
|
- features/step_definitions/headings_steps.rb
|
|
@@ -164,6 +167,7 @@ files:
|
|
|
164
167
|
- lib/page-object/elements/check_box.rb
|
|
165
168
|
- lib/page-object/elements/div.rb
|
|
166
169
|
- lib/page-object/elements/element.rb
|
|
170
|
+
- lib/page-object/elements/file_field.rb
|
|
167
171
|
- lib/page-object/elements/form.rb
|
|
168
172
|
- lib/page-object/elements/heading.rb
|
|
169
173
|
- lib/page-object/elements/hidden_field.rb
|
|
@@ -191,6 +195,7 @@ files:
|
|
|
191
195
|
- lib/page-object/platforms/selenium_webdriver/button.rb
|
|
192
196
|
- lib/page-object/platforms/selenium_webdriver/check_box.rb
|
|
193
197
|
- lib/page-object/platforms/selenium_webdriver/element.rb
|
|
198
|
+
- lib/page-object/platforms/selenium_webdriver/file_field.rb
|
|
194
199
|
- lib/page-object/platforms/selenium_webdriver/form.rb
|
|
195
200
|
- lib/page-object/platforms/selenium_webdriver/image.rb
|
|
196
201
|
- lib/page-object/platforms/selenium_webdriver/link.rb
|
|
@@ -206,6 +211,7 @@ files:
|
|
|
206
211
|
- lib/page-object/platforms/watir_webdriver.rb
|
|
207
212
|
- lib/page-object/platforms/watir_webdriver/check_box.rb
|
|
208
213
|
- lib/page-object/platforms/watir_webdriver/element.rb
|
|
214
|
+
- lib/page-object/platforms/watir_webdriver/file_field.rb
|
|
209
215
|
- lib/page-object/platforms/watir_webdriver/form.rb
|
|
210
216
|
- lib/page-object/platforms/watir_webdriver/image.rb
|
|
211
217
|
- lib/page-object/platforms/watir_webdriver/ordered_list.rb
|
|
@@ -225,6 +231,7 @@ files:
|
|
|
225
231
|
- spec/page-object/elements/check_box_spec.rb
|
|
226
232
|
- spec/page-object/elements/div_spec.rb
|
|
227
233
|
- spec/page-object/elements/element_spec.rb
|
|
234
|
+
- spec/page-object/elements/file_field_spec.rb
|
|
228
235
|
- spec/page-object/elements/form_spec.rb
|
|
229
236
|
- spec/page-object/elements/heading_spec.rb
|
|
230
237
|
- spec/page-object/elements/hidden_field_spec.rb
|
|
@@ -281,10 +288,12 @@ test_files:
|
|
|
281
288
|
- features/check_box.feature
|
|
282
289
|
- features/div.feature
|
|
283
290
|
- features/element.feature
|
|
291
|
+
- features/file_field.feature
|
|
284
292
|
- features/form.feature
|
|
285
293
|
- features/frames.feature
|
|
286
294
|
- features/headings.feature
|
|
287
295
|
- features/hidden_field.feature
|
|
296
|
+
- features/html/async.html
|
|
288
297
|
- features/html/frame_1.html
|
|
289
298
|
- features/html/frame_2.html
|
|
290
299
|
- features/html/frame_3.html
|
|
@@ -319,6 +328,7 @@ test_files:
|
|
|
319
328
|
- features/step_definitions/check_box_steps.rb
|
|
320
329
|
- features/step_definitions/div_steps.rb
|
|
321
330
|
- features/step_definitions/element_steps.rb
|
|
331
|
+
- features/step_definitions/file_field_steps.rb
|
|
322
332
|
- features/step_definitions/form_steps.rb
|
|
323
333
|
- features/step_definitions/frames_steps.rb
|
|
324
334
|
- features/step_definitions/headings_steps.rb
|
|
@@ -354,6 +364,7 @@ test_files:
|
|
|
354
364
|
- spec/page-object/elements/check_box_spec.rb
|
|
355
365
|
- spec/page-object/elements/div_spec.rb
|
|
356
366
|
- spec/page-object/elements/element_spec.rb
|
|
367
|
+
- spec/page-object/elements/file_field_spec.rb
|
|
357
368
|
- spec/page-object/elements/form_spec.rb
|
|
358
369
|
- spec/page-object/elements/heading_spec.rb
|
|
359
370
|
- spec/page-object/elements/hidden_field_spec.rb
|