page-object 1.0.2 → 1.0.3
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.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +1 -0
- data/ChangeLog +10 -0
- data/README.md +1 -1
- data/features/bold.feature +21 -0
- data/features/html/indexed_property.html +14 -0
- data/features/html/multi_elements.html +1 -1
- data/features/html/static_elements.html +1 -2
- data/features/indexed_property.feature +15 -0
- data/features/multi_elements.feature +6 -0
- data/features/step_definitions/async_steps.rb +1 -1
- data/features/step_definitions/bold_steps.rb +12 -0
- data/features/step_definitions/check_box_steps.rb +2 -2
- data/features/step_definitions/indexed_property_steps.rb +47 -1
- data/features/step_definitions/label_steps.rb +1 -1
- data/features/step_definitions/multi_elements_steps.rb +13 -0
- data/features/step_definitions/select_list_steps.rb +1 -1
- data/features/step_definitions/table_steps.rb +4 -0
- data/features/support/page.rb +9 -0
- data/features/table.feature +12 -4
- data/lib/page-object.rb +6 -5
- data/lib/page-object/accessors.rb +78 -58
- data/lib/page-object/elements.rb +1 -0
- data/lib/page-object/elements/bold.rb +11 -0
- data/lib/page-object/elements/element.rb +12 -1
- data/lib/page-object/elements/table.rb +12 -1
- data/lib/page-object/indexed_properties.rb +20 -21
- data/lib/page-object/javascript/angularjs.rb +14 -0
- data/lib/page-object/javascript_framework_facade.rb +4 -2
- data/lib/page-object/locator_generator.rb +1 -0
- data/lib/page-object/page_populator.rb +0 -1
- data/lib/page-object/platforms/selenium_webdriver/button.rb +1 -1
- data/lib/page-object/platforms/selenium_webdriver/element.rb +1 -1
- data/lib/page-object/platforms/selenium_webdriver/page_object.rb +26 -10
- data/lib/page-object/platforms/selenium_webdriver/radio_button.rb +0 -7
- data/lib/page-object/platforms/watir_webdriver/element.rb +1 -1
- data/lib/page-object/platforms/watir_webdriver/page_object.rb +23 -8
- data/lib/page-object/platforms/watir_webdriver/radio_button.rb +0 -7
- data/lib/page-object/version.rb +1 -1
- data/lib/page-object/widgets.rb +7 -0
- data/page-object.gemspec +3 -3
- data/spec/page-object/accessors_spec.rb +40 -0
- data/spec/page-object/element_locators_spec.rb +340 -305
- data/spec/page-object/elements/area_spec.rb +8 -8
- data/spec/page-object/elements/bold_spec.rb +29 -0
- data/spec/page-object/elements/button_spec.rb +7 -7
- data/spec/page-object/elements/canvas_spec.rb +6 -6
- data/spec/page-object/elements/check_box_spec.rb +9 -9
- data/spec/page-object/elements/div_spec.rb +3 -3
- data/spec/page-object/elements/element_spec.rb +21 -21
- data/spec/page-object/elements/file_field_spec.rb +4 -4
- data/spec/page-object/elements/form_spec.rb +3 -3
- data/spec/page-object/elements/heading_spec.rb +8 -8
- data/spec/page-object/elements/hidden_field_spec.rb +3 -3
- data/spec/page-object/elements/image_spec.rb +14 -14
- data/spec/page-object/elements/label_spec.rb +3 -3
- data/spec/page-object/elements/link_spec.rb +6 -6
- data/spec/page-object/elements/list_item_spec.rb +4 -3
- data/spec/page-object/elements/nested_element_spec.rb +47 -47
- data/spec/page-object/elements/option_spec.rb +1 -1
- data/spec/page-object/elements/ordered_list_spec.rb +33 -33
- data/spec/page-object/elements/paragraph_spec.rb +3 -4
- data/spec/page-object/elements/select_list_spec.rb +52 -52
- data/spec/page-object/elements/selenium/radio_button_spec.rb +7 -13
- data/spec/page-object/elements/selenium/text_field_spec.rb +7 -7
- data/spec/page-object/elements/selenium_element_spec.rb +53 -53
- data/spec/page-object/elements/span_spec.rb +3 -3
- data/spec/page-object/elements/table_cell_spec.rb +3 -3
- data/spec/page-object/elements/table_row_spec.rb +22 -22
- data/spec/page-object/elements/table_spec.rb +28 -28
- data/spec/page-object/elements/text_area_spec.rb +5 -5
- data/spec/page-object/elements/unordered_list_spec.rb +33 -34
- data/spec/page-object/elements/watir_element_spec.rb +47 -48
- data/spec/page-object/javascript_framework_facade_spec.rb +6 -6
- data/spec/page-object/loads_platform_spec.rb +4 -4
- data/spec/page-object/page-object_spec.rb +103 -102
- data/spec/page-object/page_factory_spec.rb +43 -61
- data/spec/page-object/page_populator_spec.rb +44 -50
- data/spec/page-object/platforms/selenium_webdriver/selenium_page_object_spec.rb +15 -15
- data/spec/page-object/platforms/selenium_webdriver_spec.rb +6 -6
- data/spec/page-object/platforms/watir_webdriver/watir_page_object_spec.rb +4 -4
- data/spec/page-object/platforms/watir_webdriver_spec.rb +1 -1
- data/spec/page-object/selenium_accessors_spec.rb +166 -153
- data/spec/page-object/watir_accessors_spec.rb +265 -245
- data/spec/page-object/widget_spec.rb +62 -30
- data/spec/spec_helper.rb +8 -8
- metadata +20 -10
@@ -5,7 +5,7 @@ describe PageObject::Elements::Option do
|
|
5
5
|
|
6
6
|
describe "interface" do
|
7
7
|
it "should register as tag_name :option" do
|
8
|
-
::PageObject::Elements.element_class_for(:option).
|
8
|
+
expect(::PageObject::Elements.element_class_for(:option)).to eql ::PageObject::Elements::Option
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -8,14 +8,14 @@ describe PageObject::Elements::OrderedList do
|
|
8
8
|
it "should map watir types to same" do
|
9
9
|
[:class, :id, :index, :xpath].each do |t|
|
10
10
|
identifier = ol.watir_identifier_for t => 'value'
|
11
|
-
identifier.keys.first.
|
11
|
+
expect(identifier.keys.first).to eql t
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should map selenium types to same" do
|
16
16
|
[:class, :id, :index, :name, :xpath].each do |t|
|
17
17
|
key, value = ol.selenium_identifier_for t => 'value'
|
18
|
-
key.
|
18
|
+
expect(key).to eql t
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -24,70 +24,70 @@ describe PageObject::Elements::OrderedList do
|
|
24
24
|
let(:ol_element) { double('ol_element') }
|
25
25
|
|
26
26
|
it "should register as tag_name :ol" do
|
27
|
-
::PageObject::Elements.element_class_for(:ol).
|
27
|
+
expect(::PageObject::Elements.element_class_for(:ol)).to eql ::PageObject::Elements::OrderedList
|
28
28
|
end
|
29
29
|
|
30
30
|
context "for watir" do
|
31
31
|
it "should return a list item when indexed" do
|
32
32
|
ol = PageObject::Elements::OrderedList.new(ol_element, :platform => :watir_webdriver)
|
33
|
-
ol_element.
|
34
|
-
ol_element.
|
35
|
-
ol_element.
|
36
|
-
ol_element.
|
37
|
-
ol_element.
|
38
|
-
ol_element.
|
33
|
+
allow(ol_element).to receive(:ols).and_return([ol_element])
|
34
|
+
allow(ol_element).to receive(:find_elements).and_return(ol_element)
|
35
|
+
allow(ol_element).to receive(:map).and_return([ol_element])
|
36
|
+
allow(ol_element).to receive(:parent).and_return(ol_element)
|
37
|
+
allow(ol_element).to receive(:element).and_return(ol_element)
|
38
|
+
allow(ol_element).to receive(:==).and_return(true)
|
39
39
|
ol[1]
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should know how many list items it contains" do
|
43
43
|
ol = PageObject::Elements::OrderedList.new(ol_element, :platform => :watir_webdriver)
|
44
|
-
ol_element.
|
45
|
-
ol_element.
|
46
|
-
ol_element.
|
47
|
-
ol_element.
|
48
|
-
ol_element.
|
49
|
-
ol_element.
|
50
|
-
ol.items.
|
44
|
+
allow(ol_element).to receive(:ols).and_return([ol_element])
|
45
|
+
allow(ol_element).to receive(:find_elements).and_return(ol_element)
|
46
|
+
allow(ol_element).to receive(:map).and_return([ol_element])
|
47
|
+
allow(ol_element).to receive(:parent).and_return(ol_element)
|
48
|
+
allow(ol_element).to receive(:element).and_return(ol_element)
|
49
|
+
allow(ol_element).to receive(:==).and_return(true)
|
50
|
+
expect(ol.items).to eql 1
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should iterate over the list items" do
|
54
54
|
ol = PageObject::Elements::OrderedList.new(ol_element, :platform => :watir_webdriver)
|
55
|
-
ol.
|
56
|
-
ol.
|
55
|
+
expect(ol).to receive(:items).and_return(5)
|
56
|
+
allow(ol).to receive(:[])
|
57
57
|
count = 0
|
58
58
|
ol.each { |item| count += 1 }
|
59
|
-
count.
|
59
|
+
expect(count).to eql 5
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
context "for selenium" do
|
64
64
|
it "should return a list item when indexed" do
|
65
65
|
ol = PageObject::Elements::OrderedList.new(ol_element, :platform => :selenium_webdriver)
|
66
|
-
ol_element.
|
67
|
-
ol_element.
|
68
|
-
ol_element.
|
69
|
-
ol_element.
|
70
|
-
ol_element.
|
66
|
+
expect(ol_element).to receive(:find_elements).and_return(ol_element)
|
67
|
+
expect(ol_element).to receive(:map).and_return([ol_element])
|
68
|
+
expect(ol_element).to receive(:parent).and_return(ol_element)
|
69
|
+
expect(ol_element).to receive(:element).and_return(ol_element)
|
70
|
+
expect(ol_element).to receive(:==).and_return(true)
|
71
71
|
ol[1]
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should know how many list items it contains" do
|
75
75
|
ol = PageObject::Elements::OrderedList.new(ol_element, :platform => :selenium_webdriver)
|
76
|
-
ol_element.
|
77
|
-
ol_element.
|
78
|
-
ol_element.
|
79
|
-
ol_element.
|
80
|
-
ol_element.
|
81
|
-
ol.items.
|
76
|
+
expect(ol_element).to receive(:find_elements).and_return(ol_element)
|
77
|
+
expect(ol_element).to receive(:map).and_return([ol_element])
|
78
|
+
expect(ol_element).to receive(:parent).and_return(ol_element)
|
79
|
+
expect(ol_element).to receive(:element).and_return(ol_element)
|
80
|
+
expect(ol_element).to receive(:==).and_return(true)
|
81
|
+
expect(ol.items).to eql 1
|
82
82
|
end
|
83
83
|
|
84
84
|
it "should iterate over the list items" do
|
85
85
|
ol = PageObject::Elements::OrderedList.new(ol_element, :platform => :selenium_webdriver)
|
86
|
-
ol.
|
87
|
-
ol.
|
86
|
+
expect(ol).to receive(:items).and_return(5)
|
87
|
+
allow(ol).to receive(:[])
|
88
88
|
count = 0
|
89
89
|
ol.each { |item| count += 1 }
|
90
|
-
count.
|
90
|
+
expect(count).to eql 5
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
@@ -8,21 +8,20 @@ describe PageObject::Elements::Paragraph do
|
|
8
8
|
it "should map watir types to same" do
|
9
9
|
[:class, :id, :index, :name, :xpath].each do |t|
|
10
10
|
identifier = paragraph.watir_identifier_for t => 'value'
|
11
|
-
identifier.keys.first.
|
11
|
+
expect(identifier.keys.first).to eql t
|
12
12
|
end
|
13
13
|
end
|
14
14
|
it "should map selenium types to same" do
|
15
15
|
[:class, :id, :name, :xpath, :index].each do |t|
|
16
16
|
key, value = paragraph.selenium_identifier_for t => 'value'
|
17
|
-
key.
|
17
|
+
expect(key).to eql t
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
describe "interface" do
|
23
|
-
|
24
23
|
it "should register with type :checkbox" do
|
25
|
-
::PageObject::Elements.element_class_for(:p).
|
24
|
+
expect(::PageObject::Elements.element_class_for(:p)).to eql ::PageObject::Elements::Paragraph
|
26
25
|
end
|
27
26
|
end
|
28
27
|
end
|
@@ -8,14 +8,14 @@ describe PageObject::Elements::SelectList do
|
|
8
8
|
it "should map watir types to same" do
|
9
9
|
[:class, :id, :index, :name, :text, :value, :xpath].each do |t|
|
10
10
|
identifier = selectlist.watir_identifier_for t => 'value'
|
11
|
-
identifier.keys.first.
|
11
|
+
expect(identifier.keys.first).to eql t
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should map selenium types to same" do
|
16
16
|
[:class, :id, :name, :xpath, :index].each do |t|
|
17
17
|
key, value = selectlist.selenium_identifier_for t => 'value'
|
18
|
-
key.
|
18
|
+
expect(key).to eql t
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -25,53 +25,53 @@ describe PageObject::Elements::SelectList do
|
|
25
25
|
let(:opts) { [sel_list, sel_list] }
|
26
26
|
|
27
27
|
before(:each) do
|
28
|
-
sel_list.
|
29
|
-
sel_list.
|
30
|
-
sel_list.
|
31
|
-
sel_list.
|
32
|
-
sel_list.
|
33
|
-
sel_list.
|
34
|
-
sel_list.
|
35
|
-
sel_list.
|
28
|
+
allow(sel_list).to receive(:find_elements).and_return(sel_list)
|
29
|
+
allow(sel_list).to receive(:each)
|
30
|
+
allow(sel_list).to receive(:wd).and_return(sel_list)
|
31
|
+
allow(sel_list).to receive(:map).and_return(opts)
|
32
|
+
allow(sel_list).to receive(:any?)
|
33
|
+
allow(sel_list).to receive(:include?)
|
34
|
+
allow(sel_list).to receive(:select).and_return(opts)
|
35
|
+
allow(sel_list).to receive(:text).and_return('blah')
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should register with tag_name :select" do
|
39
|
-
::PageObject::Elements.element_class_for(:select).
|
39
|
+
expect(::PageObject::Elements.element_class_for(:select)).to eql ::PageObject::Elements::SelectList
|
40
40
|
end
|
41
41
|
|
42
42
|
context "for watir" do
|
43
43
|
let(:watir_sel_list) { PageObject::Elements::SelectList.new(sel_list, :platform => :watir_webdriver) }
|
44
44
|
|
45
45
|
it "should return an option when indexed" do
|
46
|
-
sel_list.
|
47
|
-
watir_sel_list[0].
|
46
|
+
expect(sel_list).to receive(:find_elements).with(:xpath, ".//child::option").and_return(opts)
|
47
|
+
expect(watir_sel_list[0]).to be_instance_of PageObject::Elements::Option
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should return an array of options" do
|
51
|
-
sel_list.
|
52
|
-
watir_sel_list.options.size.
|
51
|
+
expect(sel_list).to receive(:find_elements).with(:xpath, ".//child::option").and_return(opts)
|
52
|
+
expect(watir_sel_list.options.size).to eql 2
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should return an array of selected options" do
|
56
|
-
sel_list.
|
57
|
-
sel_list.
|
58
|
-
watir_sel_list.selected_options.
|
56
|
+
allow(sel_list).to receive(:selected_options).and_return(opts)
|
57
|
+
allow(sel_list).to receive(:text).and_return(sel_list)
|
58
|
+
expect(watir_sel_list.selected_options).to eql opts
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should know if it includes some value" do
|
62
|
-
sel_list.
|
62
|
+
allow(sel_list).to receive(:include?).with('blah').and_return(true)
|
63
63
|
watir_sel_list.include?('blah')
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should know if an option is selected" do
|
67
|
-
sel_list.
|
67
|
+
allow(sel_list).to receive(:selected?).with('blah').and_return(true)
|
68
68
|
watir_sel_list.selected?('blah')
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should be able to get the value for the selected options" do
|
72
|
-
sel_list.
|
73
|
-
sel_list.
|
74
|
-
watir_sel_list.selected_values.
|
72
|
+
allow(sel_list).to receive(:selected_options).and_return(opts)
|
73
|
+
allow(sel_list).to receive(:value).and_return(sel_list)
|
74
|
+
expect(watir_sel_list.selected_values).to eql opts
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
@@ -79,61 +79,61 @@ describe PageObject::Elements::SelectList do
|
|
79
79
|
let(:selenium_sel_list) { PageObject::Elements::SelectList.new(sel_list, :platform => :selenium_webdriver) }
|
80
80
|
|
81
81
|
it "should return an option when indexed" do
|
82
|
-
sel_list.
|
83
|
-
selenium_sel_list[1].
|
82
|
+
expect(sel_list).to receive(:find_elements).with(:xpath, ".//child::option").and_return(opts)
|
83
|
+
expect(selenium_sel_list[1]).to be_instance_of PageObject::Elements::Option
|
84
84
|
end
|
85
85
|
|
86
86
|
it "should return an array of options" do
|
87
|
-
sel_list.
|
88
|
-
selenium_sel_list.options.size.
|
87
|
+
expect(sel_list).to receive(:find_elements).with(:xpath, ".//child::option").and_return(opts)
|
88
|
+
expect(selenium_sel_list.options.size).to eql 2
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should select an element" do
|
92
92
|
option = double('option')
|
93
|
-
sel_list.
|
94
|
-
option.
|
95
|
-
option.
|
93
|
+
expect(sel_list).to receive(:find_elements).with(:xpath, ".//child::option").and_return([option])
|
94
|
+
expect(option).to receive(:text).and_return('something')
|
95
|
+
expect(option).to receive(:click)
|
96
96
|
selenium_sel_list.select 'something'
|
97
97
|
end
|
98
98
|
|
99
99
|
it "should return an array of selected options" do
|
100
|
-
sel_list.
|
101
|
-
opts[0].
|
102
|
-
opts[0].
|
103
|
-
opts[1].
|
100
|
+
expect(sel_list).to receive(:find_elements).with(:xpath, ".//child::option").and_return(opts)
|
101
|
+
expect(opts[0]).to receive(:selected?).and_return(true)
|
102
|
+
expect(opts[0]).to receive(:text).and_return('test1')
|
103
|
+
expect(opts[1]).to receive(:selected?).and_return(false)
|
104
104
|
selected = selenium_sel_list.selected_options
|
105
|
-
selected.size.
|
106
|
-
selected[0].
|
105
|
+
expect(selected.size).to eql 1
|
106
|
+
expect(selected[0]).to eql 'test1'
|
107
107
|
end
|
108
108
|
|
109
109
|
it "should return an array of selected options" do
|
110
|
-
sel_list.
|
111
|
-
opts[0].
|
112
|
-
opts[0].
|
113
|
-
opts[1].
|
110
|
+
expect(sel_list).to receive(:find_elements).with(:xpath, ".//child::option").and_return(opts)
|
111
|
+
expect(opts[0]).to receive(:selected?).and_return(true)
|
112
|
+
expect(opts[0]).to receive(:attribute).and_return('test1')
|
113
|
+
expect(opts[1]).to receive(:selected?).and_return(false)
|
114
114
|
selected = selenium_sel_list.selected_values
|
115
|
-
selected.size.
|
116
|
-
selected[0].
|
115
|
+
expect(selected.size).to eql 1
|
116
|
+
expect(selected[0]).to eql 'test1'
|
117
117
|
end
|
118
118
|
|
119
119
|
it "should know if it includes some value" do
|
120
|
-
sel_list.
|
121
|
-
opts[0].
|
122
|
-
selenium_sel_list.
|
120
|
+
expect(sel_list).to receive(:find_elements).and_return(opts)
|
121
|
+
expect(opts[0]).to receive(:text).and_return('blah')
|
122
|
+
expect(selenium_sel_list).to include 'blah'
|
123
123
|
end
|
124
124
|
|
125
125
|
it "should know if an option is selected" do
|
126
|
-
sel_list.
|
127
|
-
opts[0].
|
128
|
-
opts[0].
|
129
|
-
selenium_sel_list.selected?('blah').
|
126
|
+
expect(sel_list).to receive(:find_elements).and_return(opts)
|
127
|
+
expect(opts[0]).to receive(:selected?).twice.and_return(true)
|
128
|
+
expect(opts[0]).to receive(:text).and_return('blah')
|
129
|
+
expect(selenium_sel_list.selected?('blah')).to be true
|
130
130
|
end
|
131
131
|
|
132
132
|
it "should be able to clear selected options" do
|
133
|
-
sel_list.
|
133
|
+
expect(sel_list).to receive(:find_elements).and_return(opts)
|
134
134
|
opts.each do |opt|
|
135
|
-
opt.
|
136
|
-
opt.
|
135
|
+
expect(opt).to receive(:selected?).and_return(true)
|
136
|
+
expect(opt).to receive(:click)
|
137
137
|
end
|
138
138
|
selenium_sel_list.clear
|
139
139
|
end
|
@@ -8,13 +8,13 @@ describe PageObject::Elements::RadioButton do
|
|
8
8
|
it "should map watir types to same" do
|
9
9
|
[:class, :id, :index, :name, :value, :xpath].each do |t|
|
10
10
|
identifier = radiobutton.watir_identifier_for t => 'value'
|
11
|
-
identifier.keys.first.
|
11
|
+
expect(identifier.keys.first).to eql t
|
12
12
|
end
|
13
13
|
end
|
14
14
|
it "should map selenium types to same" do
|
15
15
|
[:class, :id, :name, :xpath, :value, :index].each do |t|
|
16
16
|
key, value = radiobutton.selenium_identifier_for t => 'value'
|
17
|
-
key.
|
17
|
+
expect(key).to eql t
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -22,7 +22,7 @@ describe PageObject::Elements::RadioButton do
|
|
22
22
|
describe "interface" do
|
23
23
|
|
24
24
|
it "should register as type :radio" do
|
25
|
-
::PageObject::Elements.element_class_for(:input, :radio).
|
25
|
+
expect(::PageObject::Elements.element_class_for(:input, :radio)).to eql ::PageObject::Elements::RadioButton
|
26
26
|
end
|
27
27
|
|
28
28
|
context "for selenium" do
|
@@ -30,20 +30,14 @@ describe PageObject::Elements::RadioButton do
|
|
30
30
|
let(:radio_button) { PageObject::Elements::RadioButton.new(selenium_rb, :platform => :selenium_webdriver) }
|
31
31
|
|
32
32
|
it "should select" do
|
33
|
-
selenium_rb.
|
34
|
-
selenium_rb.
|
33
|
+
expect(selenium_rb).to receive(:click)
|
34
|
+
expect(selenium_rb).to receive(:selected?).and_return(false)
|
35
35
|
radio_button.select
|
36
36
|
end
|
37
37
|
|
38
|
-
it "should clear" do
|
39
|
-
selenium_rb.should_receive(:click)
|
40
|
-
selenium_rb.should_receive(:selected?).and_return(true)
|
41
|
-
radio_button.clear
|
42
|
-
end
|
43
|
-
|
44
38
|
it "should know if it is selected" do
|
45
|
-
selenium_rb.
|
46
|
-
radio_button.
|
39
|
+
expect(selenium_rb).to receive(:selected?).and_return(true)
|
40
|
+
expect(radio_button).to be_selected
|
47
41
|
end
|
48
42
|
end
|
49
43
|
end
|
@@ -9,14 +9,14 @@ describe PageObject::Elements::TextField do
|
|
9
9
|
it "should map watir types to same" do
|
10
10
|
[:class, :id, :index, :name, :title, :xpath, :text, :label].each do |t|
|
11
11
|
identifier = textfield.watir_identifier_for t => 'value'
|
12
|
-
identifier.keys.first.
|
12
|
+
expect(identifier.keys.first).to eql t
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should map selenium types to same" do
|
17
17
|
[:class, :id, :name, :title, :xpath, :index, :text, :label].each do |t|
|
18
18
|
key, value = textfield.selenium_identifier_for t => 'value'
|
19
|
-
key.
|
19
|
+
expect(key).to eql t
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -26,22 +26,22 @@ describe PageObject::Elements::TextField do
|
|
26
26
|
let(:selenium_text_field) { PageObject::Elements::TextField.new(text_field_element, :platform => :selenium_webdriver) }
|
27
27
|
|
28
28
|
it "should register with type :text" do
|
29
|
-
::PageObject::Elements.element_class_for(:input, :text).
|
29
|
+
expect(::PageObject::Elements.element_class_for(:input, :text)).to eql ::PageObject::Elements::TextField
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should register with type :password" do
|
33
|
-
::PageObject::Elements.element_class_for(:input, :password).
|
33
|
+
expect(::PageObject::Elements.element_class_for(:input, :password)).to eql ::PageObject::Elements::TextField
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should append text" do
|
37
|
-
text_field_element.
|
37
|
+
expect(text_field_element).to receive(:send_keys).with('abc')
|
38
38
|
selenium_text_field.append('abc')
|
39
39
|
end
|
40
40
|
|
41
41
|
context "for selenium" do
|
42
42
|
it "should set its' value" do
|
43
|
-
text_field_element.
|
44
|
-
text_field_element.
|
43
|
+
expect(text_field_element).to receive(:clear)
|
44
|
+
expect(text_field_element).to receive(:send_keys).with('Joseph')
|
45
45
|
selenium_text_field.value = 'Joseph'
|
46
46
|
end
|
47
47
|
end
|
@@ -9,164 +9,164 @@ describe "Element for Selenium" do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should know when it is visible" do
|
12
|
-
@selenium_driver.
|
13
|
-
@selenium_element.visible
|
12
|
+
expect(@selenium_driver).to receive(:displayed?).and_return(true)
|
13
|
+
expect(@selenium_element.visible?).to be true
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should know when it is not visible" do
|
17
|
-
@selenium_driver.
|
18
|
-
@selenium_element.visible
|
17
|
+
expect(@selenium_driver).to receive(:displayed?).and_return(false)
|
18
|
+
expect(@selenium_element.visible?).to eql false
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should know when it exists" do
|
22
|
-
@selenium_driver.
|
23
|
-
@selenium_element.exists
|
22
|
+
expect(@selenium_driver).to receive(:nil?).and_return(false)
|
23
|
+
expect(@selenium_element.exists?).to eql true
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should know when it does not exist" do
|
27
27
|
@selenium_element = ::PageObject::Elements::Element.new(nil, :platform => :selenium_webdriver)
|
28
|
-
@selenium_element.exists
|
28
|
+
expect(@selenium_element.exists?).to eql false
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should flash an element" do
|
32
32
|
bridge = double('bridge')
|
33
|
-
@selenium_driver.
|
34
|
-
@selenium_driver.
|
35
|
-
bridge.
|
33
|
+
expect(@selenium_driver).to receive(:attribute).and_return('blue')
|
34
|
+
expect(@selenium_driver).to receive(:instance_variable_get).and_return(bridge)
|
35
|
+
expect(bridge).to receive(:executeScript).exactly(10).times
|
36
36
|
@selenium_element.flash
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should be able to return the text contained in the element" do
|
40
|
-
@selenium_driver.
|
41
|
-
@selenium_element.text.
|
40
|
+
expect(@selenium_driver).to receive(:text).and_return("my text")
|
41
|
+
expect(@selenium_element.text).to eql "my text"
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should know when it is equal to another" do
|
45
|
-
@selenium_driver.
|
46
|
-
@selenium_element.
|
45
|
+
expect(@selenium_driver).to receive(:==).and_return(true)
|
46
|
+
expect(@selenium_element).to eq @selenium_element
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should return its tag name" do
|
50
|
-
@selenium_driver.
|
51
|
-
@selenium_element.tag_name.
|
50
|
+
expect(@selenium_driver).to receive(:tag_name).and_return("h1")
|
51
|
+
expect(@selenium_element.tag_name).to eql "h1"
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should know its value" do
|
55
|
-
@selenium_driver.
|
56
|
-
@selenium_element.value.
|
55
|
+
expect(@selenium_driver).to receive(:attribute).with('value').and_return("value")
|
56
|
+
expect(@selenium_element.value).to eql "value"
|
57
57
|
end
|
58
58
|
|
59
59
|
it "should know how to retrieve the value of an attribute" do
|
60
|
-
@selenium_driver.
|
61
|
-
@selenium_element.attribute('readonly').
|
60
|
+
expect(@selenium_driver).to receive(:attribute).and_return(true)
|
61
|
+
expect(@selenium_element.attribute('readonly')).to be true
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should be clickable" do
|
65
|
-
@selenium_driver.
|
65
|
+
expect(@selenium_driver).to receive(:click)
|
66
66
|
@selenium_element.click
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should be double clickable" do
|
70
|
-
Selenium::WebDriver::Mouse.
|
71
|
-
@selenium_driver.
|
70
|
+
expect(Selenium::WebDriver::Mouse).to receive(:new).and_return(@selenium_driver)
|
71
|
+
expect(@selenium_driver).to receive(:double_click)
|
72
72
|
@selenium_element.double_click
|
73
73
|
end
|
74
74
|
|
75
75
|
it "should be right clickable" do
|
76
|
-
@selenium_driver.
|
76
|
+
expect(@selenium_driver).to receive(:context_click)
|
77
77
|
@selenium_element.right_click
|
78
78
|
end
|
79
79
|
|
80
80
|
it "should be able to block until it is present" do
|
81
81
|
wait = double('wait')
|
82
|
-
::Selenium::WebDriver::Wait.
|
83
|
-
wait.
|
82
|
+
expect(::Selenium::WebDriver::Wait).to receive(:new).and_return(wait)
|
83
|
+
expect(wait).to receive(:until)
|
84
84
|
@selenium_element.when_present(10)
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should return the element when it is present" do
|
88
88
|
wait = double('wait')
|
89
|
-
::Selenium::WebDriver::Wait.
|
90
|
-
wait.
|
89
|
+
expect(::Selenium::WebDriver::Wait).to receive(:new).and_return(wait)
|
90
|
+
expect(wait).to receive(:until)
|
91
91
|
element = @selenium_element.when_present(10)
|
92
|
-
element.
|
92
|
+
expect(element).to equal @selenium_element
|
93
93
|
end
|
94
94
|
|
95
95
|
it "should return when an element is not present" do
|
96
96
|
wait = double('wait')
|
97
|
-
::Selenium::WebDriver::Wait.
|
98
|
-
wait.
|
97
|
+
expect(::Selenium::WebDriver::Wait).to receive(:new).and_return(wait)
|
98
|
+
expect(wait).to receive(:until)
|
99
99
|
@selenium_element.when_not_present
|
100
100
|
end
|
101
101
|
|
102
102
|
it "should be able to block until it is visible" do
|
103
103
|
wait = double('wait')
|
104
|
-
::Selenium::WebDriver::Wait.
|
105
|
-
wait.
|
104
|
+
expect(::Selenium::WebDriver::Wait).to receive(:new).and_return(wait)
|
105
|
+
expect(wait).to receive(:until)
|
106
106
|
@selenium_element.when_visible(10)
|
107
107
|
end
|
108
108
|
|
109
109
|
it "should return the element when it is visible" do
|
110
110
|
wait = double('wait')
|
111
|
-
::Selenium::WebDriver::Wait.
|
112
|
-
wait.
|
111
|
+
expect(::Selenium::WebDriver::Wait).to receive(:new).and_return(wait)
|
112
|
+
expect(wait).to receive(:until)
|
113
113
|
element = @selenium_element.when_visible(10)
|
114
|
-
element.
|
114
|
+
expect(element).to equal @selenium_element
|
115
115
|
end
|
116
116
|
|
117
117
|
it "should be able to block until it is not visible" do
|
118
118
|
wait = double('wait')
|
119
|
-
::Selenium::WebDriver::Wait.
|
120
|
-
wait.
|
119
|
+
expect(::Selenium::WebDriver::Wait).to receive(:new).and_return(wait)
|
120
|
+
expect(wait).to receive(:until)
|
121
121
|
@selenium_element.when_not_visible(10)
|
122
122
|
end
|
123
123
|
|
124
124
|
it "should return the element when it is not visible" do
|
125
125
|
wait = double('wait')
|
126
|
-
::Selenium::WebDriver::Wait.
|
127
|
-
wait.
|
126
|
+
expect(::Selenium::WebDriver::Wait).to receive(:new).and_return(wait)
|
127
|
+
expect(wait).to receive(:until)
|
128
128
|
element = @selenium_element.when_not_visible(10)
|
129
|
-
element.
|
129
|
+
expect(element).to equal @selenium_element
|
130
130
|
end
|
131
131
|
|
132
132
|
it "should be able to block until a user define event fires true" do
|
133
133
|
wait = double('wait')
|
134
|
-
::Selenium::WebDriver::Wait.
|
135
|
-
wait.
|
134
|
+
expect(::Selenium::WebDriver::Wait).to receive(:new).and_return(wait)
|
135
|
+
expect(wait).to receive(:until)
|
136
136
|
@selenium_element.wait_until(10, "Element blah") {}
|
137
137
|
end
|
138
138
|
|
139
139
|
it "should send keys to the element" do
|
140
|
-
@selenium_driver.
|
140
|
+
expect(@selenium_driver).to receive(:send_keys).with([:control, 'a'])
|
141
141
|
@selenium_element.send_keys([:control, 'a'])
|
142
142
|
end
|
143
143
|
|
144
144
|
it "should clear its' contents" do
|
145
|
-
@selenium_driver.
|
145
|
+
expect(@selenium_driver).to receive(:clear)
|
146
146
|
@selenium_element.clear
|
147
147
|
end
|
148
148
|
|
149
149
|
it "should fire an event" do
|
150
|
-
@selenium_driver.
|
151
|
-
@selenium_driver.
|
150
|
+
expect(@selenium_driver).to receive(:instance_variable_get).with(:@bridge).and_return(@selenium_driver)
|
151
|
+
expect(@selenium_driver).to receive(:executeScript)
|
152
152
|
@selenium_element.fire_event('onfocus')
|
153
153
|
end
|
154
154
|
|
155
155
|
it "should find the parent element" do
|
156
|
-
@selenium_driver.
|
157
|
-
@selenium_driver.
|
158
|
-
@selenium_driver.
|
156
|
+
expect(@selenium_driver).to receive(:instance_variable_get).with(:@bridge).and_return(@selenium_driver)
|
157
|
+
expect(@selenium_driver).to receive(:executeScript).and_return(@selenium_driver)
|
158
|
+
expect(@selenium_driver).to receive(:tag_name).twice.and_return(:div)
|
159
159
|
@selenium_element.parent
|
160
160
|
end
|
161
161
|
|
162
162
|
it "should set the focus" do
|
163
|
-
@selenium_driver.
|
164
|
-
@selenium_driver.
|
163
|
+
expect(@selenium_driver).to receive(:instance_variable_get).and_return(@selenium_driver)
|
164
|
+
expect(@selenium_driver).to receive(:executeScript)
|
165
165
|
@selenium_element.focus
|
166
166
|
end
|
167
167
|
|
168
168
|
it "should scroll into view" do
|
169
|
-
@selenium_driver.
|
169
|
+
expect(@selenium_driver).to receive(:location_once_scrolled_into_view)
|
170
170
|
@selenium_element.scroll_into_view
|
171
171
|
end
|
172
172
|
end
|