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,55 @@
|
|
1
|
+
require "watirspec_helper"
|
2
|
+
|
3
|
+
describe "Buttons" do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
browser.goto(WatirSpec.url_for("forms_with_input_elements.html"))
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "with selectors" do
|
10
|
+
it "returns the matching elements" do
|
11
|
+
expect(browser.buttons(name: "new_user_button").to_a).to eq [browser.button(name: "new_user_button")]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#length" do
|
16
|
+
it "returns the number of buttons" do
|
17
|
+
expect(browser.buttons.length).to eq 9
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#[]" do
|
22
|
+
it "returns the button at the given index" do
|
23
|
+
expect(browser.buttons[0].title).to eq "Submit the form"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#first" do
|
28
|
+
it "returns the first element in the collection" do
|
29
|
+
expect(browser.buttons.first.value).to eq browser.buttons[0].value
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#last" do
|
34
|
+
it "returns the last element in the collection" do
|
35
|
+
expect(browser.buttons.last.value).to eq browser.buttons[-1].value
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#each" do
|
40
|
+
it "iterates through buttons correctly" do
|
41
|
+
count = 0
|
42
|
+
|
43
|
+
browser.buttons.each_with_index do |b, index|
|
44
|
+
expect(b.name).to eq browser.button(index: index).name
|
45
|
+
expect(b.id).to eq browser.button(index: index).id
|
46
|
+
expect(b.value).to eq browser.button(index: index).value
|
47
|
+
|
48
|
+
count += 1
|
49
|
+
end
|
50
|
+
|
51
|
+
expect(count).to be > 0
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,279 @@
|
|
1
|
+
require "watirspec_helper"
|
2
|
+
|
3
|
+
describe "CheckBox" do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
browser.goto(WatirSpec.url_for("forms_with_input_elements.html"))
|
7
|
+
end
|
8
|
+
|
9
|
+
# Exists method
|
10
|
+
|
11
|
+
describe "#exists?" do
|
12
|
+
it "returns true if the checkbox button exists" do
|
13
|
+
expect(browser.checkbox(id: "new_user_interests_books")).to exist
|
14
|
+
expect(browser.checkbox(id: /new_user_interests_books/)).to exist
|
15
|
+
expect(browser.checkbox(name: "new_user_interests")).to exist
|
16
|
+
expect(browser.checkbox(name: /new_user_interests/)).to exist
|
17
|
+
expect(browser.checkbox(value: "books")).to exist
|
18
|
+
expect(browser.checkbox(value: /books/)).to exist
|
19
|
+
# not sure what :text is supposed to represent here
|
20
|
+
# browser.checkbox(text: "books").to exist
|
21
|
+
# browser.checkbox(text: /books/).to exist
|
22
|
+
expect(browser.checkbox(class: "fun")).to exist
|
23
|
+
expect(browser.checkbox(class: /fun/)).to exist
|
24
|
+
expect(browser.checkbox(index: 0)).to exist
|
25
|
+
expect(browser.checkbox(xpath: "//input[@id='new_user_interests_books']")).to exist
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns true if the checkbox button exists (search by name and value)" do
|
29
|
+
expect(browser.checkbox(name: "new_user_interests", value: 'cars')).to exist
|
30
|
+
browser.checkbox(xpath: "//input[@name='new_user_interests' and @value='cars']").set
|
31
|
+
end
|
32
|
+
|
33
|
+
it "returns the first checkbox if given no args" do
|
34
|
+
expect(browser.checkbox).to exist
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns false if the checkbox button does not exist" do
|
38
|
+
expect(browser.checkbox(id: "no_such_id")).to_not exist
|
39
|
+
expect(browser.checkbox(id: /no_such_id/)).to_not exist
|
40
|
+
expect(browser.checkbox(name: "no_such_name")).to_not exist
|
41
|
+
expect(browser.checkbox(name: /no_such_name/)).to_not exist
|
42
|
+
expect(browser.checkbox(value: "no_such_value")).to_not exist
|
43
|
+
expect(browser.checkbox(value: /no_such_value/)).to_not exist
|
44
|
+
expect(browser.checkbox(text: "no_such_text")).to_not exist
|
45
|
+
expect(browser.checkbox(text: /no_such_text/)).to_not exist
|
46
|
+
expect(browser.checkbox(class: "no_such_class")).to_not exist
|
47
|
+
expect(browser.checkbox(class: /no_such_class/)).to_not exist
|
48
|
+
expect(browser.checkbox(index: 1337)).to_not exist
|
49
|
+
expect(browser.checkbox(xpath: "//input[@id='no_such_id']")).to_not exist
|
50
|
+
end
|
51
|
+
|
52
|
+
it "returns false if the checkbox button does not exist (search by name and value)" do
|
53
|
+
expect(browser.checkbox(name: "new_user_interests", value: 'no_such_value')).to_not exist
|
54
|
+
expect(browser.checkbox(xpath: "//input[@name='new_user_interests' and @value='no_such_value']")).to_not exist
|
55
|
+
expect(browser.checkbox(name: "no_such_name", value: 'cars')).to_not exist
|
56
|
+
expect(browser.checkbox(xpath: "//input[@name='no_such_name' and @value='cars']")).to_not exist
|
57
|
+
end
|
58
|
+
|
59
|
+
it "returns true for checkboxes with a string value" do
|
60
|
+
expect(browser.checkbox(name: 'new_user_interests', value: 'books')).to exist
|
61
|
+
expect(browser.checkbox(name: 'new_user_interests', value: 'cars')).to exist
|
62
|
+
end
|
63
|
+
|
64
|
+
it "returns true for checkbox with upper case type" do
|
65
|
+
expect(browser.checkbox(id: "new_user_interests_draw")).to exist
|
66
|
+
end
|
67
|
+
|
68
|
+
it "raises TypeError when 'what' argument is invalid" do
|
69
|
+
expect { browser.checkbox(id: 3.14).exists? }.to raise_error(TypeError)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
73
|
+
expect { browser.checkbox(no_such_how: 'some_value').exists? }.to raise_error(Watir::Exception::MissingWayOfFindingObjectException)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Attribute methods
|
78
|
+
|
79
|
+
describe "#class_name" do
|
80
|
+
it "returns the class name if the checkbox exists and has an attribute" do
|
81
|
+
expect(browser.checkbox(id: "new_user_interests_dancing").class_name).to eq "fun"
|
82
|
+
end
|
83
|
+
|
84
|
+
it "returns an empty string if the checkbox exists and the attribute doesn't" do
|
85
|
+
expect(browser.checkbox(id: "new_user_interests_books").class_name).to eq ""
|
86
|
+
end
|
87
|
+
|
88
|
+
it "raises UnknownObjectException if the checkbox doesn't exist" do
|
89
|
+
expect { browser.checkbox(id: "no_such_id").class_name }.to raise_unknown_object_exception
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "#id" do
|
94
|
+
it "returns the id attribute if the checkbox exists and has an attribute" do
|
95
|
+
expect(browser.checkbox(index: 0).id).to eq "new_user_interests_books"
|
96
|
+
end
|
97
|
+
|
98
|
+
it "returns an empty string if the checkbox exists and the attribute doesn't" do
|
99
|
+
expect(browser.checkbox(index: 1).id).to eq ""
|
100
|
+
end
|
101
|
+
|
102
|
+
it "raises UnknownObjectException if the checkbox doesn't exist" do
|
103
|
+
expect { browser.checkbox(index: 1337).id }.to raise_unknown_object_exception
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "#name" do
|
108
|
+
it "returns the name attribute if the checkbox exists" do
|
109
|
+
expect(browser.checkbox(id: 'new_user_interests_books').name).to eq "new_user_interests"
|
110
|
+
end
|
111
|
+
|
112
|
+
it "returns an empty string if the checkbox exists and the attribute doesn't" do
|
113
|
+
expect(browser.checkbox(id: 'new_user_interests_food').name).to eq ""
|
114
|
+
end
|
115
|
+
|
116
|
+
it "raises UnknownObjectException if the checkbox doesn't exist" do
|
117
|
+
expect { browser.checkbox(index: 1337).name }.to raise_unknown_object_exception
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe "#title" do
|
122
|
+
it "returns the title attribute if the checkbox exists" do
|
123
|
+
expect(browser.checkbox(id: "new_user_interests_dancing").title).to eq "Dancing is fun!"
|
124
|
+
end
|
125
|
+
|
126
|
+
it "returns an empty string if the checkbox exists and the attribute doesn't" do
|
127
|
+
expect(browser.checkbox(id: "new_user_interests_books").title).to eq ""
|
128
|
+
end
|
129
|
+
|
130
|
+
it "raises UnknownObjectException if the checkbox doesn't exist" do
|
131
|
+
expect { browser.checkbox(index: 1337).title }.to raise_unknown_object_exception
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe "#type" do
|
136
|
+
it "returns the type attribute if the checkbox exists" do
|
137
|
+
expect(browser.checkbox(index: 0).type).to eq "checkbox"
|
138
|
+
end
|
139
|
+
|
140
|
+
it "raises UnknownObjectException if the checkbox doesn't exist" do
|
141
|
+
expect { browser.checkbox(index: 1337).type }.to raise_unknown_object_exception
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
describe "#value" do
|
146
|
+
it "returns the value attribute if the checkbox exists" do
|
147
|
+
expect(browser.checkbox(id: 'new_user_interests_books').value).to eq 'books'
|
148
|
+
end
|
149
|
+
|
150
|
+
it "raises UnknownObjectException if the checkbox doesn't exist" do
|
151
|
+
expect { browser.checkbox(index: 1337).value}.to raise_unknown_object_exception
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
describe "#respond_to?" do
|
156
|
+
it "returns true for all attribute methods" do
|
157
|
+
expect(browser.checkbox(index: 0)).to respond_to(:class_name)
|
158
|
+
expect(browser.checkbox(index: 0)).to respond_to(:id)
|
159
|
+
expect(browser.checkbox(index: 0)).to respond_to(:name)
|
160
|
+
expect(browser.checkbox(index: 0)).to respond_to(:title)
|
161
|
+
expect(browser.checkbox(index: 0)).to respond_to(:type)
|
162
|
+
expect(browser.checkbox(index: 0)).to respond_to(:value)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
# Access methods
|
167
|
+
|
168
|
+
describe "#enabled?" do
|
169
|
+
it "returns true if the checkbox button is enabled" do
|
170
|
+
expect(browser.checkbox(id: "new_user_interests_books")).to be_enabled
|
171
|
+
expect(browser.checkbox(xpath: "//input[@id='new_user_interests_books']")).to be_enabled
|
172
|
+
end
|
173
|
+
|
174
|
+
it "returns false if the checkbox button is disabled" do
|
175
|
+
expect(browser.checkbox(id: "new_user_interests_dentistry")).to_not be_enabled
|
176
|
+
expect(browser.checkbox(:xpath,"//input[@id='new_user_interests_dentistry']")).to_not be_enabled
|
177
|
+
end
|
178
|
+
|
179
|
+
it "raises UnknownObjectException if the checkbox button doesn't exist" do
|
180
|
+
expect { browser.checkbox(id: "no_such_id").enabled? }.to raise_unknown_object_exception
|
181
|
+
expect { browser.checkbox(xpath: "//input[@id='no_such_id']").enabled? }.to raise_unknown_object_exception
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
describe "#disabled?" do
|
186
|
+
it "returns true if the checkbox is disabled" do
|
187
|
+
expect(browser.checkbox(id: 'new_user_interests_dentistry')).to be_disabled
|
188
|
+
end
|
189
|
+
|
190
|
+
it "returns false if the checkbox is enabled" do
|
191
|
+
expect(browser.checkbox(id: 'new_user_interests_books')).to_not be_disabled
|
192
|
+
end
|
193
|
+
|
194
|
+
it "raises UnknownObjectException if the checkbox doesn't exist" do
|
195
|
+
expect { browser.checkbox(index: 1337).disabled? }.to raise_unknown_object_exception
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
# Manipulation methods
|
200
|
+
|
201
|
+
describe "#clear" do
|
202
|
+
it "raises ObjectDisabledException if the checkbox is disabled" do
|
203
|
+
expect(browser.checkbox(id: "new_user_interests_dentistry")).to_not be_set
|
204
|
+
expect { browser.checkbox(id: "new_user_interests_dentistry").clear }.to raise_object_disabled_exception
|
205
|
+
expect { browser.checkbox(xpath: "//input[@id='new_user_interests_dentistry']").clear }.to raise_object_disabled_exception
|
206
|
+
end
|
207
|
+
|
208
|
+
it "clears the checkbox button if it is set" do
|
209
|
+
browser.checkbox(id: "new_user_interests_books").clear
|
210
|
+
expect(browser.checkbox(id: "new_user_interests_books")).to_not be_set
|
211
|
+
end
|
212
|
+
|
213
|
+
it "clears the checkbox button when found by :xpath" do
|
214
|
+
browser.checkbox(xpath: "//input[@id='new_user_interests_books']").clear
|
215
|
+
expect(browser.checkbox(xpath: "//input[@id='new_user_interests_books']")).to_not be_set
|
216
|
+
end
|
217
|
+
|
218
|
+
it "raises UnknownObjectException if the checkbox button doesn't exist" do
|
219
|
+
expect { browser.checkbox(name: "no_such_id").clear }.to raise_unknown_object_exception
|
220
|
+
expect { browser.checkbox(xpath: "//input[@id='no_such_id']").clear }.to raise_unknown_object_exception
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
describe "#set" do
|
225
|
+
it "sets the checkbox button" do
|
226
|
+
browser.checkbox(id: "new_user_interests_cars").set
|
227
|
+
expect(browser.checkbox(id: "new_user_interests_cars")).to be_set
|
228
|
+
end
|
229
|
+
|
230
|
+
it "sets the checkbox button when found by :xpath" do
|
231
|
+
browser.checkbox(xpath: "//input[@id='new_user_interests_cars']").set
|
232
|
+
expect(browser.checkbox(xpath: "//input[@id='new_user_interests_cars']")).to be_set
|
233
|
+
end
|
234
|
+
|
235
|
+
it "fires the onclick event" do
|
236
|
+
expect(browser.button(id: "disabled_button")).to be_disabled
|
237
|
+
browser.checkbox(id: "toggle_button_checkbox").set
|
238
|
+
expect(browser.button(id: "disabled_button")).to_not be_disabled
|
239
|
+
browser.checkbox(id: "toggle_button_checkbox").clear
|
240
|
+
expect(browser.button(id: "disabled_button")).to be_disabled
|
241
|
+
end
|
242
|
+
|
243
|
+
it "raises UnknownObjectException if the checkbox button doesn't exist" do
|
244
|
+
expect { browser.checkbox(name: "no_such_name").set }.to raise_unknown_object_exception
|
245
|
+
expect { browser.checkbox(xpath: "//input[@name='no_such_name']").set }.to raise_unknown_object_exception
|
246
|
+
end
|
247
|
+
|
248
|
+
it "raises ObjectDisabledException if the checkbox is disabled" do
|
249
|
+
expect { browser.checkbox(id: "new_user_interests_dentistry").set }.to raise_object_disabled_exception
|
250
|
+
expect { browser.checkbox(xpath: "//input[@id='new_user_interests_dentistry']").set }.to raise_object_disabled_exception
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
# Other
|
255
|
+
|
256
|
+
describe '#set?' do
|
257
|
+
it "returns true if the checkbox button is set" do
|
258
|
+
expect(browser.checkbox(id: "new_user_interests_books")).to be_set
|
259
|
+
end
|
260
|
+
|
261
|
+
it "returns false if the checkbox button unset" do
|
262
|
+
expect(browser.checkbox(id: "new_user_interests_cars")).to_not be_set
|
263
|
+
end
|
264
|
+
|
265
|
+
it "returns the state for checkboxes with string values" do
|
266
|
+
expect(browser.checkbox(name: "new_user_interests", value: 'cars')).to_not be_set
|
267
|
+
browser.checkbox(name: "new_user_interests", value: 'cars').set
|
268
|
+
expect(browser.checkbox(name: "new_user_interests", value: 'cars')).to be_set
|
269
|
+
browser.checkbox(name: "new_user_interests", value: 'cars').clear
|
270
|
+
expect(browser.checkbox(name: "new_user_interests", value: 'cars')).to_not be_set
|
271
|
+
end
|
272
|
+
|
273
|
+
it "raises UnknownObjectException if the checkbox button doesn't exist" do
|
274
|
+
expect { browser.checkbox(id: "no_such_id").set? }.to raise_unknown_object_exception
|
275
|
+
expect { browser.checkbox(xpath: "//input[@id='no_such_id']").set? }.to raise_unknown_object_exception
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "watirspec_helper"
|
2
|
+
|
3
|
+
describe "CheckBoxes" do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
browser.goto(WatirSpec.url_for("forms_with_input_elements.html"))
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "with selectors" do
|
10
|
+
it "returns the matching elements" do
|
11
|
+
expect(browser.checkboxes(value: "books").to_a).to eq [browser.checkbox(value: "books")]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#length" do
|
16
|
+
it "returns the number of checkboxes" do
|
17
|
+
expect(browser.checkboxes.length).to eq 8
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#[]" do
|
22
|
+
it "returns the checkbox at the given index" do
|
23
|
+
expect(browser.checkboxes[0].id).to eq "new_user_interests_books"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#each" do
|
28
|
+
it "iterates through checkboxes correctly" do
|
29
|
+
count = 0
|
30
|
+
|
31
|
+
browser.checkboxes.each_with_index do |c, index|
|
32
|
+
expect(c).to be_instance_of(Watir::CheckBox)
|
33
|
+
expect(c.name).to eq browser.checkbox(index: index).name
|
34
|
+
expect(c.id).to eq browser.checkbox(index: index).id
|
35
|
+
expect(c.value).to eq browser.checkbox(index: index).value
|
36
|
+
|
37
|
+
count += 1
|
38
|
+
end
|
39
|
+
|
40
|
+
expect(count).to be > 0
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "watirspec_helper"
|
2
|
+
|
3
|
+
describe "Collections" do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
browser.goto(WatirSpec.url_for("collections.html"))
|
7
|
+
end
|
8
|
+
|
9
|
+
it "returns inner elements of parent element having different html tag" do
|
10
|
+
expect(browser.span(id: "a_span").divs.size).to eq 2
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns inner elements of parent element having same html tag" do
|
14
|
+
expect(browser.span(id: "a_span").spans.size).to eq 2
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require "watirspec_helper"
|
2
|
+
|
3
|
+
describe "Dd" do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
browser.goto(WatirSpec.url_for("definition_lists.html"))
|
7
|
+
end
|
8
|
+
|
9
|
+
# Exists method
|
10
|
+
describe "#exists?" do
|
11
|
+
it "returns true if the element exists" do
|
12
|
+
expect(browser.dd(id: "someone")).to exist
|
13
|
+
expect(browser.dd(class: "name")).to exist
|
14
|
+
expect(browser.dd(xpath: "//dd[@id='someone']")).to exist
|
15
|
+
expect(browser.dd(index: 0)).to exist
|
16
|
+
end
|
17
|
+
|
18
|
+
it "returns the first dd if given no args" do
|
19
|
+
expect(browser.dd).to exist
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns false if the element does not exist" do
|
23
|
+
expect(browser.dd(id: "no_such_id")).to_not exist
|
24
|
+
end
|
25
|
+
|
26
|
+
it "raises TypeError when 'what' argument is invalid" do
|
27
|
+
expect { browser.dd(id: 3.14).exists? }.to raise_error(TypeError)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
31
|
+
expect { browser.dd(no_such_how: 'some_value').exists? }.to raise_error(Watir::Exception::MissingWayOfFindingObjectException)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Attribute methods
|
36
|
+
describe "#class_name" do
|
37
|
+
it "returns the class attribute if the element exists" do
|
38
|
+
expect(browser.dd(id: "someone").class_name).to eq "name"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "returns an empty string if the element exists but the attribute doesn't" do
|
42
|
+
expect(browser.dd(id: "city").class_name).to eq ""
|
43
|
+
end
|
44
|
+
|
45
|
+
it "raises UnknownObjectException if the element does not exist" do
|
46
|
+
expect { browser.dd(id: "no_such_id").class_name }.to raise_unknown_object_exception
|
47
|
+
expect { browser.dd(title: "no_such_title").class_name }.to raise_unknown_object_exception
|
48
|
+
expect { browser.dd(index: 1337).class_name }.to raise_unknown_object_exception
|
49
|
+
expect { browser.dd(xpath: "//dd[@id='no_such_id']").class_name }.to raise_unknown_object_exception
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "#id" do
|
54
|
+
it "returns the id attribute if the element exists" do
|
55
|
+
expect(browser.dd(class: 'name').id).to eq "someone"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "returns an empty string if the element exists, but the attribute doesn't" do
|
59
|
+
expect(browser.dd(class: 'address').id).to eq ""
|
60
|
+
end
|
61
|
+
|
62
|
+
it "raises UnknownObjectException if the element does not exist" do
|
63
|
+
expect {browser.dd(id: "no_such_id").id }.to raise_unknown_object_exception
|
64
|
+
expect {browser.dd(title: "no_such_id").id }.to raise_unknown_object_exception
|
65
|
+
expect {browser.dd(index: 1337).id }.to raise_unknown_object_exception
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "#title" do
|
70
|
+
it "returns the title of the element" do
|
71
|
+
expect(browser.dd(class: "name").title).to eq "someone"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "#text" do
|
76
|
+
it "returns the text of the element" do
|
77
|
+
expect(browser.dd(id: "someone").text).to eq "John Doe"
|
78
|
+
end
|
79
|
+
|
80
|
+
it "returns an empty string if the element exists but contains no text" do
|
81
|
+
expect(browser.dd(class: 'noop').text).to eq ""
|
82
|
+
end
|
83
|
+
|
84
|
+
it "raises UnknownObjectException if the element does not exist" do
|
85
|
+
expect { browser.dd(id: "no_such_id").text }.to raise_unknown_object_exception
|
86
|
+
expect { browser.dd(title: "no_such_title").text }.to raise_unknown_object_exception
|
87
|
+
expect { browser.dd(index: 1337).text }.to raise_unknown_object_exception
|
88
|
+
expect { browser.dd(xpath: "//dd[@id='no_such_id']").text }.to raise_unknown_object_exception
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "#respond_to?" do
|
93
|
+
it "returns true for all attribute methods" do
|
94
|
+
expect(browser.dd(index: 0)).to respond_to(:id)
|
95
|
+
expect(browser.dd(index: 0)).to respond_to(:class_name)
|
96
|
+
expect(browser.dd(index: 0)).to respond_to(:style)
|
97
|
+
expect(browser.dd(index: 0)).to respond_to(:text)
|
98
|
+
expect(browser.dd(index: 0)).to respond_to(:title)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# Manipulation methods
|
103
|
+
describe "#click" do
|
104
|
+
it "fires events when clicked" do
|
105
|
+
expect(browser.dd(title: 'education').text).to_not eq 'changed'
|
106
|
+
browser.dd(title: 'education').click
|
107
|
+
expect(browser.dd(title: 'education').text).to eq 'changed'
|
108
|
+
end
|
109
|
+
|
110
|
+
it "raises UnknownObjectException if the element does not exist" do
|
111
|
+
expect { browser.dd(id: "no_such_id").click }.to raise_unknown_object_exception
|
112
|
+
expect { browser.dd(title: "no_such_title").click }.to raise_unknown_object_exception
|
113
|
+
expect { browser.dd(index: 1337).click }.to raise_unknown_object_exception
|
114
|
+
expect { browser.dd(xpath: "//dd[@id='no_such_id']").click }.to raise_unknown_object_exception
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "#html" do
|
119
|
+
it "returns the HTML of the element" do
|
120
|
+
html = browser.dd(id: 'someone').html
|
121
|
+
expect(html).to match(/John Doe/m)
|
122
|
+
expect(html).to_not include('</body>')
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|