operawatir 0.3-jruby
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitmodules +3 -0
- data/.yardopts +5 -0
- data/AUTHORS +7 -0
- data/Gemfile +9 -0
- data/LICENSE +30 -0
- data/README.md +158 -0
- data/Rakefile +59 -0
- data/VERSION +1 -0
- data/bin/desktopwatir +106 -0
- data/bin/operawatir +95 -0
- data/lib/operadriver/APACHE_2.0_LICENSE.txt +204 -0
- data/lib/operadriver/NEW_BSD_LICENSE.txt +36 -0
- data/lib/operadriver/commons-jxpath-1.3.jar +0 -0
- data/lib/operadriver/protobuf-java-2.3.0.jar +0 -0
- data/lib/operadriver/selenium-common.jar +0 -0
- data/lib/operadriver/webdriver-opera.jar +0 -0
- data/lib/operawatir.rb +46 -0
- data/lib/operawatir/browser.rb +181 -0
- data/lib/operawatir/collection.rb +133 -0
- data/lib/operawatir/compat.rb +25 -0
- data/lib/operawatir/compat/browser.rb +20 -0
- data/lib/operawatir/compat/collection.rb +99 -0
- data/lib/operawatir/compat/deprecation.rb +46 -0
- data/lib/operawatir/compat/element.rb +165 -0
- data/lib/operawatir/compat/element_finders.rb +159 -0
- data/lib/operawatir/compat/window.rb +27 -0
- data/lib/operawatir/element.rb +228 -0
- data/lib/operawatir/exceptions.rb +38 -0
- data/lib/operawatir/helper.rb +53 -0
- data/lib/operawatir/selector.rb +111 -0
- data/lib/operawatir/version.rb +15 -0
- data/lib/operawatir/window.rb +174 -0
- data/spec/fire_event/fire_event.rb +268 -0
- data/spec/fire_event/interactive/onBlur.html +45 -0
- data/spec/fire_event/interactive/onChange.html +47 -0
- data/spec/fire_event/interactive/onClick.html +45 -0
- data/spec/fire_event/interactive/onDblClick.html +45 -0
- data/spec/fire_event/interactive/onFocus.html +45 -0
- data/spec/fire_event/interactive/onMouseDown.html +45 -0
- data/spec/fire_event/interactive/onMouseMove.html +45 -0
- data/spec/fire_event/interactive/onMouseOut.html +45 -0
- data/spec/fire_event/interactive/onMouseOver.html +45 -0
- data/spec/fire_event/interactive/onMouseUp.html +45 -0
- data/spec/fire_event/interactive/onScroll.html +14 -0
- data/spec/legacy_watirspec/area_spec.rb +106 -0
- data/spec/legacy_watirspec/areas_spec.rb +38 -0
- data/spec/legacy_watirspec/browser_spec.rb +297 -0
- data/spec/legacy_watirspec/button_spec.rb +260 -0
- data/spec/legacy_watirspec/buttons_spec.rb +54 -0
- data/spec/legacy_watirspec/checkbox_spec.rb +280 -0
- data/spec/legacy_watirspec/checkboxes_spec.rb +38 -0
- data/spec/legacy_watirspec/collections_spec.rb +18 -0
- data/spec/legacy_watirspec/dd_spec.rb +140 -0
- data/spec/legacy_watirspec/dds_spec.rb +38 -0
- data/spec/legacy_watirspec/del_spec.rb +181 -0
- data/spec/legacy_watirspec/dels_spec.rb +62 -0
- data/spec/legacy_watirspec/div_spec.rb +244 -0
- data/spec/legacy_watirspec/divs_spec.rb +38 -0
- data/spec/legacy_watirspec/dl_spec.rb +140 -0
- data/spec/legacy_watirspec/dls_spec.rb +38 -0
- data/spec/legacy_watirspec/dt_spec.rb +140 -0
- data/spec/legacy_watirspec/dts_spec.rb +38 -0
- data/spec/legacy_watirspec/element_spec.rb +86 -0
- data/spec/legacy_watirspec/em_spec.rb +114 -0
- data/spec/legacy_watirspec/ems_spec.rb +38 -0
- data/spec/legacy_watirspec/filefield_spec.rb +127 -0
- data/spec/legacy_watirspec/filefields_spec.rb +38 -0
- data/spec/legacy_watirspec/fixtures/2000_spans.html +2009 -0
- data/spec/legacy_watirspec/fixtures/bug_duplicate_attributes.html +14 -0
- data/spec/legacy_watirspec/fixtures/bug_javascript_001.html +11 -0
- data/spec/legacy_watirspec/fixtures/buttons_with_duplicate_ids.html +18 -0
- data/spec/legacy_watirspec/fixtures/collections.html +15 -0
- data/spec/legacy_watirspec/fixtures/definition_lists.html +48 -0
- data/spec/legacy_watirspec/fixtures/euc-jp_text.html +17 -0
- data/spec/legacy_watirspec/fixtures/forms_with_input_elements.html +126 -0
- data/spec/legacy_watirspec/fixtures/frame_1.html +18 -0
- data/spec/legacy_watirspec/fixtures/frame_2.html +16 -0
- data/spec/legacy_watirspec/fixtures/frames.html +11 -0
- data/spec/legacy_watirspec/fixtures/iframes.html +12 -0
- data/spec/legacy_watirspec/fixtures/images.html +27 -0
- data/spec/legacy_watirspec/fixtures/images/1.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/2.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/3.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/button.jpg +0 -0
- data/spec/legacy_watirspec/fixtures/images/circle.jpg +0 -0
- data/spec/legacy_watirspec/fixtures/images/map.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/map2.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/minus.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/originaltriangle.jpg +0 -0
- data/spec/legacy_watirspec/fixtures/images/plus.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/square.jpg +0 -0
- data/spec/legacy_watirspec/fixtures/images/triangle.jpg +0 -0
- data/spec/legacy_watirspec/fixtures/iso-2022-jp_text.html +17 -0
- data/spec/legacy_watirspec/fixtures/javascript/helpers.js +16 -0
- data/spec/legacy_watirspec/fixtures/jquery.html +28 -0
- data/spec/legacy_watirspec/fixtures/latin1_text.html +17 -0
- data/spec/legacy_watirspec/fixtures/multiple_ids.html +14 -0
- data/spec/legacy_watirspec/fixtures/non_control_elements.html +135 -0
- data/spec/legacy_watirspec/fixtures/parser_bug_001.html +12 -0
- data/spec/legacy_watirspec/fixtures/prevent_form_submit.html +20 -0
- data/spec/legacy_watirspec/fixtures/right_click.html +11 -0
- data/spec/legacy_watirspec/fixtures/shift_jis_text.html +17 -0
- data/spec/legacy_watirspec/fixtures/tables.html +121 -0
- data/spec/legacy_watirspec/fixtures/timeout.html +16 -0
- data/spec/legacy_watirspec/fixtures/timeout_window_location.html +19 -0
- data/spec/legacy_watirspec/fixtures/tiny_mce.html +27 -0
- data/spec/legacy_watirspec/fixtures/utf8_text.html +15 -0
- data/spec/legacy_watirspec/fixtures/watirspec.css +0 -0
- data/spec/legacy_watirspec/form_spec.rb +73 -0
- data/spec/legacy_watirspec/forms_spec.rb +39 -0
- data/spec/legacy_watirspec/frame_spec.rb +161 -0
- data/spec/legacy_watirspec/frames_spec.rb +75 -0
- data/spec/legacy_watirspec/guards.rb +38 -0
- data/spec/legacy_watirspec/hidden_spec.rb +120 -0
- data/spec/legacy_watirspec/hiddens_spec.rb +38 -0
- data/spec/legacy_watirspec/hn_spec.rb +101 -0
- data/spec/legacy_watirspec/hns_spec.rb +39 -0
- data/spec/legacy_watirspec/image_spec.rb +237 -0
- data/spec/legacy_watirspec/images_spec.rb +38 -0
- data/spec/legacy_watirspec/ins_spec.rb +181 -0
- data/spec/legacy_watirspec/inses_spec.rb +62 -0
- data/spec/legacy_watirspec/label_spec.rb +85 -0
- data/spec/legacy_watirspec/labels_spec.rb +38 -0
- data/spec/legacy_watirspec/li_spec.rb +135 -0
- data/spec/legacy_watirspec/link_spec.rb +194 -0
- data/spec/legacy_watirspec/links_spec.rb +39 -0
- data/spec/legacy_watirspec/lis_spec.rb +38 -0
- data/spec/legacy_watirspec/map_spec.rb +100 -0
- data/spec/legacy_watirspec/maps_spec.rb +38 -0
- data/spec/legacy_watirspec/meta_spec.rb +26 -0
- data/spec/legacy_watirspec/metas_spec.rb +36 -0
- data/spec/legacy_watirspec/ol_spec.rb +86 -0
- data/spec/legacy_watirspec/ols_spec.rb +38 -0
- data/spec/legacy_watirspec/option_spec.rb +187 -0
- data/spec/legacy_watirspec/p_spec.rb +167 -0
- data/spec/legacy_watirspec/pre_spec.rb +133 -0
- data/spec/legacy_watirspec/pres_spec.rb +38 -0
- data/spec/legacy_watirspec/ps_spec.rb +38 -0
- data/spec/legacy_watirspec/radio_spec.rb +286 -0
- data/spec/legacy_watirspec/radios_spec.rb +35 -0
- data/spec/legacy_watirspec/select_list_spec.rb +326 -0
- data/spec/legacy_watirspec/select_lists_spec.rb +39 -0
- data/spec/legacy_watirspec/server.rb +91 -0
- data/spec/legacy_watirspec/span_spec.rb +181 -0
- data/spec/legacy_watirspec/spans_spec.rb +64 -0
- data/spec/legacy_watirspec/spec_helper.rb +12 -0
- data/spec/legacy_watirspec/strong_spec.rb +97 -0
- data/spec/legacy_watirspec/strongs_spec.rb +39 -0
- data/spec/legacy_watirspec/table_bodies_spec.rb +61 -0
- data/spec/legacy_watirspec/table_body_spec.rb +119 -0
- data/spec/legacy_watirspec/table_cell_spec.rb +76 -0
- data/spec/legacy_watirspec/table_cells_spec.rb +71 -0
- data/spec/legacy_watirspec/table_footer_spec.rb +94 -0
- data/spec/legacy_watirspec/table_footers_spec.rb +61 -0
- data/spec/legacy_watirspec/table_header_spec.rb +98 -0
- data/spec/legacy_watirspec/table_headers_spec.rb +59 -0
- data/spec/legacy_watirspec/table_row_spec.rb +104 -0
- data/spec/legacy_watirspec/table_rows_spec.rb +64 -0
- data/spec/legacy_watirspec/table_spec.rb +170 -0
- data/spec/legacy_watirspec/tables_spec.rb +40 -0
- data/spec/legacy_watirspec/text_field_spec.rb +315 -0
- data/spec/legacy_watirspec/text_fields_spec.rb +38 -0
- data/spec/legacy_watirspec/ul_spec.rb +84 -0
- data/spec/legacy_watirspec/uls_spec.rb +40 -0
- data/spec/legacy_watirspec/watir_compatibility_spec.rb +176 -0
- data/spec/legacy_watirspec/watirspec_helper.rb +57 -0
- data/utils/Rakefile +79 -0
- data/utils/launchers/launcher-linux-i686 +0 -0
- data/utils/launchers/launcher-linux-x86_64 +0 -0
- data/utils/launchers/launcher-win32-i86pc.exe +0 -0
- metadata +404 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Radios" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#length" do
|
11
|
+
it "returns the number of radios" do
|
12
|
+
browser.radios.length.should == 5
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#[]" do
|
17
|
+
it "returns the radio button at the given index" do
|
18
|
+
browser.radios[1].id.should == "new_user_newsletter_yes"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#each" do
|
23
|
+
it "iterates through radio buttons correctly" do
|
24
|
+
index = 1
|
25
|
+
browser.radios.each do |r|
|
26
|
+
r.name.should == browser.radio(:index, index).name
|
27
|
+
r.id.should == browser.radio(:index, index).id
|
28
|
+
r.value.should == browser.radio(:index, index).value
|
29
|
+
index += 1
|
30
|
+
end
|
31
|
+
browser.radios.length.should == index - 1
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,326 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "SelectList" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
# Exists method
|
11
|
+
describe "#exists?" do
|
12
|
+
it "returns true if the select list exists" do
|
13
|
+
browser.select_list(:id, 'new_user_country').should exist
|
14
|
+
browser.select_list(:id, /new_user_country/).should exist
|
15
|
+
browser.select_list(:name, 'new_user_country').should exist
|
16
|
+
browser.select_list(:name, /new_user_country/).should exist
|
17
|
+
# TODO: check behaviour in Watir
|
18
|
+
# browser.select_list(:value, 'Norway').should exist
|
19
|
+
# browser.select_list(:value, /Norway/).should exist
|
20
|
+
browser.select_list(:text, 'Norway').should exist
|
21
|
+
browser.select_list(:text, /Norway/).should exist
|
22
|
+
browser.select_list(:class, 'country').should exist
|
23
|
+
browser.select_list(:class, /country/).should exist
|
24
|
+
browser.select_list(:index, 1).should exist
|
25
|
+
browser.select_list(:xpath, "//select[@id='new_user_country']").should exist
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns true if the element exists (default how = :name)" do
|
29
|
+
browser.select_list("new_user_country").should exist
|
30
|
+
end
|
31
|
+
|
32
|
+
it "returns the first select if given no args" do
|
33
|
+
browser.select_list.should exist
|
34
|
+
end
|
35
|
+
|
36
|
+
it "returns false if the select list doesn't exist" do
|
37
|
+
browser.select_list(:id, 'no_such_id').should_not exist
|
38
|
+
browser.select_list(:id, /no_such_id/).should_not exist
|
39
|
+
browser.select_list(:name, 'no_such_name').should_not exist
|
40
|
+
browser.select_list(:name, /no_such_name/).should_not exist
|
41
|
+
browser.select_list(:value, 'no_such_value').should_not exist
|
42
|
+
browser.select_list(:value, /no_such_value/).should_not exist
|
43
|
+
browser.select_list(:text, 'no_such_text').should_not exist
|
44
|
+
browser.select_list(:text, /no_such_text/).should_not exist
|
45
|
+
browser.select_list(:class, 'no_such_class').should_not exist
|
46
|
+
browser.select_list(:class, /no_such_class/).should_not exist
|
47
|
+
browser.select_list(:index, 1337).should_not exist
|
48
|
+
browser.select_list(:xpath, "//select[@id='no_such_id']").should_not exist
|
49
|
+
end
|
50
|
+
|
51
|
+
it "raises TypeError when 'what' argument is invalid" do
|
52
|
+
lambda { browser.select_list(:id, 3.14).exists? }.should raise_error(TypeError)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
56
|
+
lambda { browser.select_list(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Attribute methods
|
61
|
+
describe "#class_name" do
|
62
|
+
it "returns the class name of the select list" do
|
63
|
+
browser.select_list(:name, 'new_user_country').class_name.should == 'country'
|
64
|
+
end
|
65
|
+
|
66
|
+
it "raises UnknownObjectException if the select list doesn't exist" do
|
67
|
+
lambda { browser.select_list(:name, 'no_such_name').class_name }.should raise_error(UnknownObjectException)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "#id" do
|
72
|
+
it "returns the id of the element" do
|
73
|
+
browser.select_list(:index, 1).id.should == "new_user_country"
|
74
|
+
end
|
75
|
+
|
76
|
+
it "raises UnknownObjectException if the select list doesn't exist" do
|
77
|
+
lambda { browser.select_list(:index, 1337).id }.should raise_error(UnknownObjectException)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "#name" do
|
82
|
+
it "returns the name of the element" do
|
83
|
+
browser.select_list(:index, 1).name.should == "new_user_country"
|
84
|
+
end
|
85
|
+
|
86
|
+
it "raises UnknownObjectException if the select list doesn't exist" do
|
87
|
+
lambda { browser.select_list(:index, 1337).name }.should raise_error(UnknownObjectException)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "#type" do
|
92
|
+
it "returns the type of the element" do
|
93
|
+
browser.select_list(:index, 1).type.should == "select-one"
|
94
|
+
browser.select_list(:index, 2).type.should == "select-multiple"
|
95
|
+
end
|
96
|
+
|
97
|
+
it "raises UnknownObjectException if the select list doesn't exist" do
|
98
|
+
lambda { browser.select_list(:index, 1337).type }.should raise_error(UnknownObjectException)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "#value" do
|
103
|
+
it "returns the value of the selected option" do
|
104
|
+
browser.select_list(:index, 1).value.should == "2"
|
105
|
+
browser.select_list(:index, 1).select(/Sweden/)
|
106
|
+
browser.select_list(:index, 1).value.should == "3"
|
107
|
+
end
|
108
|
+
|
109
|
+
it "raises UnknownObjectException if the select list doesn't exist" do
|
110
|
+
lambda { browser.select_list(:index, 1337).value }.should raise_error(UnknownObjectException)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "#respond_to?" do
|
115
|
+
it "returns true for all attribute methods" do
|
116
|
+
browser.select_list(:index, 1).should respond_to(:class_name)
|
117
|
+
browser.select_list(:index, 1).should respond_to(:id)
|
118
|
+
browser.select_list(:index, 1).should respond_to(:name)
|
119
|
+
browser.select_list(:index, 1).should respond_to(:type)
|
120
|
+
browser.select_list(:index, 1).should respond_to(:value)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
# Access methods
|
125
|
+
describe "#enabled?" do
|
126
|
+
it "returns true if the select list is enabled" do
|
127
|
+
browser.select_list(:name, 'new_user_country').should be_enabled
|
128
|
+
end
|
129
|
+
|
130
|
+
it "returns false if the select list is disabled" do
|
131
|
+
browser.select_list(:name, 'new_user_role').should_not be_enabled
|
132
|
+
end
|
133
|
+
|
134
|
+
it "raises UnknownObjectException if the select_list doesn't exist" do
|
135
|
+
lambda { browser.select_list(:name, 'no_such_name').enabled? }.should raise_error(UnknownObjectException)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe "#disabled?" do
|
140
|
+
it "returns true if the select list is disabled" do
|
141
|
+
browser.select_list(:index, 3).should be_disabled
|
142
|
+
end
|
143
|
+
|
144
|
+
it "returns false if the select list is enabled" do
|
145
|
+
browser.select_list(:index, 1).should_not be_disabled
|
146
|
+
end
|
147
|
+
|
148
|
+
it "shoulds raise UnknownObjectException when the select list does not exist" do
|
149
|
+
lambda { browser.select_list(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
# Other
|
154
|
+
describe "#option" do
|
155
|
+
it "returns an instance of Option" do
|
156
|
+
option = browser.select_list(:name, "new_user_country").option(:text, "Denmark")
|
157
|
+
option.should be_instance_of(Option)
|
158
|
+
option.value.should == "1"
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
describe "#options" do
|
163
|
+
it "shoulds raise UnknownObjectException if the select list doesn't exist" do
|
164
|
+
lambda { browser.select_list(:name, 'no_such_name').options }.should raise_error(UnknownObjectException)
|
165
|
+
end
|
166
|
+
|
167
|
+
bug "WTR-339", :watir do
|
168
|
+
it "returns all the options as an Array" do
|
169
|
+
browser.select_list(:name, "new_user_country").options.should == ["Denmark" ,"Norway" , "Sweden" , "United Kingdom", "USA", "Germany"]
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
describe "#selected_options" do
|
175
|
+
it "shoulds raise UnknownObjectException if the select list doesn't exist" do
|
176
|
+
lambda { browser.select_list(:name, 'no_such_name').selected_options }.should raise_error(UnknownObjectException)
|
177
|
+
end
|
178
|
+
|
179
|
+
it "gets the currently selected item(s)" do
|
180
|
+
browser.select_list(:name, "new_user_country").selected_options.should == ["Norway"]
|
181
|
+
browser.select_list(:name, "new_user_languages").selected_options.should == ["English", "Norwegian"]
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
describe "#clear" do
|
186
|
+
it "clears the selection when possible" do
|
187
|
+
browser.select_list(:name, "new_user_languages").clear
|
188
|
+
browser.select_list(:name, "new_user_languages").selected_options.should be_empty
|
189
|
+
end
|
190
|
+
|
191
|
+
it "does not clear selections when not possible" do
|
192
|
+
browser.select_list(:name , "new_user_country").clear
|
193
|
+
browser.select_list(:name, "new_user_country").selected_options.should == ["Norway"]
|
194
|
+
end
|
195
|
+
|
196
|
+
it "raises UnknownObjectException if the select list doesn't exist" do
|
197
|
+
lambda { browser.select_list(:name, 'no_such_name').clear }.should raise_error(UnknownObjectException)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
describe "#includes?" do
|
202
|
+
it "returns true if the given option exists" do
|
203
|
+
browser.select_list(:name, 'new_user_country').includes?('Denmark').should be_true
|
204
|
+
end
|
205
|
+
|
206
|
+
it "returns false if the given option doesn't exist" do
|
207
|
+
browser.select_list(:name, 'new_user_country').includes?('Ireland').should be_false
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
describe "#selected?" do
|
212
|
+
it "returns true if the given option is selected" do
|
213
|
+
browser.select_list(:name, 'new_user_country').select('Denmark')
|
214
|
+
browser.select_list(:name, 'new_user_country').selected?('Denmark').should be_true
|
215
|
+
end
|
216
|
+
|
217
|
+
it "returns false if the given option is not selected" do
|
218
|
+
browser.select_list(:name, 'new_user_country').selected?('Sweden').should be_false
|
219
|
+
end
|
220
|
+
|
221
|
+
it "raises UnknonwObjectException if the option doesn't exist" do
|
222
|
+
lambda { browser.select_list(:name, 'new_user_country').selected?('missing_option') }.should raise_error(UnknownObjectException)
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
describe "#select" do
|
227
|
+
it "selects the given item when given a String" do
|
228
|
+
browser.select_list(:name, "new_user_country").select("Denmark")
|
229
|
+
browser.select_list(:name, "new_user_country").selected_options.should == ["Denmark"]
|
230
|
+
end
|
231
|
+
|
232
|
+
it "selects options by label" do
|
233
|
+
browser.select_list(:name, "new_user_country").select("Germany")
|
234
|
+
browser.select_list(:name, "new_user_country").selected_options.should == ["Germany"]
|
235
|
+
end
|
236
|
+
|
237
|
+
it "selects the given item when given a Regexp" do
|
238
|
+
browser.select_list(:name, "new_user_country").select(/Denmark/)
|
239
|
+
browser.select_list(:name, "new_user_country").selected_options.should == ["Denmark"]
|
240
|
+
end
|
241
|
+
|
242
|
+
it "selects the given item when given an Xpath" do
|
243
|
+
browser.select_list(:xpath, "//select[@name='new_user_country']").select("Denmark")
|
244
|
+
browser.select_list(:xpath, "//select[@name='new_user_country']").selected_options.should == ["Denmark"]
|
245
|
+
end
|
246
|
+
|
247
|
+
it "selects multiple items using :name and a String" do
|
248
|
+
browser.select_list(:name, "new_user_languages").clear
|
249
|
+
browser.select_list(:name, "new_user_languages").select("Danish")
|
250
|
+
browser.select_list(:name, "new_user_languages").select("Swedish")
|
251
|
+
browser.select_list(:name, "new_user_languages").selected_options.should == ["Danish", "Swedish"]
|
252
|
+
end
|
253
|
+
|
254
|
+
bug "WTR-362", :watir do
|
255
|
+
it "selects multiple items using :name and a Regexp" do
|
256
|
+
browser.select_list(:name, "new_user_languages").clear
|
257
|
+
browser.select_list(:name, "new_user_languages").select(/ish/)
|
258
|
+
browser.select_list(:name, "new_user_languages").selected_options.should == ["Danish", "English", "Swedish"]
|
259
|
+
end
|
260
|
+
|
261
|
+
it "selects multiple items using :xpath" do
|
262
|
+
browser.select_list(:xpath, "//select[@name='new_user_languages']").clear
|
263
|
+
browser.select_list(:xpath, "//select[@name='new_user_languages']").select(/ish/)
|
264
|
+
browser.select_list(:xpath, "//select[@name='new_user_languages']").selected_options.should == ["Danish", "English", "Swedish"]
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
it "selects empty options" do
|
269
|
+
browser.select_list(:id, "delete_user_username").select("")
|
270
|
+
browser.select_list(:id, "delete_user_username").selected_options.should == [""]
|
271
|
+
end
|
272
|
+
|
273
|
+
bug "WTR-363", :watir do
|
274
|
+
it "returns the value selected" do
|
275
|
+
browser.select_list(:name, "new_user_languages").select("Danish").should == "Danish"
|
276
|
+
end
|
277
|
+
|
278
|
+
it "returns the first matching value if there are multiple matches" do
|
279
|
+
browser.select_list(:name, "new_user_languages").select(/ish/).should == "Danish"
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
it "fires onchange event when selecting an item" do
|
284
|
+
browser.select_list(:id, "new_user_languages").select("Danish")
|
285
|
+
messages.should == ['changed language']
|
286
|
+
end
|
287
|
+
|
288
|
+
bug "WTR-364", :watir do
|
289
|
+
it "doesn't fire onchange event when selecting an already selected item" do
|
290
|
+
browser.select_list(:id, "new_user_languages").clear # removes the two pre-selected options
|
291
|
+
browser.select_list(:id, "new_user_languages").select("English")
|
292
|
+
messages.size.should == 3
|
293
|
+
|
294
|
+
browser.select_list(:id, "new_user_languages").select("English")
|
295
|
+
messages.size.should == 3
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
it "raises NoValueFoundException if the option doesn't exist" do
|
300
|
+
lambda { browser.select_list(:name, "new_user_country").select("missing_option") }.should raise_error(NoValueFoundException)
|
301
|
+
lambda { browser.select_list(:name, "new_user_country").select(/missing_option/) }.should raise_error(NoValueFoundException)
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
describe "#select_value" do
|
306
|
+
it "selects the item by value string" do
|
307
|
+
browser.select_list(:name, "new_user_languages").clear
|
308
|
+
browser.select_list(:name, "new_user_languages").select_value("2")
|
309
|
+
browser.select_list(:name, "new_user_languages").selected_options.should == %w[English]
|
310
|
+
end
|
311
|
+
|
312
|
+
bug "WTR-362", :watir do
|
313
|
+
it "selects the items by value regexp" do
|
314
|
+
browser.select_list(:name, "new_user_languages").clear
|
315
|
+
browser.select_list(:name, "new_user_languages").select_value(/1|3/)
|
316
|
+
browser.select_list(:name, "new_user_languages").selected_options.should == %w[Danish Norwegian]
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
it "raises NoValueFoundException if the option doesn't exist" do
|
321
|
+
lambda { browser.select_list(:name, "new_user_languages").select_value("no_such_option") }.should raise_error(NoValueFoundException)
|
322
|
+
lambda { browser.select_list(:name, "new_user_languages").select_value(/no_such_option/) }.should raise_error(NoValueFoundException)
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "SelectLists" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#length" do
|
11
|
+
it "returns the correct number of select lists on the page" do
|
12
|
+
browser.select_lists.length.should == 4
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#[]" do
|
17
|
+
it "returns the correct item" do
|
18
|
+
browser.select_lists[1].value.should == "2"
|
19
|
+
browser.select_lists[1].name.should == "new_user_country"
|
20
|
+
browser.select_lists[1].type.should == "select-one"
|
21
|
+
browser.select_lists[2].type.should == "select-multiple"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#each" do
|
26
|
+
it "iterates through the select lists correctly" do
|
27
|
+
index=1
|
28
|
+
browser.select_lists.each do |l|
|
29
|
+
browser.select_list(:index, index).name.should == l.name
|
30
|
+
browser.select_list(:index, index).id.should == l.id
|
31
|
+
browser.select_list(:index, index).type.should == l.type
|
32
|
+
browser.select_list(:index, index).value.should == l.value
|
33
|
+
index += 1
|
34
|
+
end
|
35
|
+
(index - 1).should == browser.select_lists.length
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'sinatra/base'
|
3
|
+
|
4
|
+
class WatirSpec::Server < ::Sinatra::Base
|
5
|
+
|
6
|
+
set :app_file, __FILE__
|
7
|
+
set :root, File.dirname(__FILE__)
|
8
|
+
set :public, lambda { File.join(root, 'fixtures')}
|
9
|
+
set :static, true
|
10
|
+
set :run, false
|
11
|
+
set :environment, :production
|
12
|
+
set :bind, 'localhost'
|
13
|
+
set :port, 2000
|
14
|
+
set :server, %w[thin mongrel webrick]
|
15
|
+
|
16
|
+
get '/' do
|
17
|
+
self.class.name
|
18
|
+
end
|
19
|
+
|
20
|
+
get '/big' do
|
21
|
+
Class.new do
|
22
|
+
def each(&blk)
|
23
|
+
yield "<html><head><title>Big Content</title></head><body>"
|
24
|
+
string = "hello "*205
|
25
|
+
300.times { yield string }
|
26
|
+
yield "</body></html>"
|
27
|
+
end
|
28
|
+
end.new
|
29
|
+
end
|
30
|
+
|
31
|
+
post '/post_to_me' do
|
32
|
+
"You posted the following content:\n#{ env['rack.input'].read }"
|
33
|
+
end
|
34
|
+
|
35
|
+
get '/plain_text' do
|
36
|
+
content_type 'text/plain'
|
37
|
+
'This is text/plain'
|
38
|
+
end
|
39
|
+
|
40
|
+
get '/ajax' do
|
41
|
+
sleep 10
|
42
|
+
"A slooow ajax response"
|
43
|
+
end
|
44
|
+
|
45
|
+
get '/charset_mismatch' do
|
46
|
+
content_type 'text/html; charset=UTF-8'
|
47
|
+
%{
|
48
|
+
<html>
|
49
|
+
<head>
|
50
|
+
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" />
|
51
|
+
</head>
|
52
|
+
<body>
|
53
|
+
<h1>ø</h1>
|
54
|
+
</body>
|
55
|
+
</html>
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
get '/octet_stream' do
|
60
|
+
content_type 'application/octet-stream'
|
61
|
+
'This is application/octet-stream'
|
62
|
+
end
|
63
|
+
|
64
|
+
get '/set_cookie' do
|
65
|
+
content_type 'text/plain'
|
66
|
+
headers 'Set-Cookie' => "monster=/"
|
67
|
+
|
68
|
+
"C is for cookie, it's good enough for me"
|
69
|
+
end
|
70
|
+
|
71
|
+
get '/header_echo' do
|
72
|
+
content_type 'text/plain'
|
73
|
+
env.inspect
|
74
|
+
end
|
75
|
+
|
76
|
+
get '/authentication' do
|
77
|
+
auth = Rack::Auth::Basic::Request.new(env)
|
78
|
+
|
79
|
+
unless auth.provided? && auth.credentials == %w[foo bar]
|
80
|
+
headers 'WWW-Authenticate' => %(Basic realm="localhost")
|
81
|
+
halt 401, 'Authorization Required'
|
82
|
+
end
|
83
|
+
|
84
|
+
"ok"
|
85
|
+
end
|
86
|
+
|
87
|
+
get '/encodable_<stuff>' do
|
88
|
+
'page with characters in URI that need encoding'
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|