page-object 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +7 -0
- data/features/element.feature +0 -1
- data/features/page_level_actions.feature +12 -0
- data/features/select_list.feature +4 -0
- data/features/step_definitions/page_level_actions_steps.rb +22 -0
- data/features/step_definitions/select_list_steps.rb +4 -0
- data/features/text_field.feature +10 -0
- data/lib/page-object/accessors.rb +1 -0
- data/lib/page-object/elements/text_field.rb +1 -1
- data/lib/page-object/platforms/selenium_webdriver/page_object.rb +17 -7
- data/lib/page-object/platforms/selenium_webdriver/select_list.rb +8 -1
- data/lib/page-object/platforms/watir_webdriver/page_object.rb +10 -4
- data/lib/page-object/platforms/watir_webdriver/select_list.rb +9 -1
- data/lib/page-object/version.rb +1 -1
- data/spec/page-object/elements/select_list_spec.rb +16 -0
- data/spec/page-object/page-object_spec.rb +4 -2
- metadata +4 -4
data/ChangeLog
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
=== Version 0.7.4 / 2012-9-8
|
2
|
+
* Enhancements
|
3
|
+
* Added ability to find text_fields with :css when using Selenium
|
4
|
+
* Added selected_values method to SelectList to get values of all selected elements
|
5
|
+
* Fixes
|
6
|
+
* Fixed problem getting value from SelectList when it is in a Frame with Selenium
|
7
|
+
|
1
8
|
=== Version 0.7.3 / 2012-8-18
|
2
9
|
* Enhancements
|
3
10
|
* Improved handling of alert and confirm Javascript popups (George Shakhnazaryan)
|
data/features/element.feature
CHANGED
@@ -31,6 +31,10 @@ Feature: Page level actions
|
|
31
31
|
When I handle the alert
|
32
32
|
Then I should be able to get the alert's message
|
33
33
|
|
34
|
+
Scenario: Handling possible alert popups
|
35
|
+
When I handle the possible alert
|
36
|
+
Then I should be able to verify the popup didn't have a message
|
37
|
+
|
34
38
|
Scenario: Handling alert popups that reload the page
|
35
39
|
When I handle the alert that reloads the page
|
36
40
|
Then I should be able to get the alert's message
|
@@ -39,6 +43,10 @@ Feature: Page level actions
|
|
39
43
|
When I handle the confirm
|
40
44
|
Then I should be able to get the confirm message
|
41
45
|
|
46
|
+
Scenario: Handling possible confirm popups
|
47
|
+
When I handle the possible confirm
|
48
|
+
Then I should be able to verify the popup didn't have a message
|
49
|
+
|
42
50
|
Scenario: Handling confirm popups that reload the page
|
43
51
|
When I handle the confirm that reloads the page
|
44
52
|
Then I should be able to get the confirm message
|
@@ -46,6 +54,10 @@ Feature: Page level actions
|
|
46
54
|
Scenario: Handling prompt popups
|
47
55
|
When I handle the prompt
|
48
56
|
Then I should be able to get the message and default value
|
57
|
+
|
58
|
+
Scenario: Handling possible prompt popups
|
59
|
+
When I handle the possible prompt
|
60
|
+
Then I should be able to verify the popup didn't have a message
|
49
61
|
|
50
62
|
Scenario: Attach to window using title
|
51
63
|
When I open a second window
|
@@ -64,3 +64,7 @@ Feature: Select List
|
|
64
64
|
Scenario: Selecting an option by its value
|
65
65
|
When I select an option using the value "option2"
|
66
66
|
Then the selected option should be "Test 2"
|
67
|
+
|
68
|
+
Scenario: Getting the value from a selected option
|
69
|
+
When I select an option using the value "option2"
|
70
|
+
Then the selected option should have a value of "option2"
|
@@ -23,6 +23,12 @@ When /^I handle the alert$/ do
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
When /^I handle the possible alert$/ do
|
27
|
+
@msg = @page.alert do
|
28
|
+
@page.alert_button_element.focus
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
26
32
|
When /^I handle the alert that reloads the page$/ do
|
27
33
|
@msg = @page.alert do
|
28
34
|
@page.alert_button_that_reloads
|
@@ -33,12 +39,22 @@ Then /^I should be able to get the alert\'s message$/ do
|
|
33
39
|
@msg.should == "I am an alert"
|
34
40
|
end
|
35
41
|
|
42
|
+
Then /^I should be able to verify the popup didn\'t have a message$/ do
|
43
|
+
@msg.should be_nil
|
44
|
+
end
|
45
|
+
|
36
46
|
When /^I handle the confirm$/ do
|
37
47
|
@msg = @page.confirm(true) do
|
38
48
|
@page.confirm_button
|
39
49
|
end
|
40
50
|
end
|
41
51
|
|
52
|
+
When /^I handle the possible confirm$/ do
|
53
|
+
@msg = @page.confirm(true) do
|
54
|
+
@page.confirm_button_element.focus
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
42
58
|
When /^I handle the confirm that reloads the page$/ do
|
43
59
|
@msg = @page.confirm(true) do
|
44
60
|
@page.confirm_button_that_reloads
|
@@ -55,6 +71,12 @@ When /^I handle the prompt$/ do
|
|
55
71
|
end
|
56
72
|
end
|
57
73
|
|
74
|
+
When /^I handle the possible prompt$/ do
|
75
|
+
@msg = @page.prompt("Cheezy") do
|
76
|
+
@page.prompt_button_element.focus
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
58
80
|
Then /^I should be able to get the message and default value$/ do
|
59
81
|
@msg[:message].should == "enter your name"
|
60
82
|
@msg[:default_value].should == 'John Doe'
|
@@ -59,3 +59,7 @@ end
|
|
59
59
|
When /^I select an option using the value "([^\"]*)"$/ do |value|
|
60
60
|
@page.sel_list_id_element.select_value(value)
|
61
61
|
end
|
62
|
+
|
63
|
+
Then /^the selected option should have a value of "([^\"]*)"$/ do |value|
|
64
|
+
@page.sel_list_id_element.selected_values[0].should == value
|
65
|
+
end
|
data/features/text_field.feature
CHANGED
@@ -25,6 +25,16 @@ Feature: Text Fields
|
|
25
25
|
| text |
|
26
26
|
| label |
|
27
27
|
|
28
|
+
@selenium_only
|
29
|
+
Scenario Outline: Locating text fields on the Page using Selenium
|
30
|
+
When I search for the text field by "<search_by>"
|
31
|
+
Then I should be able to type "I found it" into the field
|
32
|
+
|
33
|
+
Examples:
|
34
|
+
| search_by |
|
35
|
+
| css |
|
36
|
+
|
37
|
+
|
28
38
|
Scenario Outline: Locating a text field using multiple parameters
|
29
39
|
When I search for the text field by "<param1>" and "<param2>"
|
30
40
|
Then I should be able to type "I found it" into the field
|
@@ -97,6 +97,7 @@ module PageObject
|
|
97
97
|
# @param [Hash] identifier how we find a text field. You can use a multiple paramaters
|
98
98
|
# by combining of any of the following except xpath. The valid keys are:
|
99
99
|
# * :class => Watir and Selenium
|
100
|
+
# * :css => Selenium only
|
100
101
|
# * :id => Watir and Selenium
|
101
102
|
# * :index => Watir and Selenium
|
102
103
|
# * :label => Watir and Selenium
|
@@ -71,9 +71,12 @@ module PageObject
|
|
71
71
|
#
|
72
72
|
def alert(frame=nil, &block)
|
73
73
|
yield
|
74
|
-
|
75
|
-
|
76
|
-
|
74
|
+
begin
|
75
|
+
alert = @browser.switch_to.alert
|
76
|
+
value = alert.text
|
77
|
+
alert.accept
|
78
|
+
rescue Selenium::WebDriver::Error::NoAlertPresentError
|
79
|
+
end
|
77
80
|
value
|
78
81
|
end
|
79
82
|
|
@@ -83,9 +86,12 @@ module PageObject
|
|
83
86
|
#
|
84
87
|
def confirm(response, frame=nil, &block)
|
85
88
|
yield
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
+
begin
|
90
|
+
alert = @browser.switch_to.alert
|
91
|
+
value = alert.text
|
92
|
+
response ? alert.accept : alert.dismiss
|
93
|
+
rescue Selenium::WebDriver::Error::NoAlertPresentError
|
94
|
+
end
|
89
95
|
value
|
90
96
|
end
|
91
97
|
|
@@ -291,9 +297,13 @@ module PageObject
|
|
291
297
|
#
|
292
298
|
def select_list_value_for(identifier)
|
293
299
|
process_selenium_call(identifier, Elements::SelectList, 'select') do |how, what|
|
300
|
+
selected = nil
|
294
301
|
@browser.find_element(how, what).find_elements(:tag_name => 'option').each do |o|
|
295
|
-
|
302
|
+
if selected.nil?
|
303
|
+
selected = o.text if o.selected?
|
304
|
+
end
|
296
305
|
end
|
306
|
+
selected
|
297
307
|
end
|
298
308
|
end
|
299
309
|
|
@@ -42,12 +42,19 @@ module PageObject
|
|
42
42
|
end
|
43
43
|
|
44
44
|
#
|
45
|
-
# @return [Array<String>] An array of strings representing the text
|
45
|
+
# @return [Array<String>] An array of strings representing the text of the currently selected options.
|
46
46
|
#
|
47
47
|
def selected_options
|
48
48
|
find_options.map { |e| e.text if e.selected? }.compact
|
49
49
|
end
|
50
50
|
|
51
|
+
#
|
52
|
+
# @return [Array<String>] An array of strings representing the value of the currently selected options.
|
53
|
+
#
|
54
|
+
def selected_values
|
55
|
+
find_options.map { |e| e.attribute('value') if e.selected? }.compact
|
56
|
+
end
|
57
|
+
|
51
58
|
#
|
52
59
|
# Returns true if the select list has one or more options where text or label matches the given value.
|
53
60
|
#
|
@@ -72,8 +72,11 @@ module PageObject
|
|
72
72
|
def alert(frame=nil, &block)
|
73
73
|
switch_to_frame(frame)
|
74
74
|
yield
|
75
|
-
value =
|
76
|
-
@browser.alert.
|
75
|
+
value = nil
|
76
|
+
if @browser.alert.exists?
|
77
|
+
value = @browser.alert.text
|
78
|
+
@browser.alert.ok
|
79
|
+
end
|
77
80
|
switch_to_default_content(frame)
|
78
81
|
value
|
79
82
|
end
|
@@ -85,8 +88,11 @@ module PageObject
|
|
85
88
|
def confirm(response, frame=nil, &block)
|
86
89
|
switch_to_frame(frame)
|
87
90
|
yield
|
88
|
-
value =
|
89
|
-
|
91
|
+
value = nil
|
92
|
+
if @browser.alert.exists?
|
93
|
+
value = @browser.alert.text
|
94
|
+
response ? @browser.alert.ok : @browser.alert.close
|
95
|
+
end
|
90
96
|
switch_to_default_content(frame)
|
91
97
|
value
|
92
98
|
end
|
@@ -43,12 +43,20 @@ module PageObject
|
|
43
43
|
end
|
44
44
|
|
45
45
|
#
|
46
|
-
# @return [Array<String>] An array of strings representing the text
|
46
|
+
# @return [Array<String>] An array of strings representing the text of the currently selected options.
|
47
47
|
#
|
48
48
|
def selected_options
|
49
49
|
element.selected_options.map { |e| e.text }.compact
|
50
50
|
end
|
51
51
|
|
52
|
+
#
|
53
|
+
# @return [Array<String>] An array of strings representing the value of the currently selected options.
|
54
|
+
#
|
55
|
+
def selected_values
|
56
|
+
element.selected_options.map { |e| e.value }.compact
|
57
|
+
end
|
58
|
+
|
59
|
+
|
52
60
|
#
|
53
61
|
# Returns true if the select list has one or more options where text or label matches the given value.
|
54
62
|
#
|
data/lib/page-object/version.rb
CHANGED
@@ -67,6 +67,12 @@ describe PageObject::Elements::SelectList do
|
|
67
67
|
sel_list.stub(:selected?).with('blah').and_return(true)
|
68
68
|
watir_sel_list.selected?('blah')
|
69
69
|
end
|
70
|
+
|
71
|
+
it "should be able to get the value for the selected options" do
|
72
|
+
sel_list.stub(:selected_options).and_return(opts)
|
73
|
+
sel_list.stub(:value).and_return(sel_list)
|
74
|
+
watir_sel_list.selected_values.should == opts
|
75
|
+
end
|
70
76
|
end
|
71
77
|
|
72
78
|
context "for selenium" do
|
@@ -100,6 +106,16 @@ describe PageObject::Elements::SelectList do
|
|
100
106
|
selected[0].should == 'test1'
|
101
107
|
end
|
102
108
|
|
109
|
+
it "should return an array of selected options" do
|
110
|
+
sel_list.should_receive(:find_elements).with(:xpath, ".//child::option").and_return(opts)
|
111
|
+
opts[0].should_receive(:selected?).and_return(true)
|
112
|
+
opts[0].should_receive(:attribute).and_return('test1')
|
113
|
+
opts[1].should_receive(:selected?).and_return(false)
|
114
|
+
selected = selenium_sel_list.selected_values
|
115
|
+
selected.size.should == 1
|
116
|
+
selected[0].should == 'test1'
|
117
|
+
end
|
118
|
+
|
103
119
|
it "should know if it includes some value" do
|
104
120
|
sel_list.should_receive(:find_elements).and_return(opts)
|
105
121
|
opts[0].should_receive(:text).and_return('blah')
|
@@ -123,7 +123,8 @@ describe PageObject do
|
|
123
123
|
end
|
124
124
|
|
125
125
|
it "should override alert popup behavior" do
|
126
|
-
watir_browser.should_receive(:alert).
|
126
|
+
watir_browser.should_receive(:alert).exactly(3).times.and_return(watir_browser)
|
127
|
+
watir_browser.should_receive(:exists?).and_return(true)
|
127
128
|
watir_browser.should_receive(:text)
|
128
129
|
watir_browser.should_receive(:ok)
|
129
130
|
watir_page_object.alert do
|
@@ -131,7 +132,8 @@ describe PageObject do
|
|
131
132
|
end
|
132
133
|
|
133
134
|
it "should override confirm popup behavior" do
|
134
|
-
watir_browser.should_receive(:alert).
|
135
|
+
watir_browser.should_receive(:alert).exactly(3).times.and_return(watir_browser)
|
136
|
+
watir_browser.should_receive(:exists?).and_return(true)
|
135
137
|
watir_browser.should_receive(:text)
|
136
138
|
watir_browser.should_receive(:ok)
|
137
139
|
watir_page_object.confirm(true) do
|
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.7.
|
4
|
+
version: 0.7.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08
|
12
|
+
date: 2012-09-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: watir-webdriver
|
@@ -370,7 +370,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
370
370
|
version: '0'
|
371
371
|
segments:
|
372
372
|
- 0
|
373
|
-
hash:
|
373
|
+
hash: -734083501090794232
|
374
374
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
375
375
|
none: false
|
376
376
|
requirements:
|
@@ -379,7 +379,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
379
379
|
version: '0'
|
380
380
|
segments:
|
381
381
|
- 0
|
382
|
-
hash:
|
382
|
+
hash: -734083501090794232
|
383
383
|
requirements: []
|
384
384
|
rubyforge_project: page-object
|
385
385
|
rubygems_version: 1.8.24
|