page-object 0.5.4 → 0.5.5
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 -0
- data/features/check_box.feature +1 -0
- data/features/element.feature +13 -0
- data/features/hidden_field.feature +1 -0
- data/features/html/static_elements.html +7 -0
- data/features/nested_elements.feature +1 -1
- data/features/step_definitions/element_steps.rb +24 -0
- data/features/support/env.rb +0 -25
- data/features/support/hooks.rb +7 -0
- data/features/support/page.rb +3 -1
- data/features/support/persistent_browser.rb +16 -0
- data/lib/page-object/accessors.rb +2 -0
- data/lib/page-object/elements.rb +29 -0
- data/lib/page-object/elements/button.rb +5 -0
- data/lib/page-object/elements/check_box.rb +11 -0
- data/lib/page-object/elements/div.rb +3 -1
- data/lib/page-object/elements/element.rb +2 -1
- data/lib/page-object/elements/file_field.rb +3 -0
- data/lib/page-object/elements/form.rb +2 -0
- data/lib/page-object/elements/heading.rb +9 -1
- data/lib/page-object/elements/hidden_field.rb +5 -3
- data/lib/page-object/elements/image.rb +3 -1
- data/lib/page-object/elements/link.rb +3 -0
- data/lib/page-object/elements/list_item.rb +4 -1
- data/lib/page-object/elements/option.rb +3 -0
- data/lib/page-object/elements/ordered_list.rb +2 -0
- data/lib/page-object/elements/paragraph.rb +3 -1
- data/lib/page-object/elements/radio_button.rb +2 -0
- data/lib/page-object/elements/select_list.rb +2 -0
- data/lib/page-object/elements/span.rb +4 -1
- data/lib/page-object/elements/table.rb +2 -0
- data/lib/page-object/elements/table_cell.rb +5 -1
- data/lib/page-object/elements/table_row.rb +2 -0
- data/lib/page-object/elements/text_area.rb +3 -0
- data/lib/page-object/elements/text_field.rb +3 -0
- data/lib/page-object/elements/unordered_list.rb +3 -1
- data/lib/page-object/page_populator.rb +7 -3
- data/lib/page-object/platforms/selenium_webdriver/element.rb +33 -0
- data/lib/page-object/platforms/selenium_webdriver/page_object.rb +10 -8
- data/lib/page-object/platforms/watir_webdriver/element.rb +24 -0
- data/lib/page-object/platforms/watir_webdriver/file_field.rb +1 -1
- data/lib/page-object/version.rb +1 -1
- data/spec/page-object/elements/button_spec.rb +16 -0
- data/spec/page-object/elements/check_box_spec.rb +5 -2
- data/spec/page-object/elements/div_spec.rb +7 -1
- data/spec/page-object/elements/file_field_spec.rb +4 -0
- data/spec/page-object/elements/form_spec.rb +5 -1
- data/spec/page-object/elements/heading_spec.rb +27 -1
- data/spec/page-object/elements/hidden_field_spec.rb +9 -3
- data/spec/page-object/elements/image_spec.rb +4 -0
- data/spec/page-object/elements/link_spec.rb +5 -1
- data/spec/page-object/elements/list_item_spec.rb +7 -1
- data/spec/page-object/elements/option_spec.rb +11 -0
- data/spec/page-object/elements/ordered_list_spec.rb +5 -1
- data/spec/page-object/elements/paragraph_spec.rb +28 -0
- data/spec/page-object/elements/radio_button_spec.rb +5 -0
- data/spec/page-object/elements/select_list_spec.rb +4 -0
- data/spec/page-object/elements/selenium_element_spec.rb +24 -1
- data/spec/page-object/elements/span_spec.rb +5 -1
- data/spec/page-object/elements/table_cell_spec.rb +15 -0
- data/spec/page-object/elements/table_row_spec.rb +6 -1
- data/spec/page-object/elements/table_spec.rb +4 -0
- data/spec/page-object/elements/text_area_spec.rb +6 -1
- data/spec/page-object/elements/text_field_spec.rb +8 -0
- data/spec/page-object/elements/unordered_list_spec.rb +5 -1
- data/spec/page-object/page_populator_spec.rb +31 -2
- metadata +22 -12
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'page-object/elements'
|
3
|
+
|
4
|
+
describe PageObject::Elements::Paragraph do
|
5
|
+
let(:paragraph) { PageObject::Elements::Paragraph }
|
6
|
+
|
7
|
+
describe "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 = paragraph.watir_identifier_for t => 'value'
|
11
|
+
identifier.keys.first.should == t
|
12
|
+
end
|
13
|
+
end
|
14
|
+
it "should map selenium types to same" do
|
15
|
+
[:class, :id, :name, :xpath, :index].each do |t|
|
16
|
+
key, value = paragraph.selenium_identifier_for t => 'value'
|
17
|
+
key.should == t
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "interface" do
|
23
|
+
|
24
|
+
it "should register with type :checkbox" do
|
25
|
+
::PageObject::Elements.element_class_for(:p).should == ::PageObject::Elements::Paragraph
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -20,6 +20,11 @@ describe PageObject::Elements::RadioButton do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
describe "interface" do
|
23
|
+
|
24
|
+
it "should register as type :radio" do
|
25
|
+
::PageObject::Elements.element_class_for(:input, :radio).should == ::PageObject::Elements::RadioButton
|
26
|
+
end
|
27
|
+
|
23
28
|
context "for selenium" do
|
24
29
|
let(:selenium_rb) { double('radio_button') }
|
25
30
|
let(:radio_button) { PageObject::Elements::RadioButton.new(selenium_rb, :platform => :selenium_webdriver) }
|
@@ -29,6 +29,10 @@ describe PageObject::Elements::SelectList do
|
|
29
29
|
sel_list.stub(:each)
|
30
30
|
end
|
31
31
|
|
32
|
+
it "should register with tag_name :select" do
|
33
|
+
::PageObject::Elements.element_class_for(:select).should == ::PageObject::Elements::SelectList
|
34
|
+
end
|
35
|
+
|
32
36
|
context "for watir" do
|
33
37
|
it "should return an option when indexed" do
|
34
38
|
watir_sel_list = PageObject::Elements::SelectList.new(sel_list, :platform => :watir_webdriver)
|
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'page-object/elements'
|
2
|
+
require 'selenium-webdriver'
|
3
|
+
|
1
4
|
|
2
5
|
describe "Element for Selenium" do
|
3
6
|
before(:each) do
|
@@ -16,6 +19,7 @@ describe "Element for Selenium" do
|
|
16
19
|
end
|
17
20
|
|
18
21
|
it "should know when it exists" do
|
22
|
+
@selenium_driver.should_receive(:nil?).and_return(false)
|
19
23
|
@selenium_element.exists?.should == true
|
20
24
|
end
|
21
25
|
|
@@ -125,4 +129,23 @@ describe "Element for Selenium" do
|
|
125
129
|
@selenium_driver.should_receive(:clear)
|
126
130
|
@selenium_element.clear
|
127
131
|
end
|
128
|
-
|
132
|
+
|
133
|
+
it "should fire an event" do
|
134
|
+
@selenium_driver.should_receive(:instance_variable_get).with(:@bridge).and_return(@selenium_driver)
|
135
|
+
@selenium_driver.should_receive(:executeScript)
|
136
|
+
@selenium_element.fire_event('onfocus')
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should find the parent element" do
|
140
|
+
@selenium_driver.should_receive(:instance_variable_get).with(:@bridge).and_return(@selenium_driver)
|
141
|
+
@selenium_driver.should_receive(:executeScript).and_return(@selenium_driver)
|
142
|
+
@selenium_driver.should_receive(:tag_name).twice.and_return(:div)
|
143
|
+
@selenium_element.parent
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should set the focus" do
|
147
|
+
@selenium_driver.should_receive(:instance_variable_get).and_return(@selenium_driver)
|
148
|
+
@selenium_driver.should_receive(:executeScript)
|
149
|
+
@selenium_element.focus
|
150
|
+
end
|
151
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'page-object/elements'
|
3
|
+
|
4
|
+
describe PageObject::Elements::TableCell do
|
5
|
+
|
6
|
+
context "interface" do
|
7
|
+
it "should register with tag_name :td" do
|
8
|
+
::PageObject::Elements.element_class_for(:td).should == ::PageObject::Elements::TableCell
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should register with tag_name :th" do
|
12
|
+
::PageObject::Elements.element_class_for(:th).should == ::PageObject::Elements::TableCell
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -6,6 +6,11 @@ describe PageObject::Elements::TableRow do
|
|
6
6
|
let(:table_row_driver) { double('table_row_driver') }
|
7
7
|
|
8
8
|
describe "interface" do
|
9
|
+
|
10
|
+
it "should register with tag_name :tr" do
|
11
|
+
::PageObject::Elements.element_class_for(:tr).should == ::PageObject::Elements::TableRow
|
12
|
+
end
|
13
|
+
|
9
14
|
context "for selenium" do
|
10
15
|
it "should return a table cell when indexed" do
|
11
16
|
table_row = PageObject::Elements::TableRow.new(table_row_driver, :platform => :selenium_webdriver)
|
@@ -60,4 +65,4 @@ describe PageObject::Elements::TableRow do
|
|
60
65
|
end
|
61
66
|
end
|
62
67
|
end
|
63
|
-
end
|
68
|
+
end
|
@@ -26,6 +26,10 @@ describe PageObject::Elements::Table do
|
|
26
26
|
table_element.stub(:find_elements).and_return(table_element)
|
27
27
|
end
|
28
28
|
|
29
|
+
it "should register with tag_name :table" do
|
30
|
+
::PageObject::Elements.element_class_for(:table).should == ::PageObject::Elements::Table
|
31
|
+
end
|
32
|
+
|
29
33
|
context "for watir" do
|
30
34
|
let(:watir_table) { PageObject::Elements::Table.new(table_element, :platform => :watir_webdriver) }
|
31
35
|
|
@@ -31,6 +31,11 @@ describe PageObject::Elements::TextArea do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
describe "interface" do
|
34
|
+
|
35
|
+
it "should register with tag_name :textarea" do
|
36
|
+
::PageObject::Elements.element_class_for(:textarea).should == ::PageObject::Elements::TextArea
|
37
|
+
end
|
38
|
+
|
34
39
|
context "for Selenium" do
|
35
40
|
it "should set its' value" do
|
36
41
|
text_area_element = double('text_area')
|
@@ -41,4 +46,4 @@ describe PageObject::Elements::TextArea do
|
|
41
46
|
end
|
42
47
|
end
|
43
48
|
end
|
44
|
-
end
|
49
|
+
end
|
@@ -32,6 +32,14 @@ describe PageObject::Elements::TextField do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe "interface" do
|
35
|
+
it "should register with type :text" do
|
36
|
+
::PageObject::Elements.element_class_for(:input, :text).should == ::PageObject::Elements::TextField
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should register with type :password" do
|
40
|
+
::PageObject::Elements.element_class_for(:input, :password).should == ::PageObject::Elements::TextField
|
41
|
+
end
|
42
|
+
|
35
43
|
context "for selenium" do
|
36
44
|
it "should set its' value" do
|
37
45
|
text_field_element = double('selenium_text_field')
|
@@ -23,6 +23,10 @@ describe PageObject::Elements::UnorderedList do
|
|
23
23
|
describe "interface" do
|
24
24
|
let(:ul_element) { double('ul_element') }
|
25
25
|
|
26
|
+
it "should register with tag_name :ul" do
|
27
|
+
::PageObject::Elements.element_class_for(:ul).should == ::PageObject::Elements::UnorderedList
|
28
|
+
end
|
29
|
+
|
26
30
|
context "for watir" do
|
27
31
|
it "should return a list item when indexed" do
|
28
32
|
ul = PageObject::Elements::UnorderedList.new(ul_element, :platform => :watir_webdriver)
|
@@ -76,4 +80,4 @@ describe PageObject::Elements::UnorderedList do
|
|
76
80
|
end
|
77
81
|
end
|
78
82
|
end
|
79
|
-
end
|
83
|
+
end
|
@@ -17,6 +17,7 @@ describe PageObject::PagePopulator do
|
|
17
17
|
|
18
18
|
it "should set a value in a text field" do
|
19
19
|
page_object.should_receive(:tf=).with('value')
|
20
|
+
page_object.stub(:is_enabled?).and_return(true)
|
20
21
|
page_object.populate_page_with('tf' => 'value')
|
21
22
|
end
|
22
23
|
|
@@ -27,36 +28,64 @@ describe PageObject::PagePopulator do
|
|
27
28
|
|
28
29
|
it "should set a value in a text area" do
|
29
30
|
page_object.should_receive(:ta=).with('value')
|
31
|
+
page_object.stub(:is_enabled?).and_return(true)
|
30
32
|
page_object.populate_page_with('ta' => 'value')
|
31
33
|
end
|
32
34
|
|
33
35
|
it "should set a value in a select list" do
|
34
|
-
page_object.should_receive(:
|
35
|
-
page_object.
|
36
|
+
page_object.should_receive(:sl=).with('value')
|
37
|
+
page_object.stub(:is_enabled?).and_return(true)
|
38
|
+
page_object.populate_page_with('sl' => 'value')
|
36
39
|
end
|
37
40
|
|
38
41
|
it "should set a value in a file field" do
|
39
42
|
page_object.should_receive(:ff=).with('value')
|
43
|
+
page_object.stub(:is_enabled?).and_return(true)
|
40
44
|
page_object.populate_page_with('ff' => 'value')
|
41
45
|
end
|
42
46
|
|
43
47
|
it "should check a checkbox to true is specified" do
|
44
48
|
page_object.should_receive(:check_cb)
|
49
|
+
page_object.stub(:is_enabled?).and_return(true)
|
45
50
|
page_object.populate_page_with('cb' => true)
|
46
51
|
end
|
47
52
|
|
48
53
|
it "should uncheck a checkbox to false is specified" do
|
49
54
|
page_object.should_receive(:uncheck_cb)
|
55
|
+
page_object.stub(:is_enabled?).and_return(true)
|
50
56
|
page_object.populate_page_with('cb' => false)
|
51
57
|
end
|
52
58
|
|
53
59
|
it "should select a radio button when true is specified" do
|
54
60
|
page_object.should_receive(:select_rb)
|
61
|
+
page_object.stub(:is_enabled?).and_return(true)
|
55
62
|
page_object.populate_page_with('rb' => true)
|
56
63
|
end
|
57
64
|
|
58
65
|
it "should clear a radio button when false is specified" do
|
59
66
|
page_object.should_receive(:clear_rb)
|
67
|
+
page_object.stub(:is_enabled?).and_return(true)
|
60
68
|
page_object.populate_page_with('rb' => false)
|
61
69
|
end
|
70
|
+
|
71
|
+
it "should not populate a checkbox if it is disabled" do
|
72
|
+
page_object.should_not_receive(:check_cb)
|
73
|
+
page_object.should_receive(:cb_element).and_return(browser)
|
74
|
+
browser.should_receive(:enabled?).and_return(false)
|
75
|
+
page_object.populate_page_with('cb' => true)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should not populate a radio button when it is disabled" do
|
79
|
+
page_object.should_not_receive(:select_rb)
|
80
|
+
page_object.should_receive(:rb_element).and_return(browser)
|
81
|
+
browser.should_receive(:enabled?).and_return(false)
|
82
|
+
page_object.populate_page_with('rb' => true)
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should not populate a text field when it is disabled" do
|
86
|
+
page_object.should_not_receive(:tf=)
|
87
|
+
page_object.should_receive(:tf_element).and_return(browser)
|
88
|
+
browser.should_receive(:enabled?).and_return(false)
|
89
|
+
page_object.populate_page_with('tf' => true)
|
90
|
+
end
|
62
91
|
end
|
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.5
|
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-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: watir-webdriver
|
16
|
-
requirement: &
|
16
|
+
requirement: &70351263125040 !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: *70351263125040
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: selenium-webdriver
|
27
|
-
requirement: &
|
27
|
+
requirement: &70351263124060 !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: *70351263124060
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70351263120380 !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: *70351263120380
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: cucumber
|
49
|
-
requirement: &
|
49
|
+
requirement: &70351263119680 !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: *70351263119680
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: yard
|
60
|
-
requirement: &
|
60
|
+
requirement: &70351263118960 !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: *70351263118960
|
69
69
|
description: Page Object DSL that works with both Watir and Selenium
|
70
70
|
email:
|
71
71
|
- jeff.morgan@leandog.com
|
@@ -151,7 +151,9 @@ files:
|
|
151
151
|
- features/step_definitions/text_field_steps.rb
|
152
152
|
- features/step_definitions/unordered_list_steps.rb
|
153
153
|
- features/support/env.rb
|
154
|
+
- features/support/hooks.rb
|
154
155
|
- features/support/page.rb
|
156
|
+
- features/support/persistent_browser.rb
|
155
157
|
- features/support/url_helper.rb
|
156
158
|
- features/table.feature
|
157
159
|
- features/table_cell.feature
|
@@ -239,11 +241,14 @@ files:
|
|
239
241
|
- spec/page-object/elements/link_spec.rb
|
240
242
|
- spec/page-object/elements/list_item_spec.rb
|
241
243
|
- spec/page-object/elements/nested_element_spec.rb
|
244
|
+
- spec/page-object/elements/option_spec.rb
|
242
245
|
- spec/page-object/elements/ordered_list_spec.rb
|
246
|
+
- spec/page-object/elements/paragraph_spec.rb
|
243
247
|
- spec/page-object/elements/radio_button_spec.rb
|
244
248
|
- spec/page-object/elements/select_list_spec.rb
|
245
249
|
- spec/page-object/elements/selenium_element_spec.rb
|
246
250
|
- spec/page-object/elements/span_spec.rb
|
251
|
+
- spec/page-object/elements/table_cell_spec.rb
|
247
252
|
- spec/page-object/elements/table_row_spec.rb
|
248
253
|
- spec/page-object/elements/table_spec.rb
|
249
254
|
- spec/page-object/elements/text_area_spec.rb
|
@@ -351,7 +356,9 @@ test_files:
|
|
351
356
|
- features/step_definitions/text_field_steps.rb
|
352
357
|
- features/step_definitions/unordered_list_steps.rb
|
353
358
|
- features/support/env.rb
|
359
|
+
- features/support/hooks.rb
|
354
360
|
- features/support/page.rb
|
361
|
+
- features/support/persistent_browser.rb
|
355
362
|
- features/support/url_helper.rb
|
356
363
|
- features/table.feature
|
357
364
|
- features/table_cell.feature
|
@@ -372,11 +379,14 @@ test_files:
|
|
372
379
|
- spec/page-object/elements/link_spec.rb
|
373
380
|
- spec/page-object/elements/list_item_spec.rb
|
374
381
|
- spec/page-object/elements/nested_element_spec.rb
|
382
|
+
- spec/page-object/elements/option_spec.rb
|
375
383
|
- spec/page-object/elements/ordered_list_spec.rb
|
384
|
+
- spec/page-object/elements/paragraph_spec.rb
|
376
385
|
- spec/page-object/elements/radio_button_spec.rb
|
377
386
|
- spec/page-object/elements/select_list_spec.rb
|
378
387
|
- spec/page-object/elements/selenium_element_spec.rb
|
379
388
|
- spec/page-object/elements/span_spec.rb
|
389
|
+
- spec/page-object/elements/table_cell_spec.rb
|
380
390
|
- spec/page-object/elements/table_row_spec.rb
|
381
391
|
- spec/page-object/elements/table_spec.rb
|
382
392
|
- spec/page-object/elements/text_area_spec.rb
|