page-object 0.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'page-object/elements'
|
|
3
|
-
|
|
4
|
-
describe PageObject::Elements::Button do
|
|
5
|
-
let(:button) { PageObject::Elements::Button }
|
|
6
|
-
|
|
7
|
-
context "when mapping how to find an element" do
|
|
8
|
-
it "should map watir types to same" do
|
|
9
|
-
[:class, :id, :index, :name, :xpath].each do |t|
|
|
10
|
-
identifier = button.watir_identifier_for t => 'value'
|
|
11
|
-
identifier.keys.first.should == t
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it "should map selenium types to same" do
|
|
16
|
-
[:class, :id, :index, :name, :xpath].each do |t|
|
|
17
|
-
key, value = button.selenium_identifier_for t => 'value'
|
|
18
|
-
key.should == t
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
describe "interface" do
|
|
24
|
-
let(:button_element) { double('button_element') }
|
|
25
|
-
|
|
26
|
-
context "for selenium" do
|
|
27
|
-
it "should return error when asked for its' text" do
|
|
28
|
-
button = PageObject::Elements::Button.new(button_element, :platform => :selenium)
|
|
29
|
-
lambda {button.text}.should raise_error
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'page-object/elements'
|
|
3
|
+
|
|
4
|
+
describe PageObject::Elements::Button do
|
|
5
|
+
let(:button) { PageObject::Elements::Button }
|
|
6
|
+
|
|
7
|
+
context "when mapping how to find an element" do
|
|
8
|
+
it "should map watir types to same" do
|
|
9
|
+
[:class, :id, :index, :name, :xpath].each do |t|
|
|
10
|
+
identifier = button.watir_identifier_for t => 'value'
|
|
11
|
+
identifier.keys.first.should == t
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should map selenium types to same" do
|
|
16
|
+
[:class, :id, :index, :name, :xpath].each do |t|
|
|
17
|
+
key, value = button.selenium_identifier_for t => 'value'
|
|
18
|
+
key.should == t
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe "interface" do
|
|
24
|
+
let(:button_element) { double('button_element') }
|
|
25
|
+
|
|
26
|
+
context "for selenium" do
|
|
27
|
+
it "should return error when asked for its' text" do
|
|
28
|
+
button = PageObject::Elements::Button.new(button_element, :platform => :selenium)
|
|
29
|
+
lambda { button.text }.should raise_error
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
34
|
end
|
|
@@ -3,7 +3,7 @@ require 'page-object/elements'
|
|
|
3
3
|
|
|
4
4
|
describe PageObject::Elements::CheckBox do
|
|
5
5
|
let(:checkbox) { PageObject::Elements::CheckBox }
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
describe "when mapping how to find an element" do
|
|
8
8
|
it "should map watir types to same" do
|
|
9
9
|
[:class, :id, :index, :name, :xpath].each do |t|
|
|
@@ -3,17 +3,17 @@ require 'page-object/elements'
|
|
|
3
3
|
|
|
4
4
|
describe PageObject::Elements::Div do
|
|
5
5
|
let(:div) { PageObject::Elements::Div }
|
|
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, :xpath].each do |t|
|
|
9
|
+
[:class, :id, :text, :index, :xpath].each do |t|
|
|
10
10
|
identifier = div.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, :text, :index, :name, :xpath].each do |t|
|
|
17
17
|
key, value = div.selenium_identifier_for t => 'value'
|
|
18
18
|
key.should == t
|
|
19
19
|
end
|
|
@@ -7,7 +7,7 @@ describe PageObject::Elements::Element do
|
|
|
7
7
|
let(:selenium_driver) { double('selenium') }
|
|
8
8
|
let(:watir_element) { PageObject::Elements::Element.new(watir_driver, :platform => :watir) }
|
|
9
9
|
let(:selenium_element) { PageObject::Elements::Element.new(selenium_driver, :platform => :selenium) }
|
|
10
|
-
let(:element) {PageObject::Elements::Element}
|
|
10
|
+
let(:element) { PageObject::Elements::Element }
|
|
11
11
|
|
|
12
12
|
context "when building the identifiers for Watir" do
|
|
13
13
|
it "should build xpath when finding elements by name where not supported" do
|
|
@@ -18,16 +18,16 @@ describe PageObject::Elements::Element do
|
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
context "when building the identifiers for Selenium" do
|
|
23
23
|
def all_basic_elements
|
|
24
24
|
['textarea', 'select', 'a', 'div', 'span', 'table', 'td', 'img', 'form', 'li', 'ul', 'ol']
|
|
25
25
|
end
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
def all_input_elements
|
|
28
28
|
['text', 'hidden', 'checkbox', 'radio', 'submit']
|
|
29
29
|
end
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
it "should build xpath when index is provided for basic elements" do
|
|
32
32
|
all_basic_elements.each do |tag|
|
|
33
33
|
identifier = {:tag_name => tag, :index => 1}
|
|
@@ -36,7 +36,7 @@ describe PageObject::Elements::Element do
|
|
|
36
36
|
what.should == ".//#{tag}[2]"
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
it "should should build xpath when index is provided for input elements" do
|
|
41
41
|
all_input_elements.each do |tag|
|
|
42
42
|
identifier = {:tag_name => 'input', :type => tag, :index => 1}
|
|
@@ -45,7 +45,7 @@ describe PageObject::Elements::Element do
|
|
|
45
45
|
what.should == ".//input[@type='#{tag}'][2]"
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
it "should build xpath when locating basic elements by name and index" do
|
|
50
50
|
all_basic_elements.each do |tag|
|
|
51
51
|
identifier = {:tag_name => tag, :name => 'blah', :index => 0}
|
|
@@ -54,7 +54,7 @@ describe PageObject::Elements::Element do
|
|
|
54
54
|
what.should == ".//#{tag}[@name='blah'][1]"
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
it "should build xpath when locating input elements by name and index" do
|
|
59
59
|
all_input_elements.each do |type|
|
|
60
60
|
identifier = {:tag_name => 'input', :type => "#{type}", :name => 'blah', :index => 0}
|
|
@@ -63,14 +63,14 @@ describe PageObject::Elements::Element do
|
|
|
63
63
|
what.should == ".//input[@type='#{type}' and @name='blah'][1]"
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
|
-
|
|
66
|
+
|
|
67
67
|
it "should build xpath when locating basic elements by name and class" do
|
|
68
68
|
all_basic_elements.each do |tag|
|
|
69
69
|
identifier = {:tag_name => tag, :name => 'foo', :class => 'bar'}
|
|
70
70
|
how, what = element.selenium_identifier_for identifier
|
|
71
71
|
how.should == :xpath
|
|
72
72
|
what.should == ".//#{tag}[@name='foo' and @class='bar']"
|
|
73
|
-
end
|
|
73
|
+
end
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
it "should build xpath when locating input elements by name and class" do
|
|
@@ -78,7 +78,7 @@ describe PageObject::Elements::Element do
|
|
|
78
78
|
identifier = {:tag_name => 'input', :type => "#{type}", :name => 'foo', :class => 'bar'}
|
|
79
79
|
how, what = element.selenium_identifier_for identifier
|
|
80
80
|
what.should == ".//input[@type='#{type}' and @name='foo' and @class='bar']"
|
|
81
|
-
end
|
|
81
|
+
end
|
|
82
82
|
end
|
|
83
83
|
end
|
|
84
84
|
|
|
@@ -87,118 +87,123 @@ describe PageObject::Elements::Element do
|
|
|
87
87
|
watir_driver.should_receive(:present?).and_return(true)
|
|
88
88
|
watir_element.visible?.should == true
|
|
89
89
|
end
|
|
90
|
-
|
|
90
|
+
|
|
91
91
|
it "should know when it is not visible" do
|
|
92
92
|
watir_driver.should_receive(:present?).and_return(false)
|
|
93
93
|
watir_element.visible?.should == false
|
|
94
94
|
end
|
|
95
|
-
|
|
95
|
+
|
|
96
96
|
it "should know when it exists" do
|
|
97
97
|
watir_driver.should_receive(:exists?).and_return(true)
|
|
98
98
|
watir_element.exists?.should == true
|
|
99
99
|
end
|
|
100
|
-
|
|
100
|
+
|
|
101
101
|
it "should know when it does not exist" do
|
|
102
102
|
watir_driver.should_receive(:exists?).and_return(false)
|
|
103
103
|
watir_element.exists?.should == false
|
|
104
104
|
end
|
|
105
|
-
|
|
105
|
+
|
|
106
106
|
it "should be able to return the text contained in the element" do
|
|
107
107
|
watir_driver.should_receive(:text).and_return("my text")
|
|
108
108
|
watir_element.text.should == "my text"
|
|
109
109
|
end
|
|
110
|
-
|
|
110
|
+
|
|
111
111
|
it "should know when it is equal to another" do
|
|
112
112
|
watir_driver.should_receive(:==).and_return(true)
|
|
113
113
|
watir_element.should == watir_element
|
|
114
114
|
end
|
|
115
|
-
|
|
115
|
+
|
|
116
116
|
it "should return its tag name" do
|
|
117
117
|
watir_driver.should_receive(:tag_name).and_return("h1")
|
|
118
118
|
watir_element.tag_name.should == "h1"
|
|
119
119
|
end
|
|
120
|
-
|
|
120
|
+
|
|
121
121
|
it "should know its value" do
|
|
122
122
|
watir_driver.should_receive(:value).and_return("value")
|
|
123
123
|
watir_element.value.should == "value"
|
|
124
124
|
end
|
|
125
|
-
|
|
125
|
+
|
|
126
126
|
it "should know how to retrieve the value of an attribute" do
|
|
127
127
|
watir_driver.should_receive(:attribute_value).and_return(true)
|
|
128
128
|
watir_element.attribute("readonly").should be_true
|
|
129
129
|
end
|
|
130
|
-
|
|
130
|
+
|
|
131
131
|
it "should be clickable" do
|
|
132
132
|
watir_driver.should_receive(:click)
|
|
133
133
|
watir_element.click
|
|
134
134
|
end
|
|
135
|
-
|
|
135
|
+
|
|
136
136
|
it "should be able to block until it is present" do
|
|
137
137
|
watir_driver.should_receive(:wait_until_present).with(10)
|
|
138
138
|
watir_element.when_present(10)
|
|
139
139
|
end
|
|
140
|
-
|
|
140
|
+
|
|
141
141
|
it "should be able to block until it is visible" do
|
|
142
142
|
Watir::Wait.should_receive(:until).with(10, "Element was not visible in 10 seconds")
|
|
143
143
|
watir_element.when_visible(10)
|
|
144
144
|
end
|
|
145
|
-
|
|
145
|
+
|
|
146
146
|
it "should be able to block until it is not visible" do
|
|
147
147
|
Watir::Wait.should_receive(:while).with(10, "Element still visible after 10 seconds")
|
|
148
148
|
watir_element.when_not_visible(10)
|
|
149
149
|
end
|
|
150
|
-
|
|
150
|
+
|
|
151
151
|
it "should be able to block until a user define event fires true" do
|
|
152
152
|
Watir::Wait.should_receive(:until).with(10, "Element blah")
|
|
153
153
|
watir_element.wait_until(10, "Element blah") {}
|
|
154
154
|
end
|
|
155
|
+
|
|
156
|
+
it "should send keys to the element" do
|
|
157
|
+
watir_driver.should_receive(:send_keys).with([:control, 'a'])
|
|
158
|
+
watir_element.send_keys([:control, 'a'])
|
|
159
|
+
end
|
|
155
160
|
end
|
|
156
|
-
|
|
161
|
+
|
|
157
162
|
context "when using Selenium" do
|
|
158
163
|
it "should know when it is visible" do
|
|
159
164
|
selenium_driver.should_receive(:displayed?).and_return(true)
|
|
160
165
|
selenium_element.visible?.should == true
|
|
161
166
|
end
|
|
162
|
-
|
|
167
|
+
|
|
163
168
|
it "should know when it is not visible" do
|
|
164
169
|
selenium_driver.should_receive(:displayed?).and_return(false)
|
|
165
170
|
selenium_element.visible?.should == false
|
|
166
171
|
end
|
|
167
|
-
|
|
172
|
+
|
|
168
173
|
it "should know when it exists" do
|
|
169
|
-
selenium_element.exists?.should == true
|
|
174
|
+
selenium_element.exists?.should == true
|
|
170
175
|
end
|
|
171
|
-
|
|
176
|
+
|
|
172
177
|
it "should know when it does not exist" do
|
|
173
178
|
selenium_element = PageObject::Elements::Element.new(nil, :platform => :selenium)
|
|
174
179
|
selenium_element.exists?.should == false
|
|
175
180
|
end
|
|
176
|
-
|
|
181
|
+
|
|
177
182
|
it "should be able to return the text contained in the element" do
|
|
178
183
|
selenium_driver.should_receive(:text).and_return("my text")
|
|
179
184
|
selenium_element.text.should == "my text"
|
|
180
185
|
end
|
|
181
|
-
|
|
186
|
+
|
|
182
187
|
it "should know when it is equal to another" do
|
|
183
188
|
selenium_driver.should_receive(:==).and_return(true)
|
|
184
189
|
selenium_element.should == selenium_element
|
|
185
190
|
end
|
|
186
|
-
|
|
191
|
+
|
|
187
192
|
it "should return its tag name" do
|
|
188
193
|
selenium_driver.should_receive(:tag_name).and_return("h1")
|
|
189
194
|
selenium_element.tag_name.should == "h1"
|
|
190
195
|
end
|
|
191
|
-
|
|
196
|
+
|
|
192
197
|
it "should know its value" do
|
|
193
198
|
selenium_driver.should_receive(:attribute).with('value').and_return("value")
|
|
194
199
|
selenium_element.value.should == "value"
|
|
195
200
|
end
|
|
196
|
-
|
|
201
|
+
|
|
197
202
|
it "should know how to retrieve the value of an attribute" do
|
|
198
203
|
selenium_driver.should_receive(:attribute).and_return(true)
|
|
199
204
|
selenium_element.attribute('readonly').should be_true
|
|
200
205
|
end
|
|
201
|
-
|
|
206
|
+
|
|
202
207
|
it "should be clickable" do
|
|
203
208
|
selenium_driver.should_receive(:click)
|
|
204
209
|
selenium_element.click
|
|
@@ -206,30 +211,35 @@ describe PageObject::Elements::Element do
|
|
|
206
211
|
|
|
207
212
|
it "should be able to block until it is present" do
|
|
208
213
|
wait = double('wait')
|
|
209
|
-
Selenium::WebDriver::Wait.should_receive(:new).and_return(wait)
|
|
214
|
+
Object::Selenium::WebDriver::Wait.should_receive(:new).and_return(wait)
|
|
210
215
|
wait.should_receive(:until)
|
|
211
216
|
selenium_element.when_present(10)
|
|
212
217
|
end
|
|
213
|
-
|
|
218
|
+
|
|
214
219
|
it "should be able to block until it is visible" do
|
|
215
220
|
wait = double('wait')
|
|
216
|
-
Selenium::WebDriver::Wait.should_receive(:new).and_return(wait)
|
|
221
|
+
Object::Selenium::WebDriver::Wait.should_receive(:new).and_return(wait)
|
|
217
222
|
wait.should_receive(:until)
|
|
218
223
|
selenium_element.when_visible(10)
|
|
219
224
|
end
|
|
220
|
-
|
|
225
|
+
|
|
221
226
|
it "should be able to block until it is not visible" do
|
|
222
227
|
wait = double('wait')
|
|
223
|
-
Selenium::WebDriver::Wait.should_receive(:new).and_return(wait)
|
|
228
|
+
Object::Selenium::WebDriver::Wait.should_receive(:new).and_return(wait)
|
|
224
229
|
wait.should_receive(:until)
|
|
225
230
|
selenium_element.when_not_visible(10)
|
|
226
231
|
end
|
|
227
|
-
|
|
232
|
+
|
|
228
233
|
it "should be able to block until a user define event fires true" do
|
|
229
234
|
wait = double('wait')
|
|
230
|
-
Selenium::WebDriver::Wait.should_receive(:new).and_return(wait)
|
|
235
|
+
Object::Selenium::WebDriver::Wait.should_receive(:new).and_return(wait)
|
|
231
236
|
wait.should_receive(:until)
|
|
232
237
|
selenium_element.wait_until(10, "Element blah") {}
|
|
233
238
|
end
|
|
239
|
+
|
|
240
|
+
it "should send keys to the element" do
|
|
241
|
+
selenium_driver.should_receive(:send_keys).with([:control, 'a'])
|
|
242
|
+
selenium_element.send_keys([:control, 'a'])
|
|
243
|
+
end
|
|
234
244
|
end
|
|
235
245
|
end
|
|
@@ -4,7 +4,7 @@ require 'page-object/elements'
|
|
|
4
4
|
describe PageObject::Elements::Form do
|
|
5
5
|
describe "interface" do
|
|
6
6
|
let(:form_element) { double('form_element') }
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
context "for watir" do
|
|
9
9
|
it "should submit a form" do
|
|
10
10
|
form = PageObject::Elements::Form.new(form_element, :platform => :watir)
|
|
@@ -12,13 +12,13 @@ describe PageObject::Elements::Form do
|
|
|
12
12
|
form.submit
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
context "for selenium" do
|
|
17
17
|
it "should submit a form" do
|
|
18
18
|
form = PageObject::Elements::Form.new(form_element, :platform => :selenium)
|
|
19
19
|
form_element.should_receive(:submit)
|
|
20
20
|
form.submit
|
|
21
|
-
end
|
|
21
|
+
end
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
end
|
|
@@ -3,7 +3,7 @@ require 'page-object/elements'
|
|
|
3
3
|
|
|
4
4
|
describe PageObject::Elements::HiddenField do
|
|
5
5
|
let(:hiddenfield) { PageObject::Elements::HiddenField }
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
describe "when mapping how to find an element" do
|
|
8
8
|
it "should map watir types to same" do
|
|
9
9
|
[:class, :id, :index, :name, :tag_name, :text, :xpath].each do |t|
|
|
@@ -16,14 +16,14 @@ describe PageObject::Elements::HiddenField do
|
|
|
16
16
|
identifier = hiddenfield.watir_identifier_for :css => 'value'
|
|
17
17
|
identifier.keys.first.should == :tag_name
|
|
18
18
|
end
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
it "should map selenium types to same" do
|
|
21
21
|
[:class, :css, :id, :name, :xpath, :index].each do |t|
|
|
22
22
|
key, value = hiddenfield.selenium_identifier_for t => 'value'
|
|
23
23
|
key.should == t
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
it "should map watir types to selenium" do
|
|
28
28
|
key, value = hiddenfield.selenium_identifier_for :tag_name => 'value'
|
|
29
29
|
key.should == :css
|
|
@@ -3,7 +3,7 @@ require 'page-object/elements'
|
|
|
3
3
|
|
|
4
4
|
describe PageObject::Elements::Image do
|
|
5
5
|
let(:image) { PageObject::Elements::Image }
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
describe "when mapping how to find an element" do
|
|
8
8
|
it "should map watir types to same" do
|
|
9
9
|
[:class, :id, :index, :name, :xpath].each do |t|
|
|
@@ -19,28 +19,28 @@ describe PageObject::Elements::Image do
|
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
describe "interface" do
|
|
24
24
|
let(:image_element) { double('image_element') }
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
before(:each) do
|
|
27
27
|
image_element.stub(:size).and_return(image_element)
|
|
28
28
|
end
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
context "for watir" do
|
|
31
31
|
it "should know the images width" do
|
|
32
32
|
image = PageObject::Elements::Image.new(image_element, :platform => :watir)
|
|
33
33
|
image_element.should_receive(:width).and_return(100)
|
|
34
34
|
image.width.should == 100
|
|
35
35
|
end
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
it "should know the images height" do
|
|
38
38
|
image = PageObject::Elements::Image.new(image_element, :platform => :watir)
|
|
39
39
|
image_element.should_receive(:height).and_return(120)
|
|
40
40
|
image.height.should == 120
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
context "for selenium" do
|
|
45
45
|
it "should know the images width" do
|
|
46
46
|
dim = double('dimension')
|
|
@@ -49,7 +49,7 @@ describe PageObject::Elements::Image do
|
|
|
49
49
|
dim.should_receive(:width).and_return(100)
|
|
50
50
|
image.width.should == 100
|
|
51
51
|
end
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
it "should know the images height" do
|
|
54
54
|
dim = double('dimension')
|
|
55
55
|
image = PageObject::Elements::Image.new(image_element, :platform => :selenium)
|