watir 6.0.0.beta5 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -2
- data/CHANGES.md +10 -1
- data/Gemfile +4 -0
- data/README.md +37 -23
- data/Rakefile +6 -10
- data/appveyor.yml +13 -0
- data/lib/watir.rb +20 -21
- data/lib/watir/alert.rb +21 -5
- data/lib/watir/browser.rb +9 -3
- data/lib/watir/elements/checkbox.rb +0 -1
- data/lib/watir/elements/element.rb +92 -50
- data/lib/watir/elements/form.rb +1 -2
- data/lib/watir/elements/iframe.rb +6 -2
- data/lib/watir/elements/image.rb +1 -1
- data/lib/watir/elements/option.rb +0 -1
- data/lib/watir/elements/radio.rb +0 -1
- data/lib/watir/elements/select.rb +1 -10
- data/lib/watir/extensions/select_text.rb +1 -1
- data/lib/watir/legacy_wait.rb +126 -0
- data/lib/watir/locators/text_field/locator.rb +0 -3
- data/lib/watir/locators/text_field/selector_builder.rb +1 -4
- data/lib/watir/locators/text_field/selector_builder/xpath.rb +0 -2
- data/lib/watir/locators/text_field/validator.rb +1 -9
- data/lib/watir/row_container.rb +1 -1
- data/lib/watir/user_editable.rb +7 -5
- data/lib/watir/wait.rb +56 -135
- data/lib/watir/wait/timer.rb +29 -2
- data/lib/watir/window.rb +11 -1
- data/lib/watirspec.rb +81 -0
- data/lib/watirspec/guards.rb +58 -0
- data/lib/watirspec/implementation.rb +33 -0
- data/lib/watirspec/rake_tasks.rb +115 -0
- data/lib/watirspec/runner.rb +53 -0
- data/lib/watirspec/server.rb +99 -0
- data/lib/watirspec/server/app.rb +62 -0
- data/spec/browser_spec.rb +5 -5
- data/spec/click_spec.rb +1 -1
- data/spec/container_spec.rb +1 -1
- data/spec/element_locator_spec.rb +1 -1
- data/spec/element_spec.rb +20 -34
- data/spec/implementation_spec.rb +24 -0
- data/spec/input_spec.rb +1 -1
- data/spec/spec_helper.rb +35 -3
- data/spec/special_chars_spec.rb +1 -1
- data/spec/watirspec/.gitignore +2 -0
- data/spec/watirspec/after_hooks_spec.rb +179 -0
- data/spec/watirspec/alert_spec.rb +101 -0
- data/spec/watirspec/browser_spec.rb +291 -0
- data/spec/watirspec/cookies_spec.rb +147 -0
- data/spec/watirspec/drag_and_drop_spec.rb +49 -0
- data/spec/watirspec/element_hidden_spec.rb +65 -0
- data/spec/watirspec/elements/area_spec.rb +76 -0
- data/spec/watirspec/elements/areas_spec.rb +42 -0
- data/spec/watirspec/elements/button_spec.rb +270 -0
- data/spec/watirspec/elements/buttons_spec.rb +55 -0
- data/spec/watirspec/elements/checkbox_spec.rb +279 -0
- data/spec/watirspec/elements/checkboxes_spec.rb +44 -0
- data/spec/watirspec/elements/collections_spec.rb +16 -0
- data/spec/watirspec/elements/dd_spec.rb +126 -0
- data/spec/watirspec/elements/dds_spec.rb +42 -0
- data/spec/watirspec/elements/del_spec.rb +128 -0
- data/spec/watirspec/elements/dels_spec.rb +40 -0
- data/spec/watirspec/elements/div_spec.rb +199 -0
- data/spec/watirspec/elements/divs_spec.rb +42 -0
- data/spec/watirspec/elements/dl_spec.rb +144 -0
- data/spec/watirspec/elements/dls_spec.rb +43 -0
- data/spec/watirspec/elements/dt_spec.rb +126 -0
- data/spec/watirspec/elements/dts_spec.rb +42 -0
- data/spec/watirspec/elements/element_spec.rb +361 -0
- data/spec/watirspec/elements/elements_spec.rb +15 -0
- data/spec/watirspec/elements/em_spec.rb +100 -0
- data/spec/watirspec/elements/ems_spec.rb +43 -0
- data/spec/watirspec/elements/filefield_spec.rb +181 -0
- data/spec/watirspec/elements/filefields_spec.rb +43 -0
- data/spec/watirspec/elements/font_spec.rb +29 -0
- data/spec/watirspec/elements/form_spec.rb +70 -0
- data/spec/watirspec/elements/forms_spec.rb +44 -0
- data/spec/watirspec/elements/frame_spec.rb +121 -0
- data/spec/watirspec/elements/frames_spec.rb +41 -0
- data/spec/watirspec/elements/hidden_spec.rb +102 -0
- data/spec/watirspec/elements/hiddens_spec.rb +43 -0
- data/spec/watirspec/elements/hn_spec.rb +96 -0
- data/spec/watirspec/elements/hns_spec.rb +38 -0
- data/spec/watirspec/elements/iframe_spec.rb +174 -0
- data/spec/watirspec/elements/iframes_spec.rb +47 -0
- data/spec/watirspec/elements/image_spec.rb +164 -0
- data/spec/watirspec/elements/images_spec.rb +40 -0
- data/spec/watirspec/elements/ins_spec.rb +129 -0
- data/spec/watirspec/elements/inses_spec.rb +40 -0
- data/spec/watirspec/elements/label_spec.rb +79 -0
- data/spec/watirspec/elements/labels_spec.rb +40 -0
- data/spec/watirspec/elements/li_spec.rb +115 -0
- data/spec/watirspec/elements/link_spec.rb +174 -0
- data/spec/watirspec/elements/links_spec.rb +44 -0
- data/spec/watirspec/elements/lis_spec.rb +42 -0
- data/spec/watirspec/elements/map_spec.rb +79 -0
- data/spec/watirspec/elements/maps_spec.rb +41 -0
- data/spec/watirspec/elements/meta_spec.rb +23 -0
- data/spec/watirspec/elements/metas_spec.rb +40 -0
- data/spec/watirspec/elements/ol_spec.rb +89 -0
- data/spec/watirspec/elements/ols_spec.rb +40 -0
- data/spec/watirspec/elements/option_spec.rb +152 -0
- data/spec/watirspec/elements/p_spec.rb +115 -0
- data/spec/watirspec/elements/pre_spec.rb +115 -0
- data/spec/watirspec/elements/pres_spec.rb +40 -0
- data/spec/watirspec/elements/ps_spec.rb +40 -0
- data/spec/watirspec/elements/radio_spec.rb +263 -0
- data/spec/watirspec/elements/radios_spec.rb +43 -0
- data/spec/watirspec/elements/select_list_spec.rb +379 -0
- data/spec/watirspec/elements/select_lists_spec.rb +46 -0
- data/spec/watirspec/elements/span_spec.rb +129 -0
- data/spec/watirspec/elements/spans_spec.rb +40 -0
- data/spec/watirspec/elements/strong_spec.rb +92 -0
- data/spec/watirspec/elements/strongs_spec.rb +43 -0
- data/spec/watirspec/elements/table_nesting_spec.rb +51 -0
- data/spec/watirspec/elements/table_spec.rb +146 -0
- data/spec/watirspec/elements/tables_spec.rb +42 -0
- data/spec/watirspec/elements/tbody_spec.rb +96 -0
- data/spec/watirspec/elements/tbodys_spec.rb +62 -0
- data/spec/watirspec/elements/td_spec.rb +71 -0
- data/spec/watirspec/elements/tds_spec.rb +53 -0
- data/spec/watirspec/elements/text_field_spec.rb +302 -0
- data/spec/watirspec/elements/text_fields_spec.rb +44 -0
- data/spec/watirspec/elements/textarea_spec.rb +26 -0
- data/spec/watirspec/elements/textareas_spec.rb +24 -0
- data/spec/watirspec/elements/tfoot_spec.rb +91 -0
- data/spec/watirspec/elements/tfoots_spec.rb +68 -0
- data/spec/watirspec/elements/thead_spec.rb +91 -0
- data/spec/watirspec/elements/theads_spec.rb +68 -0
- data/spec/watirspec/elements/tr_spec.rb +80 -0
- data/spec/watirspec/elements/trs_spec.rb +61 -0
- data/spec/watirspec/elements/ul_spec.rb +79 -0
- data/spec/watirspec/elements/uls_spec.rb +39 -0
- data/spec/watirspec/html/alerts.html +12 -0
- data/spec/watirspec/html/aria_attributes.html +9 -0
- data/spec/watirspec/html/class_locator.html +8 -0
- data/spec/watirspec/html/clicks.html +19 -0
- data/spec/watirspec/html/closeable.html +13 -0
- data/spec/watirspec/html/collections.html +15 -0
- data/spec/watirspec/html/css/jquery-ui-1.8.17.custom.css +287 -0
- data/spec/watirspec/html/data_attributes.html +9 -0
- data/spec/watirspec/html/definition_lists.html +48 -0
- data/spec/watirspec/html/drag_and_drop.html +106 -0
- data/spec/watirspec/html/font.html +10 -0
- data/spec/watirspec/html/forms_with_input_elements.html +170 -0
- data/spec/watirspec/html/frame_1.html +22 -0
- data/spec/watirspec/html/frame_2.html +16 -0
- data/spec/watirspec/html/frames.html +11 -0
- data/spec/watirspec/html/hover.html +12 -0
- data/spec/watirspec/html/iframe_1.html +22 -0
- data/spec/watirspec/html/iframes.html +12 -0
- data/spec/watirspec/html/images.html +28 -0
- data/spec/watirspec/html/images/1.gif +0 -0
- data/spec/watirspec/html/images/2.gif +0 -0
- data/spec/watirspec/html/images/3.gif +0 -0
- data/spec/watirspec/html/images/button.png +0 -0
- data/spec/watirspec/html/images/circle.png +0 -0
- data/spec/watirspec/html/images/map.gif +0 -0
- data/spec/watirspec/html/images/map2.gif +0 -0
- data/spec/watirspec/html/images/minus.gif +0 -0
- data/spec/watirspec/html/images/originaltriangle.png +0 -0
- data/spec/watirspec/html/images/plus.gif +0 -0
- data/spec/watirspec/html/images/square.png +0 -0
- data/spec/watirspec/html/images/triangle.png +0 -0
- data/spec/watirspec/html/inner_outer.html +5 -0
- data/spec/watirspec/html/javascript/helpers.js +16 -0
- data/spec/watirspec/html/javascript/jquery-1.7.1.min.js +4 -0
- data/spec/watirspec/html/javascript/jquery-ui-1.8.17.custom.min.js +68 -0
- data/spec/watirspec/html/keylogger.html +15 -0
- data/spec/watirspec/html/modal_dialog.html +9 -0
- data/spec/watirspec/html/multiple_ids.html +14 -0
- data/spec/watirspec/html/nested_frame_1.html +1 -0
- data/spec/watirspec/html/nested_frame_2.html +9 -0
- data/spec/watirspec/html/nested_frame_3.html +14 -0
- data/spec/watirspec/html/nested_frames.html +10 -0
- data/spec/watirspec/html/nested_iframe_2.html +12 -0
- data/spec/watirspec/html/nested_iframes.html +9 -0
- data/spec/watirspec/html/nested_tables.html +203 -0
- data/spec/watirspec/html/non_control_elements.html +135 -0
- data/spec/watirspec/html/removed_element.html +24 -0
- data/spec/watirspec/html/right_click.html +11 -0
- data/spec/watirspec/html/special_chars.html +12 -0
- data/spec/watirspec/html/tables.html +121 -0
- data/spec/watirspec/html/timeout_window_location.html +19 -0
- data/spec/watirspec/html/uneven_table.html +20 -0
- data/spec/watirspec/html/wait.html +65 -0
- data/spec/watirspec/html/watirspec.css +0 -0
- data/spec/watirspec/html/window_switching.html +12 -0
- data/spec/watirspec/relaxed_locate_spec.rb +214 -0
- data/spec/watirspec/screenshot_spec.rb +29 -0
- data/spec/watirspec/wait_spec.rb +304 -0
- data/spec/watirspec/window_switching_spec.rb +411 -0
- data/spec/{implementation.rb → watirspec_helper.rb} +13 -13
- data/support/appveyor.cmd +9 -0
- data/support/doctest_helper.rb +5 -1
- data/support/travis.sh +0 -1
- data/watir.gemspec +3 -4
- metadata +323 -30
- data/.gitmodules +0 -3
@@ -0,0 +1,115 @@
|
|
1
|
+
require "watirspec_helper"
|
2
|
+
|
3
|
+
describe "P" do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
browser.goto(WatirSpec.url_for("non_control_elements.html"))
|
7
|
+
end
|
8
|
+
|
9
|
+
# Exists method
|
10
|
+
describe "#exist?" do
|
11
|
+
it "returns true if the 'p' exists" do
|
12
|
+
expect(browser.p(id: "lead")).to exist
|
13
|
+
expect(browser.p(id: /lead/)).to exist
|
14
|
+
expect(browser.p(text: "Dubito, ergo cogito, ergo sum.")).to exist
|
15
|
+
expect(browser.p(text: /Dubito, ergo cogito, ergo sum/)).to exist
|
16
|
+
expect(browser.p(class: "lead")).to exist
|
17
|
+
expect(browser.p(class: /lead/)).to exist
|
18
|
+
expect(browser.p(index: 0)).to exist
|
19
|
+
expect(browser.p(xpath: "//p[@id='lead']")).to exist
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns the first p if given no args" do
|
23
|
+
expect(browser.p).to exist
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns false if the 'p' doesn't exist" do
|
27
|
+
expect(browser.p(id: "no_such_id")).to_not exist
|
28
|
+
expect(browser.p(id: /no_such_id/)).to_not exist
|
29
|
+
expect(browser.p(text: "no_such_text")).to_not exist
|
30
|
+
expect(browser.p(text: /no_such_text/)).to_not exist
|
31
|
+
expect(browser.p(class: "no_such_class")).to_not exist
|
32
|
+
expect(browser.p(class: /no_such_class/)).to_not exist
|
33
|
+
expect(browser.p(index: 1337)).to_not exist
|
34
|
+
expect(browser.p(xpath: "//p[@id='no_such_id']")).to_not exist
|
35
|
+
end
|
36
|
+
|
37
|
+
it "raises TypeError when 'what' argument is invalid" do
|
38
|
+
expect { browser.p(id: 3.14).exists? }.to raise_error(TypeError)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
42
|
+
expect { browser.p(no_such_how: 'some_value').exists? }.to raise_error(Watir::Exception::MissingWayOfFindingObjectException)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Attribute methods
|
47
|
+
describe "#class_name" do
|
48
|
+
it "returns the class attribute" do
|
49
|
+
expect(browser.p(index: 0).class_name).to eq 'lead'
|
50
|
+
end
|
51
|
+
|
52
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
53
|
+
expect(browser.p(index: 2).class_name).to eq ''
|
54
|
+
end
|
55
|
+
|
56
|
+
it "raises UnknownObjectException if the p doesn't exist" do
|
57
|
+
expect { browser.p(id: 'no_such_id').class_name }.to raise_unknown_object_exception
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "#id" do
|
62
|
+
it "returns the id attribute" do
|
63
|
+
expect(browser.p(index: 0).id).to eq "lead"
|
64
|
+
end
|
65
|
+
|
66
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
67
|
+
expect(browser.p(index: 2).id).to eq ''
|
68
|
+
end
|
69
|
+
|
70
|
+
it "raises UnknownObjectException if the p doesn't exist" do
|
71
|
+
expect { browser.p(id: "no_such_id").id }.to raise_unknown_object_exception
|
72
|
+
expect { browser.p(index: 1337).id }.to raise_unknown_object_exception
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#title" do
|
77
|
+
it "returns the title attribute" do
|
78
|
+
expect(browser.p(index: 0).title).to eq 'Lorem ipsum'
|
79
|
+
end
|
80
|
+
|
81
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
82
|
+
expect(browser.p(index: 2).title).to eq ''
|
83
|
+
end
|
84
|
+
|
85
|
+
it "raises UnknownObjectException if the p doesn't exist" do
|
86
|
+
expect { browser.p(id: 'no_such_id').title }.to raise_unknown_object_exception
|
87
|
+
expect { browser.p(xpath: "//p[@id='no_such_id']").title }.to raise_unknown_object_exception
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "#text" do
|
92
|
+
it "returns the text of the p" do
|
93
|
+
expect(browser.p(index: 1).text).to eq 'Sed pretium metus et quam. Nullam odio dolor, vestibulum non, tempor ut, vehicula sed, sapien. Vestibulum placerat ligula at quam. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.'
|
94
|
+
end
|
95
|
+
|
96
|
+
it "returns an empty string if the element doesn't contain any text" do
|
97
|
+
expect(browser.p(index: 4).text).to eq ''
|
98
|
+
end
|
99
|
+
|
100
|
+
it "raises UnknownObjectException if the p doesn't exist" do
|
101
|
+
expect { browser.p(id: 'no_such_id').text }.to raise_unknown_object_exception
|
102
|
+
expect { browser.p(:xpath , "//p[@id='no_such_id']").text }.to raise_unknown_object_exception
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "#respond_to?" do
|
107
|
+
it "returns true for all attribute methods" do
|
108
|
+
expect(browser.p(index: 0)).to respond_to(:class_name)
|
109
|
+
expect(browser.p(index: 0)).to respond_to(:id)
|
110
|
+
expect(browser.p(index: 0)).to respond_to(:title)
|
111
|
+
expect(browser.p(index: 0)).to respond_to(:text)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require "watirspec_helper"
|
2
|
+
|
3
|
+
describe "Pre" do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
browser.goto(WatirSpec.url_for("non_control_elements.html"))
|
7
|
+
end
|
8
|
+
|
9
|
+
# Exists method
|
10
|
+
describe "#exist?" do
|
11
|
+
it "returns true if the 'p' exists" do
|
12
|
+
expect(browser.pre(id: "rspec")).to exist
|
13
|
+
expect(browser.pre(id: /rspec/)).to exist
|
14
|
+
expect(browser.pre(text: 'browser.pre(id: "rspec").should exist')).to exist
|
15
|
+
expect(browser.pre(text: /browser\.pre/)).to exist
|
16
|
+
expect(browser.pre(class: "ruby")).to exist
|
17
|
+
expect(browser.pre(class: /ruby/)).to exist
|
18
|
+
expect(browser.pre(index: 0)).to exist
|
19
|
+
expect(browser.pre(xpath: "//pre[@id='rspec']")).to exist
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns the first pre if given no args" do
|
23
|
+
expect(browser.pre).to exist
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns false if the 'p' doesn't exist" do
|
27
|
+
expect(browser.pre(id: "no_such_id")).to_not exist
|
28
|
+
expect(browser.pre(id: /no_such_id/)).to_not exist
|
29
|
+
expect(browser.pre(text: "no_such_text")).to_not exist
|
30
|
+
expect(browser.pre(text: /no_such_text/)).to_not exist
|
31
|
+
expect(browser.pre(class: "no_such_class")).to_not exist
|
32
|
+
expect(browser.pre(class: /no_such_class/)).to_not exist
|
33
|
+
expect(browser.pre(index: 1337)).to_not exist
|
34
|
+
expect(browser.pre(xpath: "//pre[@id='no_such_id']")).to_not exist
|
35
|
+
end
|
36
|
+
|
37
|
+
it "raises TypeError when 'what' argument is invalid" do
|
38
|
+
expect { browser.pre(id: 3.14).exists? }.to raise_error(TypeError)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
42
|
+
expect { browser.pre(no_such_how: 'some_value').exists? }.to raise_error(Watir::Exception::MissingWayOfFindingObjectException)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Attribute methods
|
47
|
+
describe "#class_name" do
|
48
|
+
it "returns the class attribute" do
|
49
|
+
expect(browser.pre(id: 'rspec').class_name).to eq 'ruby'
|
50
|
+
end
|
51
|
+
|
52
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
53
|
+
expect(browser.pre(index: 0).class_name).to eq ''
|
54
|
+
end
|
55
|
+
|
56
|
+
it "raises UnknownObjectException if the p doesn't exist" do
|
57
|
+
expect { browser.pre(id: 'no_such_id').class_name }.to raise_unknown_object_exception
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "#id" do
|
62
|
+
it "returns the id attribute" do
|
63
|
+
expect(browser.pre(class: 'ruby').id).to eq "rspec"
|
64
|
+
end
|
65
|
+
|
66
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
67
|
+
expect(browser.pre(index: 0).id).to eq ''
|
68
|
+
end
|
69
|
+
|
70
|
+
it "raises UnknownObjectException if the pre doesn't exist" do
|
71
|
+
expect { browser.pre(id: "no_such_id").id }.to raise_unknown_object_exception
|
72
|
+
expect { browser.pre(index: 1337).id }.to raise_unknown_object_exception
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#title" do
|
77
|
+
it "returns the title attribute" do
|
78
|
+
expect(browser.pre(class: 'brainfuck').title).to eq 'The brainfuck language is an esoteric programming language noted for its extreme minimalism'
|
79
|
+
end
|
80
|
+
|
81
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
82
|
+
expect(browser.pre(index: 0).title).to eq ''
|
83
|
+
end
|
84
|
+
|
85
|
+
it "raises UnknownObjectException if the pre doesn't exist" do
|
86
|
+
expect { browser.pre(id: 'no_such_id').title }.to raise_unknown_object_exception
|
87
|
+
expect { browser.pre(xpath: "//pre[@id='no_such_id']").title }.to raise_unknown_object_exception
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "#text" do
|
92
|
+
it "returns the text of the pre" do
|
93
|
+
expect(browser.pre(class: 'haskell').text).to eq 'main = putStrLn "Hello World"'
|
94
|
+
end
|
95
|
+
|
96
|
+
it "returns an empty string if the element doesn't contain any text" do
|
97
|
+
expect(browser.pre(index: 0).text).to eq ''
|
98
|
+
end
|
99
|
+
|
100
|
+
it "raises UnknownObjectException if the pre doesn't exist" do
|
101
|
+
expect { browser.pre(id: 'no_such_id').text }.to raise_unknown_object_exception
|
102
|
+
expect { browser.pre(:xpath , "//pre[@id='no_such_id']").text }.to raise_unknown_object_exception
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "#respond_to?" do
|
107
|
+
it "returns true for all attribute methods" do
|
108
|
+
expect(browser.image(index: 0)).to respond_to(:class_name)
|
109
|
+
expect(browser.image(index: 0)).to respond_to(:id)
|
110
|
+
expect(browser.image(index: 0)).to respond_to(:title)
|
111
|
+
expect(browser.image(index: 0)).to respond_to(:text)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "watirspec_helper"
|
2
|
+
|
3
|
+
describe "Pres" do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
browser.goto(WatirSpec.url_for("non_control_elements.html"))
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "with selectors" do
|
10
|
+
it "returns the matching elements" do
|
11
|
+
expect(browser.pres(class: "c-plus-plus").to_a).to eq [browser.pre(class: "c-plus-plus")]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#length" do
|
16
|
+
it "returns the number of pres" do
|
17
|
+
expect(browser.pres.length).to eq 7
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#[]" do
|
22
|
+
it "returns the pre at the given index" do
|
23
|
+
expect(browser.pres[1].id).to eq "rspec"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#each" do
|
28
|
+
it "iterates through pres correctly" do
|
29
|
+
count = 0
|
30
|
+
|
31
|
+
browser.pres.each_with_index do |p, index|
|
32
|
+
expect(p.id).to eq browser.pre(index: index).id
|
33
|
+
count += 1
|
34
|
+
end
|
35
|
+
|
36
|
+
expect(count).to be > 0
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "watirspec_helper"
|
2
|
+
|
3
|
+
describe "Ps" do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
browser.goto(WatirSpec.url_for("non_control_elements.html"))
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "with selectors" do
|
10
|
+
it "returns the matching elements" do
|
11
|
+
expect(browser.ps(class: "lead").to_a).to eq [browser.p(class: "lead")]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#length" do
|
16
|
+
it "returns the number of ps" do
|
17
|
+
expect(browser.ps.length).to eq 5
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#[]" do
|
22
|
+
it "returns the p at the given index" do
|
23
|
+
expect(browser.ps[0].id).to eq "lead"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#each" do
|
28
|
+
it "iterates through ps correctly" do
|
29
|
+
count = 0
|
30
|
+
|
31
|
+
browser.ps.each_with_index do |p, index|
|
32
|
+
expect(p.id).to eq browser.p(index: index).id
|
33
|
+
count += 1
|
34
|
+
end
|
35
|
+
|
36
|
+
expect(count).to be > 0
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,263 @@
|
|
1
|
+
require "watirspec_helper"
|
2
|
+
|
3
|
+
describe "Radio" do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
browser.goto(WatirSpec.url_for("forms_with_input_elements.html"))
|
7
|
+
end
|
8
|
+
|
9
|
+
# Exists method
|
10
|
+
describe "#exists?" do
|
11
|
+
it "returns true if the radio button exists" do
|
12
|
+
expect(browser.radio(id: "new_user_newsletter_yes")).to exist
|
13
|
+
expect(browser.radio(id: /new_user_newsletter_yes/)).to exist
|
14
|
+
expect(browser.radio(name: "new_user_newsletter")).to exist
|
15
|
+
expect(browser.radio(name: /new_user_newsletter/)).to exist
|
16
|
+
expect(browser.radio(value: "yes")).to exist
|
17
|
+
expect(browser.radio(value: /yes/)).to exist
|
18
|
+
# TODO: figure out what :text means for a radio button
|
19
|
+
# browser.radio(text: "yes").to exist
|
20
|
+
# browser.radio(text: /yes/).to exist
|
21
|
+
expect(browser.radio(class: "huge")).to exist
|
22
|
+
expect(browser.radio(class: /huge/)).to exist
|
23
|
+
expect(browser.radio(index: 0)).to exist
|
24
|
+
expect(browser.radio(xpath: "//input[@id='new_user_newsletter_yes']")).to exist
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns the first radio if given no args" do
|
28
|
+
expect(browser.radio).to exist
|
29
|
+
end
|
30
|
+
|
31
|
+
it "returns true if the radio button exists (search by name and value)" do
|
32
|
+
expect(browser.radio(name: "new_user_newsletter", value: 'yes')).to exist
|
33
|
+
browser.radio(xpath: "//input[@name='new_user_newsletter' and @value='yes']").set
|
34
|
+
end
|
35
|
+
|
36
|
+
it "returns true for element with upper case type" do
|
37
|
+
expect(browser.radio(id: "new_user_newsletter_probably")).to exist
|
38
|
+
end
|
39
|
+
|
40
|
+
it "returns false if the radio button does not exist" do
|
41
|
+
expect(browser.radio(id: "no_such_id")).to_not exist
|
42
|
+
expect(browser.radio(id: /no_such_id/)).to_not exist
|
43
|
+
expect(browser.radio(name: "no_such_name")).to_not exist
|
44
|
+
expect(browser.radio(name: /no_such_name/)).to_not exist
|
45
|
+
expect(browser.radio(value: "no_such_value")).to_not exist
|
46
|
+
expect(browser.radio(value: /no_such_value/)).to_not exist
|
47
|
+
expect(browser.radio(text: "no_such_text")).to_not exist
|
48
|
+
expect(browser.radio(text: /no_such_text/)).to_not exist
|
49
|
+
expect(browser.radio(class: "no_such_class")).to_not exist
|
50
|
+
expect(browser.radio(class: /no_such_class/)).to_not exist
|
51
|
+
expect(browser.radio(index: 1337)).to_not exist
|
52
|
+
expect(browser.radio(xpath: "input[@id='no_such_id']")).to_not exist
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns false if the radio button does not exist (search by name and value)" do
|
56
|
+
expect(browser.radio(name: "new_user_newsletter", value: 'no_such_value')).to_not exist
|
57
|
+
expect(browser.radio(xpath: "//input[@name='new_user_newsletter' and @value='no_such_value']")).to_not exist
|
58
|
+
expect(browser.radio(name: "no_such_name", value: 'yes')).to_not exist
|
59
|
+
expect(browser.radio(xpath: "//input[@name='no_such_name' and @value='yes']")).to_not exist
|
60
|
+
end
|
61
|
+
|
62
|
+
it "returns true for radios with a string value" do
|
63
|
+
expect(browser.radio(name: 'new_user_newsletter', value: 'yes')).to exist
|
64
|
+
expect(browser.radio(name: 'new_user_newsletter', value: 'no')).to exist
|
65
|
+
end
|
66
|
+
|
67
|
+
it "raises TypeError when 'what' argument is invalid" do
|
68
|
+
expect { browser.radio(id: 3.14).exists? }.to raise_error(TypeError)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
72
|
+
expect { browser.radio(no_such_how: 'some_value').exists? }.to raise_error(Watir::Exception::MissingWayOfFindingObjectException)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# Attribute methods
|
77
|
+
describe "#class_name" do
|
78
|
+
it "returns the class name if the radio exists and has an attribute" do
|
79
|
+
expect(browser.radio(id: "new_user_newsletter_yes").class_name).to eq "huge"
|
80
|
+
end
|
81
|
+
|
82
|
+
it "returns an empty string if the radio exists and the attribute doesn't" do
|
83
|
+
expect(browser.radio(id: "new_user_newsletter_no").class_name).to eq ""
|
84
|
+
end
|
85
|
+
|
86
|
+
it "raises UnknownObjectException if the radio doesn't exist" do
|
87
|
+
expect { browser.radio(id: "no_such_id").class_name }.to raise_unknown_object_exception
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "#id" do
|
92
|
+
it "returns the id attribute if the radio exists and has an attribute" do
|
93
|
+
expect(browser.radio(index: 0).id).to eq "new_user_newsletter_yes"
|
94
|
+
end
|
95
|
+
|
96
|
+
it "returns an empty string if the radio exists and the attribute doesn't" do
|
97
|
+
expect(browser.radio(index: 2).id).to eq ""
|
98
|
+
end
|
99
|
+
|
100
|
+
it "raises UnknownObjectException if the radio doesn't exist" do
|
101
|
+
expect { browser.radio(index: 1337).id }.to raise_unknown_object_exception
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "#name" do
|
106
|
+
it "returns the name attribute if the radio exists" do
|
107
|
+
expect(browser.radio(id: 'new_user_newsletter_yes').name).to eq "new_user_newsletter"
|
108
|
+
end
|
109
|
+
|
110
|
+
it "returns an empty string if the radio exists and the attribute doesn't" do
|
111
|
+
expect(browser.radio(id: 'new_user_newsletter_absolutely').name).to eq ""
|
112
|
+
end
|
113
|
+
|
114
|
+
it "raises UnknownObjectException if the radio doesn't exist" do
|
115
|
+
expect { browser.radio(index: 1337).name }.to raise_unknown_object_exception
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "#title" do
|
120
|
+
it "returns the title attribute if the radio exists" do
|
121
|
+
expect(browser.radio(id: "new_user_newsletter_no").title).to eq "Traitor!"
|
122
|
+
end
|
123
|
+
|
124
|
+
it "returns an empty string if the radio exists and the attribute doesn't" do
|
125
|
+
expect(browser.radio(id: "new_user_newsletter_yes").title).to eq ""
|
126
|
+
end
|
127
|
+
|
128
|
+
it "raises UnknownObjectException if the radio doesn't exist" do
|
129
|
+
expect { browser.radio(index: 1337).title }.to raise_unknown_object_exception
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe "#type" do
|
134
|
+
it "returns the type attribute if the radio exists" do
|
135
|
+
expect(browser.radio(index: 0).type).to eq "radio"
|
136
|
+
end
|
137
|
+
|
138
|
+
it "raises UnknownObjectException if the radio doesn't exist" do
|
139
|
+
expect { browser.radio(index: 1337).type }.to raise_unknown_object_exception
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe "#value" do
|
144
|
+
it "returns the value attribute if the radio exists" do
|
145
|
+
expect(browser.radio(id: 'new_user_newsletter_yes').value).to eq 'yes'
|
146
|
+
end
|
147
|
+
|
148
|
+
it "raises UnknownObjectException if the radio doesn't exist" do
|
149
|
+
expect { browser.radio(index: 1337).value}.to raise_unknown_object_exception
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
describe "#respond_to?" do
|
154
|
+
it "returns true for all attribute methods" do
|
155
|
+
expect(browser.radio(index: 0)).to respond_to(:class_name)
|
156
|
+
expect(browser.radio(index: 0)).to respond_to(:id)
|
157
|
+
expect(browser.radio(index: 0)).to respond_to(:name)
|
158
|
+
expect(browser.radio(index: 0)).to respond_to(:title)
|
159
|
+
expect(browser.radio(index: 0)).to respond_to(:type)
|
160
|
+
expect(browser.radio(index: 0)).to respond_to(:value)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
# Access methods
|
165
|
+
describe "#enabled?" do
|
166
|
+
it "returns true if the radio button is enabled" do
|
167
|
+
expect(browser.radio(id: "new_user_newsletter_yes")).to be_enabled
|
168
|
+
expect(browser.radio(xpath: "//input[@id='new_user_newsletter_yes']")).to be_enabled
|
169
|
+
end
|
170
|
+
|
171
|
+
it "returns false if the radio button is disabled" do
|
172
|
+
expect(browser.radio(id: "new_user_newsletter_nah")).to_not be_enabled
|
173
|
+
expect(browser.radio(xpath: "//input[@id='new_user_newsletter_nah']")).to_not be_enabled
|
174
|
+
end
|
175
|
+
|
176
|
+
it "raises UnknownObjectException if the radio button doesn't exist" do
|
177
|
+
expect { browser.radio(id: "no_such_id").enabled? }.to raise_unknown_object_exception
|
178
|
+
expect { browser.radio(xpath: "//input[@id='no_such_id']").enabled? }.to raise_unknown_object_exception
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
describe "#disabled?" do
|
183
|
+
it "returns true if the radio is disabled" do
|
184
|
+
expect(browser.radio(id: 'new_user_newsletter_nah')).to be_disabled
|
185
|
+
end
|
186
|
+
|
187
|
+
it "returns false if the radio is enabled" do
|
188
|
+
expect(browser.radio(id: 'new_user_newsletter_yes')).to_not be_disabled
|
189
|
+
end
|
190
|
+
|
191
|
+
it "raises UnknownObjectException if the radio doesn't exist" do
|
192
|
+
expect { browser.radio(index: 1337).disabled? }.to raise_unknown_object_exception
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
describe "#set" do
|
197
|
+
it "sets the radio button" do
|
198
|
+
browser.radio(id: "new_user_newsletter_no").set
|
199
|
+
expect(browser.radio(id: "new_user_newsletter_no")).to be_set
|
200
|
+
end
|
201
|
+
|
202
|
+
it "sets the radio button when found by :xpath" do
|
203
|
+
browser.radio(xpath: "//input[@id='new_user_newsletter_no']").set
|
204
|
+
expect(browser.radio(xpath: "//input[@id='new_user_newsletter_no']")).to be_set
|
205
|
+
end
|
206
|
+
|
207
|
+
it "fires the onclick event" do
|
208
|
+
browser.radio(id: "new_user_newsletter_no").set
|
209
|
+
browser.radio(id: "new_user_newsletter_yes").set
|
210
|
+
expect(messages).to eq ["clicked: new_user_newsletter_no", "clicked: new_user_newsletter_yes"]
|
211
|
+
end
|
212
|
+
|
213
|
+
# http://webbugtrack.blogspot.com/2007/11/bug-193-onchange-does-not-fire-properly.html
|
214
|
+
not_compliant_on :internet_explorer do
|
215
|
+
it "fires the onchange event" do
|
216
|
+
browser.radio(value: 'certainly').set
|
217
|
+
expect(messages).to eq ["changed: new_user_newsletter"]
|
218
|
+
|
219
|
+
browser.radio(value: 'certainly').set
|
220
|
+
expect(messages).to eq ["changed: new_user_newsletter"] # no event fired here - didn't change
|
221
|
+
|
222
|
+
browser.radio(value: 'yes').set
|
223
|
+
browser.radio(value: 'certainly').set
|
224
|
+
expect(messages).to eq ["changed: new_user_newsletter", "clicked: new_user_newsletter_yes", "changed: new_user_newsletter"]
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
it "raises UnknownObjectException if the radio button doesn't exist" do
|
229
|
+
expect { browser.radio(name: "no_such_name").set }.to raise_unknown_object_exception
|
230
|
+
expect { browser.radio(xpath: "//input[@name='no_such_name']").set }.to raise_unknown_object_exception
|
231
|
+
end
|
232
|
+
|
233
|
+
it "raises ObjectDisabledException if the radio is disabled" do
|
234
|
+
expect { browser.radio(id: "new_user_newsletter_nah").set }.to raise_object_disabled_exception
|
235
|
+
expect { browser.radio(xpath: "//input[@id='new_user_newsletter_nah']").set }.to raise_object_disabled_exception
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
# Other
|
240
|
+
describe '#set?' do
|
241
|
+
it "returns true if the radio button is set" do
|
242
|
+
expect(browser.radio(id: "new_user_newsletter_yes")).to be_set
|
243
|
+
end
|
244
|
+
|
245
|
+
it "returns false if the radio button unset" do
|
246
|
+
expect(browser.radio(id: "new_user_newsletter_no")).to_not be_set
|
247
|
+
end
|
248
|
+
|
249
|
+
it "returns the state for radios with string values" do
|
250
|
+
expect(browser.radio(name: "new_user_newsletter", value: 'no')).to_not be_set
|
251
|
+
browser.radio(name: "new_user_newsletter", value: 'no').set
|
252
|
+
expect(browser.radio(name: "new_user_newsletter", value: 'no')).to be_set
|
253
|
+
browser.radio(name: "new_user_newsletter", value: 'yes').set
|
254
|
+
expect(browser.radio(name: "new_user_newsletter", value: 'no')).to_not be_set
|
255
|
+
end
|
256
|
+
|
257
|
+
it "raises UnknownObjectException if the radio button doesn't exist" do
|
258
|
+
expect { browser.radio(id: "no_such_id").set? }.to raise_unknown_object_exception
|
259
|
+
expect { browser.radio(xpath: "//input[@id='no_such_id']").set? }.to raise_unknown_object_exception
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
end
|