page-object 0.7.5.1 → 0.7.6

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 (50) hide show
  1. data/ChangeLog +8 -0
  2. data/features/area.feature +9 -0
  3. data/features/audio.feature +9 -0
  4. data/features/canvas.feature +9 -0
  5. data/features/check_box.feature +9 -0
  6. data/features/element.feature +5 -0
  7. data/features/file_field.feature +9 -0
  8. data/features/form.feature +9 -0
  9. data/features/headings.feature +55 -0
  10. data/features/hidden_field.feature +9 -0
  11. data/features/html/double_click.html +13 -0
  12. data/features/html/failure.html +8 -0
  13. data/features/html/static_elements.html +1 -0
  14. data/features/image.feature +10 -0
  15. data/features/label.feature +9 -0
  16. data/features/link.feature +9 -0
  17. data/features/list_item.feature +9 -0
  18. data/features/ordered_list.feature +12 -0
  19. data/features/page_level_actions.feature +10 -0
  20. data/features/paragraph.feature +9 -0
  21. data/features/radio_button.feature +10 -0
  22. data/features/span.feature +9 -0
  23. data/features/step_definitions/element_steps.rb +19 -0
  24. data/features/step_definitions/page_level_actions_steps.rb +6 -0
  25. data/features/step_definitions/span_steps.rb +1 -1
  26. data/features/support/page.rb +30 -0
  27. data/features/support/url_helper.rb +4 -1
  28. data/features/table.feature +9 -0
  29. data/features/table_cell.feature +9 -0
  30. data/features/text_area.feature +8 -0
  31. data/features/unordered_list.feature +12 -0
  32. data/features/video.feature +9 -0
  33. data/lib/page-object.rb +4 -2
  34. data/lib/page-object/accessors.rb +57 -0
  35. data/lib/page-object/elements/button.rb +1 -1
  36. data/lib/page-object/elements/div.rb +1 -1
  37. data/lib/page-object/elements/element.rb +2 -7
  38. data/lib/page-object/elements/link.rb +1 -1
  39. data/lib/page-object/elements/select_list.rb +0 -4
  40. data/lib/page-object/elements/span.rb +1 -1
  41. data/lib/page-object/elements/text_field.rb +1 -1
  42. data/lib/page-object/platforms/selenium_webdriver/element.rb +8 -0
  43. data/lib/page-object/platforms/selenium_webdriver/page_object.rb +1 -1
  44. data/lib/page-object/platforms/watir_webdriver/element.rb +7 -0
  45. data/lib/page-object/version.rb +1 -1
  46. data/page-object.gemspec +1 -1
  47. data/spec/page-object/elements/selenium_element_spec.rb +1 -0
  48. data/spec/page-object/elements/watir_element_spec.rb +5 -0
  49. data/spec/page-object/page-object_spec.rb +35 -3
  50. metadata +10 -6
data/ChangeLog CHANGED
@@ -1,3 +1,11 @@
1
+ === Version 0.7.6 / 2012-11-28
2
+ * Fixes
3
+ * Fixed attach_to_window workes with partial url on Selenium (George Shakhnazaryan)
4
+ * Fixed double click works on Selenium (William Powell)
5
+ * Enhancements
6
+ * Added css selector support for all elements when using Selenium (Brendan Mulholland)
7
+ * Added callback to initialize_accessors method during initialization (Theodore Robert Campbell Jr)
8
+
1
9
  === Version 0.7.5.1 / 2012-10-16
2
10
  * Fixes
3
11
  * Fixed issue when passing symbol to page_url and calling multiple times
@@ -20,6 +20,15 @@ Feature: Area
20
20
  | xpath |
21
21
  | index |
22
22
 
23
+ @selenium_only
24
+ Scenario Outline: Locating areas on the page
25
+ When I search for the area by "<search_by>"
26
+ Then I should be able to click the area
27
+
28
+ Scenarios:
29
+ | search_by |
30
+ | css |
31
+
23
32
  Scenario: Getting the coordinates for the area
24
33
  When I retrieve the area element
25
34
  Then I should see the coordinates are "0,0,82,126"
@@ -20,6 +20,15 @@ Feature: Support for the audio element
20
20
  | xpath |
21
21
  | index |
22
22
 
23
+ @selenium_only
24
+ Scenario Outline: Locating an audio element on the page
25
+ When I search for the audio element by "<search_by>"
26
+ Then I should know it is visible
27
+
28
+ Scenarios:
29
+ | search_by |
30
+ | css |
31
+
23
32
  Scenario Outline: Locating audios using multiple parameters
24
33
  When I search for the audio element by "<param1>" and "<param2>"
25
34
  Then I should know it is visible
@@ -20,6 +20,15 @@ Feature: Support for the canvas element
20
20
  | xpath |
21
21
  | index |
22
22
 
23
+ @selenium_only
24
+ Scenario Outline: Locating a canvas on the page
25
+ When I search for the canvas by "<search_by>"
26
+ Then I should know it is visible
27
+
28
+ Examples:
29
+ | search_by |
30
+ | css |
31
+
23
32
  Scenario: Determining the width and height of the canvas
24
33
  When I retrieve the canvas element
25
34
  Then I should see that the canvas width is "200"
@@ -25,6 +25,15 @@ Feature: Check Box
25
25
  | index |
26
26
  | value |
27
27
 
28
+ @selenium_only
29
+ Scenario Outline: Locating check boxes on the page
30
+ When I search for the check box by "<search_by>"
31
+ Then I should be able to check the check box
32
+
33
+ Scenarios:
34
+ | search_by |
35
+ | css |
36
+
28
37
  Scenario Outline: Locating check boxes using multiple parameters
29
38
  When I search for the check box by "<param1>" and "<param2>"
30
39
  Then I should be able to check the check box
@@ -285,3 +285,8 @@ Feature: Elements
285
285
  Scenario: Getting an element's id
286
286
  When I retrieve a button element
287
287
  Then I should know its id is "button_id"
288
+
289
+ Scenario: Double Clicking
290
+ Given I am on the Double Click page
291
+ When I double click the button
292
+ Then the paragraph should read "Double Click Received"
@@ -20,6 +20,15 @@ Feature: File Field
20
20
  | title |
21
21
  | index |
22
22
 
23
+ @selenium_only
24
+ Scenario Outline: Locating file fields on the Page
25
+ When I search for the file field by "<search_by>"
26
+ Then I should be able to set the file field
27
+
28
+ Scenarios:
29
+ | search_by |
30
+ | css |
31
+
23
32
  Scenario Outline: Locating file fields using multiple parameters
24
33
  When I search for the file field by "<param1>" and "<param2>"
25
34
  Then I should be able to set the file field
@@ -19,6 +19,15 @@ Feature: Form
19
19
  | index |
20
20
  | action |
21
21
 
22
+ @selenium_only
23
+ Scenario Outline: Locating a form on the page
24
+ When I locate the form by "<search_by>"
25
+ Then I should be able to submit the form
26
+
27
+ Scenarios:
28
+ | search_by |
29
+ | css |
30
+
22
31
  Scenario Outline: Locating table using multiple parameters
23
32
  When I locate the form using "<param1>" and "<param2>"
24
33
  Then I should be able to submit the form
@@ -29,6 +29,15 @@ Feature: Headings
29
29
  | xpath |
30
30
  | index |
31
31
 
32
+ @selenium_only
33
+ Scenario Outline: Locating h1s on the Page
34
+ When I search for the heading1 by "<search_by>"
35
+ Then I should see "h1's are cool"
36
+
37
+ Scenarios:
38
+ | search_by |
39
+ | css |
40
+
32
41
  Scenario Outline: Locating h2s on the Page
33
42
  When I search for the heading2 by "<search_by>"
34
43
  Then I should see "h2's are cool"
@@ -41,6 +50,15 @@ Feature: Headings
41
50
  | xpath |
42
51
  | index |
43
52
 
53
+ @selenium_only
54
+ Scenario Outline: Locating h2s on the Page
55
+ When I search for the heading2 by "<search_by>"
56
+ Then I should see "h2's are cool"
57
+
58
+ Scenarios:
59
+ | search_by |
60
+ | css |
61
+
44
62
  Scenario Outline: Locating h3s on the Page
45
63
  When I search for the heading3 by "<search_by>"
46
64
  Then I should see "h3's are cool"
@@ -53,6 +71,15 @@ Feature: Headings
53
71
  | xpath |
54
72
  | index |
55
73
 
74
+ @selenium_only
75
+ Scenario Outline: Locating h3s on the Page
76
+ When I search for the heading3 by "<search_by>"
77
+ Then I should see "h3's are cool"
78
+
79
+ Scenarios:
80
+ | search_by |
81
+ | css |
82
+
56
83
  Scenario Outline: Locating h4s on the Page
57
84
  When I search for the heading4 by "<search_by>"
58
85
  Then I should see "h4's are cool"
@@ -65,6 +92,15 @@ Feature: Headings
65
92
  | xpath |
66
93
  | index |
67
94
 
95
+ @selenium_only
96
+ Scenario Outline: Locating h4s on the Page
97
+ When I search for the heading4 by "<search_by>"
98
+ Then I should see "h4's are cool"
99
+
100
+ Scenarios:
101
+ | search_by |
102
+ | css |
103
+
68
104
  Scenario Outline: Locating h5s on the Page
69
105
  When I search for the heading5 by "<search_by>"
70
106
  Then I should see "h5's are cool"
@@ -77,6 +113,15 @@ Feature: Headings
77
113
  | xpath |
78
114
  | index |
79
115
 
116
+ @selenium_only
117
+ Scenario Outline: Locating h5s on the Page
118
+ When I search for the heading5 by "<search_by>"
119
+ Then I should see "h5's are cool"
120
+
121
+ Scenarios:
122
+ | search_by |
123
+ | css |
124
+
80
125
  Scenario Outline: Locating h6s on the Page
81
126
  When I search for the heading6 by "<search_by>"
82
127
  Then I should see "h6's are cool"
@@ -88,3 +133,13 @@ Feature: Headings
88
133
  | name |
89
134
  | xpath |
90
135
  | index |
136
+
137
+ @selenium_only
138
+ Scenario Outline: Locating h6s on the Page
139
+ When I search for the heading6 by "<search_by>"
140
+ Then I should see "h6's are cool"
141
+
142
+ Scenarios:
143
+ | search_by |
144
+ | css |
145
+
@@ -21,6 +21,15 @@ Feature: Hidden Fields
21
21
  | text |
22
22
  | value |
23
23
 
24
+ @selenium_only
25
+ Scenario Outline: Locating hidden fields on the Page
26
+ When I search for the hidden field by "<search_by>"
27
+ Then the hidden field element should contain "12345"
28
+
29
+ Scenarios:
30
+ | search_by |
31
+ | css |
32
+
24
33
  Scenario Outline: Locating a hidden field using multiple parameters
25
34
  When I search for the hidden field by "<param1>" and "<param2>"
26
35
  Then the hidden field element should contain "12345"
@@ -0,0 +1,13 @@
1
+ <html>
2
+ <body>
3
+ <button ondblclick="change_text()">Double Click</button>
4
+ <p id="change_on_double_click">The double click has not occurred.</p>
5
+ </body>
6
+
7
+ <script>
8
+ function change_text()
9
+ {
10
+ document.getElementById("change_on_double_click").innerHTML="Double Click Received"
11
+ }
12
+ </script>
13
+ </html>
@@ -0,0 +1,8 @@
1
+ <html>
2
+ <head>
3
+ <title>Failure</title>
4
+ </head>
5
+ <body>
6
+ <h1>Failure</h1>
7
+ </body>
8
+ </html>
@@ -150,6 +150,7 @@
150
150
  <h6 id="h6_id" class="h6_class" name="h6_name">h6's are cool</h6>
151
151
 
152
152
  <a href="success.html" target="_blank">New Window</a>
153
+ <a href="failure.html" target="_blank">Another New Window</a>
153
154
 
154
155
  <input type="text" id="onfocus_text_field" onfocus="document.getElementById('onfocus_test').innerHTML = 'changed by onfocus event'"/>
155
156
  <div id="onfocus_test"></div>
@@ -23,6 +23,16 @@ Feature: Image
23
23
  | alt |
24
24
  | src |
25
25
 
26
+ @selenium_only
27
+ Scenario Outline: Locating an image on the page
28
+ When I get the image element by "<search_by>"
29
+ Then the image should be "106" pixels wide
30
+ And the image should be "106" pixels tall
31
+
32
+ Scenarios:
33
+ | search_by |
34
+ | css |
35
+
26
36
  Scenario Outline: Locating an image using multiple parameters
27
37
  When I get the image element by "<param1>" and "<param2>"
28
38
  Then the image should be "106" pixels wide
@@ -29,6 +29,15 @@ Feature: Handling labels with page object
29
29
  | name |
30
30
  | text |
31
31
 
32
+ @selenium_only
33
+ Scenario Outline: Locating labels on the page
34
+ When I search for the label by "<search_by>"
35
+ Then the text should be "page-object is the best!"
36
+
37
+ Scenarios:
38
+ | search_by |
39
+ | css |
40
+
32
41
  Scenario Outline: Locating labels using multiple parameters
33
42
  When I search for the label by "<param1>" and "<param2>"
34
43
  Then the text should be "page-object is the best!"
@@ -27,6 +27,15 @@ Feature: Links
27
27
  | css |
28
28
  | title |
29
29
 
30
+ @selenium_only
31
+ Scenario Outline: Locating links on the Page
32
+ When I search for the link by "<search_by>"
33
+ Then I should be able to select the link
34
+
35
+ Scenarios:
36
+ | search_by |
37
+ | css |
38
+
30
39
  Scenario: Support for multiple parameters
31
40
  When I select a link labeled "Hello" and index "0"
32
41
  Then the page should contain the text "Success"
@@ -20,6 +20,15 @@ Feature: List item
20
20
  | name |
21
21
  | text |
22
22
 
23
+ @selenium_only
24
+ Scenario Outline: Locating list items on the page
25
+ When I search for the list item by "<search_by>"
26
+ Then the text should be "Item One"
27
+
28
+ Scenarios:
29
+ | search_by |
30
+ | css |
31
+
23
32
  Scenario Outline: Locating list items using multiple parameters
24
33
  When I search for the list item by "<param1>" and "<param2>"
25
34
  Then the text should be "Item One"
@@ -22,6 +22,18 @@ Feature: Ordered list
22
22
  | index |
23
23
  | name |
24
24
 
25
+ @selenium_only
26
+ Scenario Outline: Locating ordered lists on the page
27
+ When I search for the ordered list by "<search_by>"
28
+ And I get the first item from the list
29
+ Then the list items text should be "Number One"
30
+ And the list should contain 3 items
31
+ And each item should contain "Number"
32
+
33
+ Scenarios:
34
+ | search_by |
35
+ | css |
36
+
25
37
  Scenario Outline: Locating ordered lists using multiple parameters
26
38
  When I search for the ordered list by "<param1>" and "<param2>"
27
39
  And I get the first item from the list
@@ -62,10 +62,20 @@ Feature: Page level actions
62
62
  Scenario: Attach to window using title
63
63
  When I open a second window
64
64
  Then I should be able to attach to a page object using title
65
+
66
+ Scenario: Attach to window using title with multiple windows
67
+ When I open a second window
68
+ When I open a third window
69
+ Then I should be able to attach to a page object using title
65
70
 
66
71
  Scenario: Attach to window using url
67
72
  When I open a second window
68
73
  Then I should be able to attach to a page object using url
74
+
75
+ Scenario: Attach to window using url with multiple windows
76
+ When I open a second window
77
+ When I open a third window
78
+ Then I should be able to attach to a page object using url
69
79
 
70
80
  Scenario: Refreshing the page
71
81
  Then I should be able to refresh the page
@@ -19,6 +19,15 @@ Feature: Paragraph
19
19
  | index |
20
20
  | name |
21
21
 
22
+ @selenium_only
23
+ Scenario Outline: Locating paragraphs on the page
24
+ When I search for the paragraph by "<search_by>"
25
+ Then the text should be "Static Elements Page"
26
+
27
+ Scenarios:
28
+ | search_by |
29
+ | css |
30
+
22
31
  Scenario Outline: Locating paragraphs using multiple parameters
23
32
  When I search for the paragraph by "<param1>" and "<param2>"
24
33
  Then the text should be "Static Elements Page"
@@ -26,6 +26,16 @@ Feature: Radio Buttons
26
26
  | value |
27
27
  | index |
28
28
 
29
+ @selenium_only
30
+ Scenario Outline: Locating radio buttons on the Page
31
+ When I search for the radio button by "<search_by>"
32
+ And I select the radio button
33
+ Then the "Milk" radio button should be selected
34
+
35
+ Scenarios:
36
+ | search_by |
37
+ | css |
38
+
29
39
  Scenario Outline: Locating radio buttons using multiple parameters
30
40
  When I search for the radio button by "<param1>" and "<param2>"
31
41
  And I select the radio button
@@ -21,6 +21,15 @@ Feature: Span
21
21
  | text |
22
22
  | title |
23
23
 
24
+ @selenium_only
25
+ Scenario Outline: Locating spans on the page
26
+ When I search for the span by "<search_by>"
27
+ Then the text should be "My alert"
28
+
29
+ Scenarios:
30
+ | search_by |
31
+ | css |
32
+
24
33
  Scenario Outline: Locating span using multiple parameters
25
34
  When I search for the span by "<param1>" and "<param2>"
26
35
  Then the text should be "My alert"
@@ -212,3 +212,22 @@ end
212
212
  Then /^I should know its id is "([^\"]*)"$/ do |id|
213
213
  @element.id.should == id
214
214
  end
215
+
216
+ class DoubleClickPage
217
+ include PageObject
218
+ button(:click)
219
+ paragraph(:text)
220
+ end
221
+
222
+ Given /^I am on the Double Click page$/ do
223
+ @page = DoubleClickPage.new(@browser)
224
+ @page.navigate_to UrlHelper.double_click
225
+ end
226
+
227
+ When /^I double click the button$/ do
228
+ @page.click_element.double_click
229
+ end
230
+
231
+ Then /^the paragraph should read "([^"]*)"$/ do |expected_text|
232
+ @page.text.should == expected_text
233
+ end