page_object 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/ChangeLog +809 -0
- data/Gemfile +14 -0
- data/Guardfile +20 -0
- data/LICENSE +20 -0
- data/README.md +111 -0
- data/Rakefile +35 -0
- data/cucumber.yml +10 -0
- data/features/area.feature +35 -0
- data/features/async.feature +30 -0
- data/features/audio.feature +68 -0
- data/features/bold.feature +21 -0
- data/features/button.feature +98 -0
- data/features/canvas.feature +37 -0
- data/features/check_box.feature +55 -0
- data/features/div.feature +45 -0
- data/features/element.feature +322 -0
- data/features/file_field.feature +40 -0
- data/features/form.feature +43 -0
- data/features/frames.feature +75 -0
- data/features/generic_elements.feature +29 -0
- data/features/gxt_table_extension.feature +24 -0
- data/features/headings.feature +97 -0
- data/features/hidden_field.feature +45 -0
- data/features/html/04-Death_Becomes_Fur.mp4 +0 -0
- data/features/html/04-Death_Becomes_Fur.oga +0 -0
- data/features/html/async.html +36 -0
- data/features/html/double_click.html +13 -0
- data/features/html/failure.html +8 -0
- data/features/html/frame_1.html +18 -0
- data/features/html/frame_2.html +16 -0
- data/features/html/frame_3.html +14 -0
- data/features/html/frames.html +12 -0
- data/features/html/hover.html +12 -0
- data/features/html/iframes.html +12 -0
- data/features/html/images/circle.png +0 -0
- data/features/html/images/img_pulpit.jpg +0 -0
- data/features/html/images/submit.gif +0 -0
- data/features/html/indexed_property.html +55 -0
- data/features/html/modal.html +17 -0
- data/features/html/modal_1.html +38 -0
- data/features/html/modal_2.html +27 -0
- data/features/html/movie.mp4 +0 -0
- data/features/html/movie.ogg +0 -0
- data/features/html/multi_elements.html +144 -0
- data/features/html/nested_elements.html +77 -0
- data/features/html/nested_frame_1.html +1 -0
- data/features/html/nested_frame_2.html +11 -0
- data/features/html/nested_frame_3.html +14 -0
- data/features/html/nested_frames.html +10 -0
- data/features/html/planets.gif +0 -0
- data/features/html/static_elements.html +207 -0
- data/features/html/success.html +8 -0
- data/features/html/sun.gif +0 -0
- data/features/html/sun.html +7 -0
- data/features/image.feature +50 -0
- data/features/indexed_property.feature +117 -0
- data/features/javascript.feature +28 -0
- data/features/label.feature +46 -0
- data/features/link.feature +52 -0
- data/features/list_item.feature +36 -0
- data/features/modal_dialog.feature +15 -0
- data/features/multi_elements.feature +492 -0
- data/features/nested_elements.feature +117 -0
- data/features/ordered_list.feature +56 -0
- data/features/page_level_actions.feature +90 -0
- data/features/paragraph.feature +35 -0
- data/features/radio_button.feature +58 -0
- data/features/radio_button_group.feature +29 -0
- data/features/sample-app/public/jquery-1.3.2.js +4376 -0
- data/features/sample-app/public/jquery.html +30 -0
- data/features/sample-app/public/prototype-1.6.0.3.js +4320 -0
- data/features/sample-app/public/prototype.html +35 -0
- data/features/sample-app/sample_app.rb +35 -0
- data/features/section.feature +132 -0
- data/features/select_list.feature +86 -0
- data/features/span.feature +37 -0
- data/features/step_definitions/accessor_steps.rb +64 -0
- data/features/step_definitions/area_steps.rb +19 -0
- data/features/step_definitions/async_steps.rb +83 -0
- data/features/step_definitions/audio_steps.rb +27 -0
- data/features/step_definitions/bold_steps.rb +12 -0
- data/features/step_definitions/button_steps.rb +48 -0
- data/features/step_definitions/canvas_steps.rb +15 -0
- data/features/step_definitions/check_box_steps.rb +35 -0
- data/features/step_definitions/div_steps.rb +19 -0
- data/features/step_definitions/element_steps.rb +266 -0
- data/features/step_definitions/file_field_steps.rb +19 -0
- data/features/step_definitions/form_steps.rb +19 -0
- data/features/step_definitions/frames_steps.rb +159 -0
- data/features/step_definitions/generic_element_steps.rb +31 -0
- data/features/step_definitions/gxt_table_steps.rb +58 -0
- data/features/step_definitions/headings_steps.rb +12 -0
- data/features/step_definitions/hidden_field_steps.rb +27 -0
- data/features/step_definitions/image_steps.rb +27 -0
- data/features/step_definitions/indexed_property_steps.rb +163 -0
- data/features/step_definitions/javascript_steps.rb +53 -0
- data/features/step_definitions/label_steps.rb +19 -0
- data/features/step_definitions/link_steps.rb +40 -0
- data/features/step_definitions/list_item_steps.rb +19 -0
- data/features/step_definitions/modal_dialog_steps.rb +62 -0
- data/features/step_definitions/multi_elements_steps.rb +541 -0
- data/features/step_definitions/nested_elements_steps.rb +212 -0
- data/features/step_definitions/ordered_list_steps.rb +23 -0
- data/features/step_definitions/page_level_actions_steps.rb +135 -0
- data/features/step_definitions/page_traversal_steps.rb +4 -0
- data/features/step_definitions/paragraph_steps.rb +28 -0
- data/features/step_definitions/radio_button_group_steps.rb +36 -0
- data/features/step_definitions/radio_button_steps.rb +27 -0
- data/features/step_definitions/section_steps.rb +268 -0
- data/features/step_definitions/select_list_steps.rb +65 -0
- data/features/step_definitions/span_steps.rb +19 -0
- data/features/step_definitions/table_cell_steps.rb +15 -0
- data/features/step_definitions/table_row_steps.rb +23 -0
- data/features/step_definitions/table_steps.rb +70 -0
- data/features/step_definitions/text_area_steps.rb +35 -0
- data/features/step_definitions/text_field_steps.rb +35 -0
- data/features/step_definitions/unordered_list_steps.rb +23 -0
- data/features/step_definitions/video_steps.rb +45 -0
- data/features/support/ajax_text_environment.rb +26 -0
- data/features/support/env.rb +8 -0
- data/features/support/hooks.rb +8 -0
- data/features/support/page.rb +382 -0
- data/features/support/persistent_browser.rb +70 -0
- data/features/support/targets/firefox14_osx.rb +6 -0
- data/features/support/targets/firefox14_windows7.rb +6 -0
- data/features/support/url_helper.rb +57 -0
- data/features/table.feature +122 -0
- data/features/table_cell.feature +45 -0
- data/features/table_row.feature +43 -0
- data/features/text_area.feature +51 -0
- data/features/text_field.feature +70 -0
- data/features/unordered_list.feature +56 -0
- data/features/video.feature +73 -0
- data/lib/page-object.rb +421 -0
- data/lib/page-object/accessors.rb +1412 -0
- data/lib/page-object/core_ext/string.rb +5 -0
- data/lib/page-object/element_locators.rb +21 -0
- data/lib/page-object/elements.rb +60 -0
- data/lib/page-object/elements/area.rb +31 -0
- data/lib/page-object/elements/audio.rb +9 -0
- data/lib/page-object/elements/bold.rb +11 -0
- data/lib/page-object/elements/button.rb +35 -0
- data/lib/page-object/elements/canvas.rb +23 -0
- data/lib/page-object/elements/check_box.rb +37 -0
- data/lib/page-object/elements/div.rb +19 -0
- data/lib/page-object/elements/element.rb +226 -0
- data/lib/page-object/elements/file_field.rb +38 -0
- data/lib/page-object/elements/form.rb +36 -0
- data/lib/page-object/elements/heading.rb +15 -0
- data/lib/page-object/elements/hidden_field.rb +22 -0
- data/lib/page-object/elements/image.rb +36 -0
- data/lib/page-object/elements/label.rb +19 -0
- data/lib/page-object/elements/link.rb +46 -0
- data/lib/page-object/elements/list_item.rb +19 -0
- data/lib/page-object/elements/media.rb +45 -0
- data/lib/page-object/elements/option.rb +10 -0
- data/lib/page-object/elements/ordered_list.rb +50 -0
- data/lib/page-object/elements/paragraph.rb +9 -0
- data/lib/page-object/elements/radio_button.rb +37 -0
- data/lib/page-object/elements/select_list.rb +42 -0
- data/lib/page-object/elements/span.rb +19 -0
- data/lib/page-object/elements/table.rb +79 -0
- data/lib/page-object/elements/table_cell.rb +28 -0
- data/lib/page-object/elements/table_row.rb +50 -0
- data/lib/page-object/elements/text_area.rb +38 -0
- data/lib/page-object/elements/text_field.rb +42 -0
- data/lib/page-object/elements/unordered_list.rb +51 -0
- data/lib/page-object/elements/video.rb +18 -0
- data/lib/page-object/indexed_properties.rb +40 -0
- data/lib/page-object/javascript/angularjs.rb +14 -0
- data/lib/page-object/javascript/jquery.rb +14 -0
- data/lib/page-object/javascript/prototype.rb +14 -0
- data/lib/page-object/javascript/yui.rb +19 -0
- data/lib/page-object/javascript_framework_facade.rb +80 -0
- data/lib/page-object/loads_platform.rb +45 -0
- data/lib/page-object/locator_generator.rb +131 -0
- data/lib/page-object/nested_elements.rb +17 -0
- data/lib/page-object/page_factory.rb +108 -0
- data/lib/page-object/page_populator.rb +83 -0
- data/lib/page-object/platforms.rb +18 -0
- data/lib/page-object/platforms/selenium_webdriver.rb +30 -0
- data/lib/page-object/platforms/selenium_webdriver/button.rb +15 -0
- data/lib/page-object/platforms/selenium_webdriver/check_box.rb +29 -0
- data/lib/page-object/platforms/selenium_webdriver/element.rb +291 -0
- data/lib/page-object/platforms/selenium_webdriver/file_field.rb +16 -0
- data/lib/page-object/platforms/selenium_webdriver/form.rb +16 -0
- data/lib/page-object/platforms/selenium_webdriver/image.rb +28 -0
- data/lib/page-object/platforms/selenium_webdriver/link.rb +23 -0
- data/lib/page-object/platforms/selenium_webdriver/ordered_list.rb +39 -0
- data/lib/page-object/platforms/selenium_webdriver/page_object.rb +1237 -0
- data/lib/page-object/platforms/selenium_webdriver/radio_button.rb +22 -0
- data/lib/page-object/platforms/selenium_webdriver/select_list.rb +93 -0
- data/lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb +42 -0
- data/lib/page-object/platforms/selenium_webdriver/table.rb +42 -0
- data/lib/page-object/platforms/selenium_webdriver/table_row.rb +43 -0
- data/lib/page-object/platforms/selenium_webdriver/text_area.rb +17 -0
- data/lib/page-object/platforms/selenium_webdriver/text_field.rb +17 -0
- data/lib/page-object/platforms/selenium_webdriver/unordered_list.rb +39 -0
- data/lib/page-object/platforms/watir_webdriver.rb +30 -0
- data/lib/page-object/platforms/watir_webdriver/check_box.rb +29 -0
- data/lib/page-object/platforms/watir_webdriver/element.rb +249 -0
- data/lib/page-object/platforms/watir_webdriver/file_field.rb +16 -0
- data/lib/page-object/platforms/watir_webdriver/form.rb +16 -0
- data/lib/page-object/platforms/watir_webdriver/image.rb +22 -0
- data/lib/page-object/platforms/watir_webdriver/link.rb +15 -0
- data/lib/page-object/platforms/watir_webdriver/ordered_list.rb +35 -0
- data/lib/page-object/platforms/watir_webdriver/page_object.rb +1082 -0
- data/lib/page-object/platforms/watir_webdriver/radio_button.rb +22 -0
- data/lib/page-object/platforms/watir_webdriver/select_list.rb +74 -0
- data/lib/page-object/platforms/watir_webdriver/table.rb +38 -0
- data/lib/page-object/platforms/watir_webdriver/table_row.rb +37 -0
- data/lib/page-object/platforms/watir_webdriver/text_area.rb +23 -0
- data/lib/page-object/platforms/watir_webdriver/text_field.rb +16 -0
- data/lib/page-object/platforms/watir_webdriver/unordered_list.rb +36 -0
- data/lib/page-object/sections.rb +29 -0
- data/lib/page-object/version.rb +4 -0
- data/lib/page-object/widgets.rb +133 -0
- data/page_object.gemspec +31 -0
- data/pageobject.gems +1 -0
- data/spec/page-object/accessors_spec.rb +40 -0
- data/spec/page-object/element_locators_spec.rb +1122 -0
- data/spec/page-object/elements/area_spec.rb +45 -0
- data/spec/page-object/elements/bold_spec.rb +29 -0
- data/spec/page-object/elements/button_spec.rb +64 -0
- data/spec/page-object/elements/canvas_spec.rb +40 -0
- data/spec/page-object/elements/check_box_spec.rb +49 -0
- data/spec/page-object/elements/div_spec.rb +28 -0
- data/spec/page-object/elements/element_spec.rb +114 -0
- data/spec/page-object/elements/file_field_spec.rb +39 -0
- data/spec/page-object/elements/form_spec.rb +28 -0
- data/spec/page-object/elements/heading_spec.rb +48 -0
- data/spec/page-object/elements/hidden_field_spec.rb +28 -0
- data/spec/page-object/elements/image_spec.rb +66 -0
- data/spec/page-object/elements/label_spec.rb +29 -0
- data/spec/page-object/elements/link_spec.rb +49 -0
- data/spec/page-object/elements/list_item_spec.rb +29 -0
- data/spec/page-object/elements/nested_element_spec.rb +254 -0
- data/spec/page-object/elements/option_spec.rb +11 -0
- data/spec/page-object/elements/ordered_list_spec.rb +94 -0
- data/spec/page-object/elements/paragraph_spec.rb +27 -0
- data/spec/page-object/elements/select_list_spec.rb +142 -0
- data/spec/page-object/elements/selenium/radio_button_spec.rb +44 -0
- data/spec/page-object/elements/selenium/text_field_spec.rb +49 -0
- data/spec/page-object/elements/selenium_element_spec.rb +177 -0
- data/spec/page-object/elements/span_spec.rb +26 -0
- data/spec/page-object/elements/table_cell_spec.rb +21 -0
- data/spec/page-object/elements/table_row_spec.rb +70 -0
- data/spec/page-object/elements/table_spec.rb +98 -0
- data/spec/page-object/elements/text_area_spec.rb +39 -0
- data/spec/page-object/elements/unordered_list_spec.rb +94 -0
- data/spec/page-object/elements/watir_element_spec.rb +145 -0
- data/spec/page-object/javascript_framework_facade_spec.rb +61 -0
- data/spec/page-object/loads_platform_spec.rb +53 -0
- data/spec/page-object/page-object_spec.rb +407 -0
- data/spec/page-object/page_factory_spec.rb +238 -0
- data/spec/page-object/page_populator_spec.rb +122 -0
- data/spec/page-object/page_section_spec.rb +73 -0
- data/spec/page-object/platforms/selenium_webdriver/selenium_page_object_spec.rb +68 -0
- data/spec/page-object/platforms/selenium_webdriver_spec.rb +29 -0
- data/spec/page-object/platforms/watir_webdriver/watir_page_object_spec.rb +29 -0
- data/spec/page-object/platforms/watir_webdriver_spec.rb +9 -0
- data/spec/page-object/selenium_accessors_spec.rb +609 -0
- data/spec/page-object/watir_accessors_spec.rb +1134 -0
- data/spec/page-object/widget_spec.rb +226 -0
- data/spec/spec_helper.rb +47 -0
- metadata +601 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe PageObject::Platforms::SeleniumWebDriver do
|
5
|
+
|
6
|
+
it "should be registered as an adapter" do
|
7
|
+
expect(PageObject::Platforms.get[:selenium_webdriver]).to be PageObject::Platforms::SeleniumWebDriver
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'create page object' do
|
11
|
+
let(:browser) { double('browser') }
|
12
|
+
let(:subject) { PageObject::Platforms::SeleniumWebDriver.create_page_object(browser) }
|
13
|
+
|
14
|
+
it "should create a SeleniumPageObject" do
|
15
|
+
expect(subject).to be_kind_of PageObject::Platforms::SeleniumWebDriver::PageObject
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "is for?" do
|
20
|
+
it "should be true when the browser is a selenium driver" do
|
21
|
+
browser = mock_selenium_browser()
|
22
|
+
expect(PageObject::Platforms::SeleniumWebDriver.is_for?(browser)).to eql true
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should be false when the browser is anything else" do
|
26
|
+
expect(PageObject::Platforms::SeleniumWebDriver.is_for?("asdf")).to eql false
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PageObject::Platforms::WatirWebDriver do
|
4
|
+
describe "create page object" do
|
5
|
+
let(:browser) { double('browser') }
|
6
|
+
let(:subject) { PageObject::Platforms::WatirWebDriver.create_page_object(browser) }
|
7
|
+
|
8
|
+
it "should create a WatirPageObject" do
|
9
|
+
expect(subject).to be_kind_of PageObject::Platforms::WatirWebDriver::PageObject
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should give the watir page object the browser" do
|
13
|
+
expect(subject.browser).to be browser
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "is for?" do
|
18
|
+
it "should be true when the browser is Watir::Browser" do
|
19
|
+
browser = mock_watir_browser()
|
20
|
+
expect(PageObject::Platforms::WatirWebDriver.is_for?(browser)).to be true
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should be false at any other point" do
|
24
|
+
browser = 'asdf'
|
25
|
+
expect(PageObject::Platforms::WatirWebDriver.is_for?('asdf')).to be false
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,609 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class SeleniumAccessorsTestPageObject
|
4
|
+
include PageObject
|
5
|
+
|
6
|
+
page_url "http://apple.com"
|
7
|
+
expected_title "Expected Title"
|
8
|
+
expected_element :google_search
|
9
|
+
link(:google_search, :link => 'Google Search')
|
10
|
+
text_field(:first_name, :id => 'first_name')
|
11
|
+
hidden_field(:social_security_number, :id => 'ssn')
|
12
|
+
text_area(:address, :id => 'address')
|
13
|
+
select_list(:state, :id => 'state')
|
14
|
+
checkbox(:active, :id => 'is_active_id')
|
15
|
+
radio_button(:first, :id => 'first_choice')
|
16
|
+
button(:click_me, :id => 'button_submit')
|
17
|
+
div(:message, :id => 'message_id')
|
18
|
+
table(:cart, :id => 'cart_id')
|
19
|
+
cell(:total, :id => 'total')
|
20
|
+
span(:alert_span, :id => 'alert_id')
|
21
|
+
image(:logo, :id => 'logo')
|
22
|
+
form(:login, :id => 'login')
|
23
|
+
list_item(:item_one, :id => 'one')
|
24
|
+
unordered_list(:menu, :id => 'main_menu')
|
25
|
+
ordered_list(:top_five, :id => 'top')
|
26
|
+
h1(:heading1, :id => 'main_heading')
|
27
|
+
h2(:heading2, :id => 'main_heading')
|
28
|
+
h3(:heading3, :id => 'main_heading')
|
29
|
+
h4(:heading4, :id => 'main_heading')
|
30
|
+
h5(:heading5, :id => 'main_heading')
|
31
|
+
h6(:heading6, :id => 'main_heading')
|
32
|
+
paragraph(:first_para, :id => 'first')
|
33
|
+
file_field(:upload_me, :id => 'the_file')
|
34
|
+
area(:img_area, :id => 'area')
|
35
|
+
canvas(:my_canvas, :id => 'canvas')
|
36
|
+
audio(:acdc, :id => 'audio_id')
|
37
|
+
video(:movie, :id => 'movie_id')
|
38
|
+
b(:bold, :id=>'bold')
|
39
|
+
end
|
40
|
+
|
41
|
+
class SeleniumBlockPageObject
|
42
|
+
include PageObject
|
43
|
+
|
44
|
+
attr_reader :value
|
45
|
+
|
46
|
+
text_field :first_name do |element|
|
47
|
+
"text_field"
|
48
|
+
end
|
49
|
+
hidden_field :secret do |element|
|
50
|
+
"hidden_field"
|
51
|
+
end
|
52
|
+
text_area :address do |element|
|
53
|
+
"text_area"
|
54
|
+
end
|
55
|
+
select_list :state do |element|
|
56
|
+
"select_list"
|
57
|
+
end
|
58
|
+
link :continue do |element|
|
59
|
+
"link"
|
60
|
+
end
|
61
|
+
checkbox :active do |element|
|
62
|
+
"checkbox"
|
63
|
+
end
|
64
|
+
radio_button :first do |element|
|
65
|
+
"radio_button"
|
66
|
+
end
|
67
|
+
button :click_me do |element|
|
68
|
+
"button"
|
69
|
+
end
|
70
|
+
div :footer do |element|
|
71
|
+
"div"
|
72
|
+
end
|
73
|
+
span :alert_span do |element|
|
74
|
+
"span"
|
75
|
+
end
|
76
|
+
table :cart do |element|
|
77
|
+
"table"
|
78
|
+
end
|
79
|
+
cell :total do |element|
|
80
|
+
"cell"
|
81
|
+
end
|
82
|
+
image :logo do |element|
|
83
|
+
"image"
|
84
|
+
end
|
85
|
+
form :login do |element|
|
86
|
+
"form"
|
87
|
+
end
|
88
|
+
list_item :item_one do |element|
|
89
|
+
"list_item"
|
90
|
+
end
|
91
|
+
unordered_list :menu do |element|
|
92
|
+
"unordered_list"
|
93
|
+
end
|
94
|
+
ordered_list :top_five do |element|
|
95
|
+
"ordered_list"
|
96
|
+
end
|
97
|
+
h1 :heading1 do |element|
|
98
|
+
"h1"
|
99
|
+
end
|
100
|
+
h2 :heading2 do |element|
|
101
|
+
"h2"
|
102
|
+
end
|
103
|
+
h3 :heading3 do |element|
|
104
|
+
"h3"
|
105
|
+
end
|
106
|
+
h4 :heading4 do |element|
|
107
|
+
"h4"
|
108
|
+
end
|
109
|
+
h5 :heading5 do |element|
|
110
|
+
"h5"
|
111
|
+
end
|
112
|
+
h6 :heading6 do |element|
|
113
|
+
"h6"
|
114
|
+
end
|
115
|
+
paragraph :first_para do |element|
|
116
|
+
"p"
|
117
|
+
end
|
118
|
+
file_field :a_file do |element|
|
119
|
+
"file_field"
|
120
|
+
end
|
121
|
+
area :img_area do |element|
|
122
|
+
"area"
|
123
|
+
end
|
124
|
+
canvas :my_canvas do |element|
|
125
|
+
"canvas"
|
126
|
+
end
|
127
|
+
audio :acdc do |element|
|
128
|
+
'audio'
|
129
|
+
end
|
130
|
+
video :movie do |element|
|
131
|
+
'video'
|
132
|
+
end
|
133
|
+
|
134
|
+
b :bold do |element|
|
135
|
+
'b'
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe PageObject::Accessors do
|
140
|
+
let(:selenium_browser) { mock_selenium_browser }
|
141
|
+
let(:selenium_page_object) { SeleniumAccessorsTestPageObject.new(selenium_browser) }
|
142
|
+
let(:block_page_object) { SeleniumBlockPageObject.new(selenium_browser) }
|
143
|
+
|
144
|
+
before(:each) do
|
145
|
+
allow(selenium_browser).to receive(:switch_to).and_return(selenium_browser)
|
146
|
+
allow(selenium_browser).to receive(:default_content)
|
147
|
+
end
|
148
|
+
|
149
|
+
describe "link accessors" do
|
150
|
+
it "should select a link" do
|
151
|
+
allow(selenium_browser).to receive_messages(find_element: selenium_browser, click: selenium_browser)
|
152
|
+
selenium_page_object.google_search
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should return a link element" do
|
156
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
157
|
+
element = selenium_page_object.google_search_element
|
158
|
+
expect(element).to be_instance_of PageObject::Elements::Link
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
|
163
|
+
describe "text_field accessors" do
|
164
|
+
it "should get the text from the text field element" do
|
165
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
166
|
+
expect(selenium_browser).to receive(:attribute).with('value').and_return('Katie')
|
167
|
+
expect(selenium_page_object.first_name).to eql 'Katie'
|
168
|
+
end
|
169
|
+
|
170
|
+
it "should set some text on a text field element" do
|
171
|
+
expect(selenium_browser).to receive(:find_element).twice.and_return(selenium_browser)
|
172
|
+
expect(selenium_browser).to receive(:clear)
|
173
|
+
expect(selenium_browser).to receive(:send_keys).with('Katie')
|
174
|
+
selenium_page_object.first_name = 'Katie'
|
175
|
+
end
|
176
|
+
|
177
|
+
it "should retrieve a text field element" do
|
178
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
179
|
+
element = selenium_page_object.first_name_element
|
180
|
+
expect(element).to be_instance_of PageObject::Elements::TextField
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
|
185
|
+
describe "hidden field accessors" do
|
186
|
+
it "should get the text from a hidden field" do
|
187
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
188
|
+
expect(selenium_browser).to receive(:attribute).with('value').and_return("12345")
|
189
|
+
expect(selenium_page_object.social_security_number).to eql "12345"
|
190
|
+
end
|
191
|
+
|
192
|
+
it "should retrieve a hidden field element" do
|
193
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
194
|
+
element = selenium_page_object.social_security_number_element
|
195
|
+
expect(element).to be_instance_of PageObject::Elements::HiddenField
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
describe "text area accessors" do
|
200
|
+
it "should set some text on the text area" do
|
201
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
202
|
+
expect(selenium_browser).to receive(:clear)
|
203
|
+
expect(selenium_browser).to receive(:send_keys).with("123 main street")
|
204
|
+
selenium_page_object.address = "123 main street"
|
205
|
+
end
|
206
|
+
|
207
|
+
it "should get the text from the text area" do
|
208
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
209
|
+
expect(selenium_browser).to receive(:attribute).with('value').and_return("123 main street")
|
210
|
+
expect(selenium_page_object.address).to eql "123 main street"
|
211
|
+
end
|
212
|
+
|
213
|
+
it "should retrieve a text area element" do
|
214
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
215
|
+
element = selenium_page_object.address_element
|
216
|
+
expect(element).to be_instance_of PageObject::Elements::TextArea
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
describe "select_list accessors" do
|
221
|
+
it "should should get the current item from a select list" do
|
222
|
+
selected = "OH"
|
223
|
+
expect(selected).to receive(:selected?).and_return(selected)
|
224
|
+
expect(selected).to receive(:text).and_return("OH")
|
225
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
226
|
+
expect(selenium_browser).to receive(:find_elements).and_return([selected])
|
227
|
+
expect(selenium_page_object.state).to eql "OH"
|
228
|
+
end
|
229
|
+
|
230
|
+
it "should set the current item of a select list" do
|
231
|
+
option = double('option')
|
232
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
233
|
+
expect(selenium_browser).to receive(:find_elements).and_return([option])
|
234
|
+
expect(option).to receive(:text).and_return('OH')
|
235
|
+
expect(option).to receive(:click)
|
236
|
+
selenium_page_object.state = "OH"
|
237
|
+
end
|
238
|
+
|
239
|
+
it "should retrieve the select list element" do
|
240
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
241
|
+
element = selenium_page_object.state_element
|
242
|
+
expect(element).to be_instance_of PageObject::Elements::SelectList
|
243
|
+
end
|
244
|
+
|
245
|
+
it "should return list of selection options" do
|
246
|
+
option1 = double('option')
|
247
|
+
option2 = double('option')
|
248
|
+
expect(option1).to receive(:text).and_return("CA")
|
249
|
+
expect(option2).to receive(:text).and_return("OH")
|
250
|
+
|
251
|
+
select_element = double("select")
|
252
|
+
expect(select_element).to receive(:options).twice.and_return([option1, option2])
|
253
|
+
expect(selenium_page_object).to receive(:state_element).and_return(select_element)
|
254
|
+
|
255
|
+
expect(selenium_page_object.state_options).to eql ["CA","OH"]
|
256
|
+
end
|
257
|
+
|
258
|
+
end
|
259
|
+
|
260
|
+
|
261
|
+
describe "check_box accessors" do
|
262
|
+
it "should check a check box element" do
|
263
|
+
expect(selenium_browser).to receive(:find_element).twice.and_return(selenium_browser)
|
264
|
+
expect(selenium_browser).to receive(:selected?).and_return(false)
|
265
|
+
expect(selenium_browser).to receive(:click)
|
266
|
+
selenium_page_object.check_active
|
267
|
+
end
|
268
|
+
|
269
|
+
it "should clear a check box element" do
|
270
|
+
expect(selenium_browser).to receive(:find_element).twice.and_return(selenium_browser)
|
271
|
+
expect(selenium_browser).to receive(:selected?).and_return(true)
|
272
|
+
expect(selenium_browser).to receive(:click)
|
273
|
+
selenium_page_object.uncheck_active
|
274
|
+
end
|
275
|
+
|
276
|
+
it "should know if a check box element is selected" do
|
277
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
278
|
+
expect(selenium_browser).to receive(:selected?).and_return(true)
|
279
|
+
expect(selenium_page_object.active_checked?).to be true
|
280
|
+
end
|
281
|
+
|
282
|
+
it "should retrieve a checkbox element" do
|
283
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
284
|
+
element = selenium_page_object.active_element
|
285
|
+
expect(element).to be_instance_of PageObject::Elements::CheckBox
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
|
290
|
+
describe "radio accessors" do
|
291
|
+
it "should select a radio button" do
|
292
|
+
expect(selenium_browser).to receive(:find_element).twice.and_return(selenium_browser)
|
293
|
+
expect(selenium_browser).to receive(:selected?).and_return(false)
|
294
|
+
expect(selenium_browser).to receive(:click)
|
295
|
+
selenium_page_object.select_first
|
296
|
+
end
|
297
|
+
|
298
|
+
it "should determine if a radio is selected" do
|
299
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
300
|
+
expect(selenium_browser).to receive(:selected?).and_return(true)
|
301
|
+
selenium_page_object.first_selected?
|
302
|
+
end
|
303
|
+
|
304
|
+
it "should retrieve a radio button element" do
|
305
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
306
|
+
element = selenium_page_object.first_element
|
307
|
+
expect(element).to be_instance_of PageObject::Elements::RadioButton
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
describe "button accessors" do
|
312
|
+
it "should be able to click a button" do
|
313
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
314
|
+
expect(selenium_browser).to receive(:click)
|
315
|
+
selenium_page_object.click_me
|
316
|
+
end
|
317
|
+
|
318
|
+
it "should retrieve a button element" do
|
319
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
320
|
+
element = selenium_page_object.click_me_element
|
321
|
+
expect(element).to be_instance_of PageObject::Elements::Button
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
describe "div accessors" do
|
326
|
+
it "should retrieve the text from a div" do
|
327
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
328
|
+
expect(selenium_browser).to receive(:text).and_return("Message from div")
|
329
|
+
expect(selenium_page_object.message).to eql "Message from div"
|
330
|
+
end
|
331
|
+
|
332
|
+
it "should retrieve the div element from the page" do
|
333
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
334
|
+
element = selenium_page_object.message_element
|
335
|
+
expect(element).to be_instance_of PageObject::Elements::Div
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
describe "span accessors" do
|
340
|
+
it "should retrieve the text from a span" do
|
341
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
342
|
+
expect(selenium_browser).to receive(:text).and_return("Alert")
|
343
|
+
expect(selenium_page_object.alert_span).to eql "Alert"
|
344
|
+
end
|
345
|
+
|
346
|
+
it "should retrieve the span element from the page" do
|
347
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
348
|
+
element = selenium_page_object.alert_span_element
|
349
|
+
expect(element).to be_instance_of PageObject::Elements::Span
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
describe "table accessors" do
|
354
|
+
it "should retrieve the table element from the page" do
|
355
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
356
|
+
element = selenium_page_object.cart_element
|
357
|
+
expect(element).to be_instance_of(PageObject::Elements::Table)
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
describe "table cell accessors" do
|
362
|
+
it "should retrieve the text from the cell" do
|
363
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
364
|
+
expect(selenium_browser).to receive(:text).and_return('celldata')
|
365
|
+
expect(selenium_page_object.total).to eql 'celldata'
|
366
|
+
end
|
367
|
+
|
368
|
+
it "should retrieve the cell element from the page" do
|
369
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
370
|
+
element = selenium_page_object.total_element
|
371
|
+
expect(element).to be_instance_of PageObject::Elements::TableCell
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
375
|
+
describe "image accessors" do
|
376
|
+
it "should retrieve the image element from the page" do
|
377
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
378
|
+
element = selenium_page_object.logo_element
|
379
|
+
expect(element).to be_instance_of PageObject::Elements::Image
|
380
|
+
end
|
381
|
+
end
|
382
|
+
|
383
|
+
describe "form accessors" do
|
384
|
+
it "should retrieve the form element from the page" do
|
385
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
386
|
+
element = selenium_page_object.login_element
|
387
|
+
expect(element).to be_instance_of PageObject::Elements::Form
|
388
|
+
end
|
389
|
+
end
|
390
|
+
|
391
|
+
describe "list item accessors" do
|
392
|
+
it "should retrieve the text from the list item" do
|
393
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
394
|
+
expect(selenium_browser).to receive(:text).and_return("value")
|
395
|
+
expect(selenium_page_object.item_one).to eql "value"
|
396
|
+
end
|
397
|
+
|
398
|
+
it "should retrieve the list item from the page" do
|
399
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
400
|
+
element = selenium_page_object.item_one_element
|
401
|
+
expect(element).to be_instance_of PageObject::Elements::ListItem
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
405
|
+
describe "unordered list accessors" do
|
406
|
+
it "should retrieve the element from the page" do
|
407
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
408
|
+
element = selenium_page_object.menu_element
|
409
|
+
expect(element).to be_instance_of PageObject::Elements::UnorderedList
|
410
|
+
end
|
411
|
+
end
|
412
|
+
|
413
|
+
describe "ordered list accessors" do
|
414
|
+
it "should retrieve the element from the page" do
|
415
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
416
|
+
element = selenium_page_object.top_five_element
|
417
|
+
expect(element).to be_instance_of PageObject::Elements::OrderedList
|
418
|
+
end
|
419
|
+
end
|
420
|
+
|
421
|
+
describe "h1 accessors" do
|
422
|
+
it "should retrieve the text from the h1" do
|
423
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
424
|
+
expect(selenium_browser).to receive(:text).and_return("value")
|
425
|
+
expect(selenium_page_object.heading1).to eql "value"
|
426
|
+
end
|
427
|
+
|
428
|
+
it "should retrieve the element from the page" do
|
429
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
430
|
+
element = selenium_page_object.heading1_element
|
431
|
+
expect(element).to be_instance_of PageObject::Elements::Heading
|
432
|
+
end
|
433
|
+
end
|
434
|
+
|
435
|
+
describe "h2 accessors" do
|
436
|
+
it "should retrieve the text from the h2" do
|
437
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
438
|
+
expect(selenium_browser).to receive(:text).and_return("value")
|
439
|
+
expect(selenium_page_object.heading2).to eql "value"
|
440
|
+
end
|
441
|
+
|
442
|
+
it "should retrieve the element from the page" do
|
443
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
444
|
+
element = selenium_page_object.heading2_element
|
445
|
+
expect(element).to be_instance_of PageObject::Elements::Heading
|
446
|
+
end
|
447
|
+
end
|
448
|
+
|
449
|
+
describe "h3 accessors" do
|
450
|
+
it "should retrieve the text from the h3" do
|
451
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
452
|
+
expect(selenium_browser).to receive(:text).and_return("value")
|
453
|
+
expect(selenium_page_object.heading3).to eql "value"
|
454
|
+
end
|
455
|
+
|
456
|
+
it "should retrieve the element from the page" do
|
457
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
458
|
+
element = selenium_page_object.heading3_element
|
459
|
+
expect(element).to be_instance_of PageObject::Elements::Heading
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
463
|
+
describe "h4 accessors" do
|
464
|
+
it "should retrieve the text from the h4" do
|
465
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
466
|
+
expect(selenium_browser).to receive(:text).and_return("value")
|
467
|
+
expect(selenium_page_object.heading4).to eql "value"
|
468
|
+
end
|
469
|
+
|
470
|
+
it "should retrieve the element from the page" do
|
471
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
472
|
+
element = selenium_page_object.heading4_element
|
473
|
+
expect(element).to be_instance_of PageObject::Elements::Heading
|
474
|
+
end
|
475
|
+
end
|
476
|
+
|
477
|
+
describe "h5 accessors" do
|
478
|
+
it "should retrieve the text from the h5" do
|
479
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
480
|
+
expect(selenium_browser).to receive(:text).and_return("value")
|
481
|
+
expect(selenium_page_object.heading5).to eql "value"
|
482
|
+
end
|
483
|
+
|
484
|
+
it "should retrieve the element from the page" do
|
485
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
486
|
+
element = selenium_page_object.heading5_element
|
487
|
+
expect(element).to be_instance_of PageObject::Elements::Heading
|
488
|
+
end
|
489
|
+
end
|
490
|
+
|
491
|
+
describe "h6 accessors" do
|
492
|
+
it "should retrieve the text from the h6" do
|
493
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
494
|
+
expect(selenium_browser).to receive(:text).and_return("value")
|
495
|
+
expect(selenium_page_object.heading6).to eql "value"
|
496
|
+
end
|
497
|
+
|
498
|
+
it "should retrieve the element from the page" do
|
499
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
500
|
+
element = selenium_page_object.heading6_element
|
501
|
+
expect(element).to be_instance_of PageObject::Elements::Heading
|
502
|
+
end
|
503
|
+
end
|
504
|
+
|
505
|
+
|
506
|
+
describe "p accessors" do
|
507
|
+
it "should retrieve the text from the p" do
|
508
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
509
|
+
expect(selenium_browser).to receive(:text).and_return("value")
|
510
|
+
expect(selenium_page_object.first_para).to eql "value"
|
511
|
+
end
|
512
|
+
|
513
|
+
it "should retrieve the element from the page" do
|
514
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
515
|
+
element = selenium_page_object.first_para_element
|
516
|
+
expect(element).to be_instance_of PageObject::Elements::Paragraph
|
517
|
+
end
|
518
|
+
end
|
519
|
+
|
520
|
+
describe "file_field accessors" do
|
521
|
+
it "should set the file name" do
|
522
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
523
|
+
expect(selenium_browser).to receive(:send_keys).with('some_file')
|
524
|
+
selenium_page_object.upload_me = 'some_file'
|
525
|
+
end
|
526
|
+
|
527
|
+
it "should retrieve a file_field element" do
|
528
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
529
|
+
element = selenium_page_object.upload_me_element
|
530
|
+
expect(element).to be_instance_of PageObject::Elements::FileField
|
531
|
+
end
|
532
|
+
end
|
533
|
+
|
534
|
+
describe "area accessors" do
|
535
|
+
context "when called on a page object" do
|
536
|
+
it "should generate accessor methods" do
|
537
|
+
expect(selenium_page_object).to respond_to(:img_area)
|
538
|
+
expect(selenium_page_object).to respond_to(:img_area_element)
|
539
|
+
end
|
540
|
+
|
541
|
+
it "should call a block on the element method when present" do
|
542
|
+
expect(block_page_object.img_area_element).to eql "area"
|
543
|
+
end
|
544
|
+
end
|
545
|
+
|
546
|
+
it "should click on the area" do
|
547
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
548
|
+
expect(selenium_browser).to receive(:click)
|
549
|
+
selenium_page_object.img_area
|
550
|
+
end
|
551
|
+
|
552
|
+
it "should retrieve the element from the page" do
|
553
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
554
|
+
element = selenium_page_object.img_area_element
|
555
|
+
expect(element).to be_instance_of PageObject::Elements::Area
|
556
|
+
end
|
557
|
+
end
|
558
|
+
|
559
|
+
describe "canvas accessors" do
|
560
|
+
context "when called on a page object" do
|
561
|
+
it "should generate accessor methods" do
|
562
|
+
expect(selenium_page_object).to respond_to(:my_canvas_element)
|
563
|
+
end
|
564
|
+
|
565
|
+
it "should call a block on the element method when present" do
|
566
|
+
expect(block_page_object.my_canvas_element).to eql "canvas"
|
567
|
+
end
|
568
|
+
end
|
569
|
+
end
|
570
|
+
|
571
|
+
describe "audio accessors" do
|
572
|
+
context "when called on a page object" do
|
573
|
+
it "should generate accessor methods" do
|
574
|
+
expect(selenium_page_object).to respond_to(:acdc_element)
|
575
|
+
end
|
576
|
+
|
577
|
+
it "should call a block on the element method when present" do
|
578
|
+
expect(block_page_object.acdc_element).to eql "audio"
|
579
|
+
end
|
580
|
+
end
|
581
|
+
end
|
582
|
+
|
583
|
+
describe "video accessors" do
|
584
|
+
context "when called on a page object" do
|
585
|
+
it "should generate accessor methods" do
|
586
|
+
expect(selenium_page_object).to respond_to(:movie_element)
|
587
|
+
end
|
588
|
+
|
589
|
+
it "should call a block on the elmenet method when present" do
|
590
|
+
expect(block_page_object.movie_element).to eql "video"
|
591
|
+
end
|
592
|
+
end
|
593
|
+
end
|
594
|
+
|
595
|
+
describe "b accessors" do
|
596
|
+
it "should retrieve the text from the b" do
|
597
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
598
|
+
expect(selenium_browser).to receive(:text).and_return("value")
|
599
|
+
expect(selenium_page_object.bold).to eql "value"
|
600
|
+
end
|
601
|
+
|
602
|
+
it "should retrieve the element from the page" do
|
603
|
+
expect(selenium_browser).to receive(:find_element).and_return(selenium_browser)
|
604
|
+
element = selenium_page_object.bold_element
|
605
|
+
expect(element).to be_instance_of PageObject::Elements::Bold
|
606
|
+
end
|
607
|
+
end
|
608
|
+
|
609
|
+
end
|