caius-celerity 0.0.6.10 → 0.0.6.11
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +335 -0
- data/benchmark/bm_2000_spans.rb +48 -0
- data/benchmark/bm_digg.rb +26 -0
- data/benchmark/bm_google_images.rb +36 -0
- data/benchmark/bm_input_locator.rb +69 -0
- data/benchmark/bm_text_input.rb +19 -0
- data/benchmark/loader.rb +14 -0
- data/celerity.gemspec +33 -0
- data/config/hoe.rb +78 -0
- data/config/requirements.rb +9 -0
- data/lib/celerity/version.rb +1 -1
- data/spec/area_spec.rb +97 -0
- data/spec/areas_spec.rb +40 -0
- data/spec/browser_authentication_spec.rb +20 -0
- data/spec/browser_spec.rb +537 -0
- data/spec/button_spec.rb +244 -0
- data/spec/buttons_spec.rb +51 -0
- data/spec/checkbox_spec.rb +302 -0
- data/spec/checkboxes_spec.rb +38 -0
- data/spec/clickable_element_spec.rb +43 -0
- data/spec/dd_spec.rb +143 -0
- data/spec/dds_spec.rb +39 -0
- data/spec/default_viewer_spec.rb +24 -0
- data/spec/div_spec.rb +235 -0
- data/spec/divs_spec.rb +39 -0
- data/spec/dl_spec.rb +143 -0
- data/spec/dls_spec.rb +39 -0
- data/spec/dt_spec.rb +143 -0
- data/spec/dts_spec.rb +39 -0
- data/spec/element_spec.rb +150 -0
- data/spec/em_spec.rb +116 -0
- data/spec/ems_spec.rb +39 -0
- data/spec/filefield_spec.rb +133 -0
- data/spec/filefields_spec.rb +40 -0
- data/spec/form_spec.rb +59 -0
- data/spec/forms_spec.rb +41 -0
- data/spec/frame_spec.rb +139 -0
- data/spec/frames_spec.rb +71 -0
- data/spec/hidden_spec.rb +127 -0
- data/spec/hiddens_spec.rb +39 -0
- data/spec/hn_spec.rb +104 -0
- data/spec/hns_spec.rb +45 -0
- data/spec/html/2000_spans.html +2009 -0
- data/spec/html/bug_duplicate_attributes.html +14 -0
- data/spec/html/bug_javascript_001.html +11 -0
- data/spec/html/definition_lists.html +48 -0
- data/spec/html/euc-jp_text.html +17 -0
- data/spec/html/forms_with_input_elements.html +124 -0
- data/spec/html/frame_1.html +18 -0
- data/spec/html/frame_2.html +16 -0
- data/spec/html/frames.html +11 -0
- data/spec/html/iframes.html +12 -0
- data/spec/html/images.html +27 -0
- data/spec/html/images/1.gif +0 -0
- data/spec/html/images/2.gif +0 -0
- data/spec/html/images/3.gif +0 -0
- data/spec/html/images/button.jpg +0 -0
- data/spec/html/images/circle.jpg +0 -0
- data/spec/html/images/map.gif +0 -0
- data/spec/html/images/map2.gif +0 -0
- data/spec/html/images/minus.gif +0 -0
- data/spec/html/images/originaltriangle.jpg +0 -0
- data/spec/html/images/plus.gif +0 -0
- data/spec/html/images/square.jpg +0 -0
- data/spec/html/images/triangle.jpg +0 -0
- data/spec/html/iso-2022-jp_text.html +17 -0
- data/spec/html/jquery.html +29 -0
- data/spec/html/latin1_text.html +17 -0
- data/spec/html/multiple_ids.html +14 -0
- data/spec/html/non_control_elements.html +115 -0
- data/spec/html/right_click.html +16 -0
- data/spec/html/shift_jis_text.html +17 -0
- data/spec/html/tables.html +119 -0
- data/spec/html/timeout.html +16 -0
- data/spec/html/tiny_mce.html +29 -0
- data/spec/html/utf8_text.html +15 -0
- data/spec/htmlunit_spec.rb +47 -0
- data/spec/image_spec.rb +221 -0
- data/spec/images_spec.rb +39 -0
- data/spec/index_offset_spec.rb +26 -0
- data/spec/label_spec.rb +88 -0
- data/spec/labels_spec.rb +40 -0
- data/spec/li_spec.rb +139 -0
- data/spec/link_spec.rb +200 -0
- data/spec/links_spec.rb +47 -0
- data/spec/lis_spec.rb +40 -0
- data/spec/listener_spec.rb +142 -0
- data/spec/map_spec.rb +102 -0
- data/spec/maps_spec.rb +40 -0
- data/spec/meta_spec.rb +29 -0
- data/spec/metas_spec.rb +38 -0
- data/spec/ol_spec.rb +87 -0
- data/spec/ols_spec.rb +40 -0
- data/spec/option_spec.rb +156 -0
- data/spec/p_spec.rb +171 -0
- data/spec/pre_spec.rb +135 -0
- data/spec/pres_spec.rb +40 -0
- data/spec/ps_spec.rb +40 -0
- data/spec/radio_spec.rb +314 -0
- data/spec/radios_spec.rb +42 -0
- data/spec/select_list_spec.rb +320 -0
- data/spec/select_lists_spec.rb +47 -0
- data/spec/span_spec.rb +184 -0
- data/spec/spans_spec.rb +64 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +66 -0
- data/spec/strong_spec.rb +101 -0
- data/spec/strongs_spec.rb +40 -0
- data/spec/table_bodies_spec.rb +57 -0
- data/spec/table_body_spec.rb +109 -0
- data/spec/table_cell_spec.rb +84 -0
- data/spec/table_cells_spec.rb +59 -0
- data/spec/table_footer_spec.rb +96 -0
- data/spec/table_footers_spec.rb +55 -0
- data/spec/table_header_spec.rb +101 -0
- data/spec/table_headers_spec.rb +55 -0
- data/spec/table_row_spec.rb +106 -0
- data/spec/table_rows_spec.rb +58 -0
- data/spec/table_spec.rb +169 -0
- data/spec/tables_spec.rb +42 -0
- data/spec/text_field_spec.rb +331 -0
- data/spec/text_fields_spec.rb +44 -0
- data/spec/ul_spec.rb +88 -0
- data/spec/uls_spec.rb +40 -0
- data/spec/watir_compatibility_spec.rb +268 -0
- data/support/spec_server.rb +122 -0
- data/tasks/benchmark.rake +4 -0
- data/tasks/deployment.rake +43 -0
- data/tasks/environment.rake +7 -0
- data/tasks/fix.rake +25 -0
- data/tasks/rspec.rake +31 -0
- data/tasks/simple_ci.rake +94 -0
- data/tasks/snapshot.rake +22 -0
- data/tasks/specserver.rake +21 -0
- data/tasks/website.rake +17 -0
- data/tasks/yard.rake +9 -0
- data/website/benchmarks.html +237 -0
- data/website/css/color.css +153 -0
- data/website/css/hacks.css +3 -0
- data/website/css/layout.css +179 -0
- data/website/css/screen.css +5 -0
- data/website/css/textmate.css +226 -0
- data/website/css/typography.css +72 -0
- data/website/gfx/body_bg.gif +0 -0
- data/website/gfx/button_bg.jpg +0 -0
- data/website/gfx/header_bg.jpg +0 -0
- data/website/gfx/header_left.jpg +0 -0
- data/website/gfx/header_right.jpg +0 -0
- data/website/gfx/nav_bg.jpg +0 -0
- data/website/index.html +133 -0
- data/website/yard/Celerity.html +50 -0
- data/website/yard/Celerity/Area.html +212 -0
- data/website/yard/Celerity/Areas.html +103 -0
- data/website/yard/Celerity/Browser.html +5594 -0
- data/website/yard/Celerity/Button.html +312 -0
- data/website/yard/Celerity/Buttons.html +103 -0
- data/website/yard/Celerity/CheckBox.html +347 -0
- data/website/yard/Celerity/CheckBoxes.html +103 -0
- data/website/yard/Celerity/ClickableElement.html +448 -0
- data/website/yard/Celerity/Container.html +7676 -0
- data/website/yard/Celerity/Dd.html +198 -0
- data/website/yard/Celerity/Dds.html +103 -0
- data/website/yard/Celerity/DefaultViewer.html +101 -0
- data/website/yard/Celerity/DisabledElement.html +252 -0
- data/website/yard/Celerity/Div.html +198 -0
- data/website/yard/Celerity/Divs.html +103 -0
- data/website/yard/Celerity/Dl.html +198 -0
- data/website/yard/Celerity/Dls.html +103 -0
- data/website/yard/Celerity/Dt.html +198 -0
- data/website/yard/Celerity/Dts.html +103 -0
- data/website/yard/Celerity/Element.html +1703 -0
- data/website/yard/Celerity/ElementCollection.html +725 -0
- data/website/yard/Celerity/ElementLocator.html +589 -0
- data/website/yard/Celerity/Em.html +198 -0
- data/website/yard/Celerity/Ems.html +103 -0
- data/website/yard/Celerity/Exception.html +23 -0
- data/website/yard/Celerity/Exception/CelerityException.html +32 -0
- data/website/yard/Celerity/Exception/MissingWayOfFindingObjectException.html +32 -0
- data/website/yard/Celerity/Exception/NavigationException.html +33 -0
- data/website/yard/Celerity/Exception/NoValueFoundException.html +33 -0
- data/website/yard/Celerity/Exception/ObjectDisabledException.html +33 -0
- data/website/yard/Celerity/Exception/ObjectReadOnlyException.html +33 -0
- data/website/yard/Celerity/Exception/UnexpectedPageException.html +33 -0
- data/website/yard/Celerity/Exception/UnknownCellException.html +33 -0
- data/website/yard/Celerity/Exception/UnknownFormException.html +33 -0
- data/website/yard/Celerity/Exception/UnknownFrameException.html +33 -0
- data/website/yard/Celerity/Exception/UnknownObjectException.html +33 -0
- data/website/yard/Celerity/Exception/UnknownRowException.html +33 -0
- data/website/yard/Celerity/FileField.html +289 -0
- data/website/yard/Celerity/FileFields.html +103 -0
- data/website/yard/Celerity/Form.html +284 -0
- data/website/yard/Celerity/Forms.html +103 -0
- data/website/yard/Celerity/Frame.html +527 -0
- data/website/yard/Celerity/Frames.html +103 -0
- data/website/yard/Celerity/H1.html +198 -0
- data/website/yard/Celerity/H1s.html +103 -0
- data/website/yard/Celerity/H2.html +198 -0
- data/website/yard/Celerity/H2s.html +103 -0
- data/website/yard/Celerity/H3.html +198 -0
- data/website/yard/Celerity/H3s.html +103 -0
- data/website/yard/Celerity/H4.html +198 -0
- data/website/yard/Celerity/H4s.html +103 -0
- data/website/yard/Celerity/H5.html +198 -0
- data/website/yard/Celerity/H5s.html +103 -0
- data/website/yard/Celerity/H6.html +198 -0
- data/website/yard/Celerity/H6s.html +103 -0
- data/website/yard/Celerity/Hidden.html +285 -0
- data/website/yard/Celerity/Hiddens.html +103 -0
- data/website/yard/Celerity/Image.html +645 -0
- data/website/yard/Celerity/Images.html +103 -0
- data/website/yard/Celerity/InputElement.html +271 -0
- data/website/yard/Celerity/Label.html +210 -0
- data/website/yard/Celerity/Labels.html +103 -0
- data/website/yard/Celerity/Li.html +198 -0
- data/website/yard/Celerity/Link.html +295 -0
- data/website/yard/Celerity/Links.html +103 -0
- data/website/yard/Celerity/Lis.html +103 -0
- data/website/yard/Celerity/Listener.html +821 -0
- data/website/yard/Celerity/Map.html +198 -0
- data/website/yard/Celerity/Maps.html +103 -0
- data/website/yard/Celerity/Meta.html +196 -0
- data/website/yard/Celerity/Metas.html +103 -0
- data/website/yard/Celerity/MethodGenerator.html +195 -0
- data/website/yard/Celerity/NonControlElement.html +212 -0
- data/website/yard/Celerity/Ol.html +198 -0
- data/website/yard/Celerity/Ols.html +103 -0
- data/website/yard/Celerity/Option.html +348 -0
- data/website/yard/Celerity/Options.html +103 -0
- data/website/yard/Celerity/P.html +198 -0
- data/website/yard/Celerity/Pre.html +198 -0
- data/website/yard/Celerity/Pres.html +103 -0
- data/website/yard/Celerity/Ps.html +103 -0
- data/website/yard/Celerity/Radio.html +339 -0
- data/website/yard/Celerity/RadioCheckCommon.html +453 -0
- data/website/yard/Celerity/Radios.html +103 -0
- data/website/yard/Celerity/SelectList.html +1122 -0
- data/website/yard/Celerity/SelectLists.html +103 -0
- data/website/yard/Celerity/ShortInspect.html +108 -0
- data/website/yard/Celerity/Span.html +198 -0
- data/website/yard/Celerity/Spans.html +103 -0
- data/website/yard/Celerity/Strong.html +198 -0
- data/website/yard/Celerity/Strongs.html +103 -0
- data/website/yard/Celerity/Table.html +1287 -0
- data/website/yard/Celerity/TableBodies.html +103 -0
- data/website/yard/Celerity/TableBody.html +203 -0
- data/website/yard/Celerity/TableCell.html +279 -0
- data/website/yard/Celerity/TableCells.html +103 -0
- data/website/yard/Celerity/TableElement.html +437 -0
- data/website/yard/Celerity/TableFooter.html +203 -0
- data/website/yard/Celerity/TableFooters.html +103 -0
- data/website/yard/Celerity/TableHeader.html +203 -0
- data/website/yard/Celerity/TableHeaders.html +103 -0
- data/website/yard/Celerity/TableRow.html +478 -0
- data/website/yard/Celerity/TableRows.html +103 -0
- data/website/yard/Celerity/Tables.html +103 -0
- data/website/yard/Celerity/TextField.html +938 -0
- data/website/yard/Celerity/TextFields.html +103 -0
- data/website/yard/Celerity/Th.html +208 -0
- data/website/yard/Celerity/Ul.html +209 -0
- data/website/yard/Celerity/Uls.html +103 -0
- data/website/yard/Celerity/Util.html +264 -0
- data/website/yard/Celerity/VERSION.html +44 -0
- data/website/yard/HtmlUnit.html +23 -0
- data/website/yard/HtmlUnit/Html.html +23 -0
- data/website/yard/HtmlUnit/Util.html +23 -0
- data/website/yard/Java/ComGargoylesoftwareHtmlunitHtml/HtmlPage.html +90 -0
- data/website/yard/Java/JavaLang/Iterable.html +103 -0
- data/website/yard/Java/OrgW3cDom/NamedNodeMap.html +97 -0
- data/website/yard/README.txt.html +116 -0
- data/website/yard/String.html +103 -0
- data/website/yard/all-files.html +22 -0
- data/website/yard/all-methods.html +3276 -0
- data/website/yard/all-namespaces.html +258 -0
- data/website/yard/app.js +18 -0
- data/website/yard/index.html +19 -0
- data/website/yard/jquery.js +11 -0
- data/website/yard/style.css +68 -0
- data/website/yard/syntax_highlight.css +21 -0
- metadata +285 -13
data/spec/pres_spec.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Pres" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@browser = Browser.new(BROWSER_OPTIONS)
|
7
|
+
end
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
@browser.goto(HTML_DIR + "/non_control_elements.html")
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#length" do
|
14
|
+
it "returns the number of pres" do
|
15
|
+
@browser.pres.length.should == 7
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#[]" do
|
20
|
+
it "returns the pre at the given index" do
|
21
|
+
@browser.pres[2].id.should == "rspec"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#each" do
|
26
|
+
it "iterates through pres correctly" do
|
27
|
+
@browser.pres.each_with_index do |p, index|
|
28
|
+
p.name.should == @browser.pre(:index, index+1).name
|
29
|
+
p.id.should == @browser.pre(:index, index+1).id
|
30
|
+
p.value.should == @browser.pre(:index, index+1).value
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
after :all do
|
36
|
+
@browser.close
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
data/spec/ps_spec.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Ps" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@browser = Browser.new(BROWSER_OPTIONS)
|
7
|
+
end
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
@browser.goto(HTML_DIR + "/non_control_elements.html")
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#length" do
|
14
|
+
it "returns the number of ps" do
|
15
|
+
@browser.ps.length.should == 5
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#[]" do
|
20
|
+
it "returns the p at the given index" do
|
21
|
+
@browser.ps[1].id.should == "lead"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#each" do
|
26
|
+
it "iterates through ps correctly" do
|
27
|
+
@browser.ps.each_with_index do |p, index|
|
28
|
+
p.name.should == @browser.p(:index, index+1).name
|
29
|
+
p.id.should == @browser.p(:index, index+1).id
|
30
|
+
p.value.should == @browser.p(:index, index+1).value
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
after :all do
|
36
|
+
@browser.close
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
data/spec/radio_spec.rb
ADDED
@@ -0,0 +1,314 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Radio" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@browser = Browser.new(BROWSER_OPTIONS)
|
7
|
+
end
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
@browser.goto(HTML_DIR + "/forms_with_input_elements.html")
|
11
|
+
end
|
12
|
+
|
13
|
+
# Exists method
|
14
|
+
describe "#exists?" do
|
15
|
+
it "returns true if the radio button exists" do
|
16
|
+
@browser.radio(:id, "new_user_newsletter_yes").should exist
|
17
|
+
@browser.radio(:id, /new_user_newsletter_yes/).should exist
|
18
|
+
@browser.radio(:name, "new_user_newsletter").should exist
|
19
|
+
@browser.radio(:name, /new_user_newsletter/).should exist
|
20
|
+
@browser.radio(:value, "yes").should exist
|
21
|
+
@browser.radio(:value, /yes/).should exist
|
22
|
+
# TODO: figure out what :text means for a radio button
|
23
|
+
# @browser.radio(:text, "yes").should exist
|
24
|
+
# @browser.radio(:text, /yes/).should exist
|
25
|
+
@browser.radio(:class, "huge").should exist
|
26
|
+
@browser.radio(:class, /huge/).should exist
|
27
|
+
@browser.radio(:index, 1).should exist
|
28
|
+
@browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").should exist
|
29
|
+
end
|
30
|
+
|
31
|
+
it "returns true if the element exists (default how = :name)" do
|
32
|
+
@browser.radio("new_user_newsletter").should exist
|
33
|
+
end
|
34
|
+
|
35
|
+
it "returns true if the radio button exists (search by name and value)" do
|
36
|
+
@browser.radio(:name, "new_user_newsletter", 'yes').should exist
|
37
|
+
@browser.radio(:xpath, "//input[@name='new_user_newsletter' and @value='yes']").set
|
38
|
+
end
|
39
|
+
|
40
|
+
it "returns false if the radio button does not exist" do
|
41
|
+
@browser.radio(:id, "no_such_id").should_not exist
|
42
|
+
@browser.radio(:id, /no_such_id/).should_not exist
|
43
|
+
@browser.radio(:name, "no_such_name").should_not exist
|
44
|
+
@browser.radio(:name, /no_such_name/).should_not exist
|
45
|
+
@browser.radio(:value, "no_such_value").should_not exist
|
46
|
+
@browser.radio(:value, /no_such_value/).should_not exist
|
47
|
+
@browser.radio(:text, "no_such_text").should_not exist
|
48
|
+
@browser.radio(:text, /no_such_text/).should_not exist
|
49
|
+
@browser.radio(:class, "no_such_class").should_not exist
|
50
|
+
@browser.radio(:class, /no_such_class/).should_not exist
|
51
|
+
@browser.radio(:index, 1337).should_not exist
|
52
|
+
@browser.radio(:xpath, "input[@id='no_such_id']").should_not exist
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns false if the radio button does not exist (search by name and value)" do
|
56
|
+
@browser.radio(:name, "new_user_newsletter", 'no_such_value').should_not exist
|
57
|
+
@browser.radio(:xpath, "//input[@name='new_user_newsletter' and @value='no_such_value']").should_not exist
|
58
|
+
@browser.radio(:name, "no_such_name", 'yes').should_not exist
|
59
|
+
@browser.radio(:xpath, "//input[@name='no_such_name' and @value='yes']").should_not exist
|
60
|
+
end
|
61
|
+
|
62
|
+
it "returns true for radios with a string value" do
|
63
|
+
@browser.radio(:name, 'new_user_newsletter', 'yes').should exist
|
64
|
+
@browser.radio(:name, 'new_user_newsletter', 'no').should exist
|
65
|
+
end
|
66
|
+
|
67
|
+
it "raises TypeError when 'what' argument is invalid" do
|
68
|
+
lambda { @browser.radio(:id, 3.14).exists? }.should raise_error(TypeError)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
72
|
+
lambda { @browser.radio(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
# Attribute methods
|
78
|
+
describe "#class_name" do
|
79
|
+
it "returns the class name if the radio exists and has an attribute" do
|
80
|
+
@browser.radio(:id, "new_user_newsletter_yes").class_name.should == "huge"
|
81
|
+
end
|
82
|
+
|
83
|
+
it "returns an emptry string if the radio exists and the attribute doesn't" do
|
84
|
+
@browser.radio(:id, "new_user_newsletter_no").class_name.should == ""
|
85
|
+
end
|
86
|
+
|
87
|
+
it "raises UnknownObjectException if the radio doesn't exist" do
|
88
|
+
lambda { @browser.radio(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "#id" do
|
93
|
+
it "returns the id attribute if the radio exists and has an attribute" do
|
94
|
+
@browser.radio(:index, 1).id.should == "new_user_newsletter_yes"
|
95
|
+
end
|
96
|
+
|
97
|
+
it "returns an emptry string if the radio exists and the attribute doesn't" do
|
98
|
+
@browser.radio(:index, 3).id.should == ""
|
99
|
+
end
|
100
|
+
|
101
|
+
it "raises UnknownObjectException if the radio doesn't exist" do
|
102
|
+
lambda { @browser.radio(:index, 1337).id }.should raise_error(UnknownObjectException)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "#name" do
|
107
|
+
it "returns the name attribute if the radio exists" do
|
108
|
+
@browser.radio(:id, 'new_user_newsletter_yes').name.should == "new_user_newsletter"
|
109
|
+
end
|
110
|
+
|
111
|
+
it "returns an empty string if the radio exists and the attribute doesn't" do
|
112
|
+
@browser.radio(:id, 'new_user_newsletter_absolutely').name.should == ""
|
113
|
+
end
|
114
|
+
|
115
|
+
it "raises UnknownObjectException if the radio doesn't exist" do
|
116
|
+
lambda { @browser.radio(:index, 1337).name }.should raise_error(UnknownObjectException)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "#title" do
|
121
|
+
it "returns the title attribute if the radio exists" do
|
122
|
+
@browser.radio(:id, "new_user_newsletter_no").title.should == "Traitor!"
|
123
|
+
end
|
124
|
+
|
125
|
+
it "returns an emptry string if the radio exists and the attribute doesn't" do
|
126
|
+
@browser.radio(:id, "new_user_newsletter_yes").title.should == ""
|
127
|
+
end
|
128
|
+
|
129
|
+
it "raises UnknownObjectException if the radio doesn't exist" do
|
130
|
+
lambda { @browser.radio(:index, 1337).title }.should raise_error(UnknownObjectException)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe "#type" do
|
135
|
+
it "returns the type attribute if the radio exists" do
|
136
|
+
@browser.radio(:index, 1).type.should == "radio"
|
137
|
+
end
|
138
|
+
|
139
|
+
it "raises UnknownObjectException if the radio doesn't exist" do
|
140
|
+
lambda { @browser.radio(:index, 1337).type }.should raise_error(UnknownObjectException)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe "#value" do
|
145
|
+
it "returns the value attribute if the radio exists" do
|
146
|
+
@browser.radio(:id, 'new_user_newsletter_yes').value.should == 'yes'
|
147
|
+
end
|
148
|
+
|
149
|
+
it "raises UnknownObjectException if the radio doesn't exist" do
|
150
|
+
lambda { @browser.radio(:index, 1337).value}.should raise_error(UnknownObjectException)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe "#respond_to?" do
|
155
|
+
it "returns true for all attribute methods" do
|
156
|
+
@browser.radio(:index, 1).should respond_to(:class_name)
|
157
|
+
@browser.radio(:index, 1).should respond_to(:id)
|
158
|
+
@browser.radio(:index, 1).should respond_to(:name)
|
159
|
+
@browser.radio(:index, 1).should respond_to(:title)
|
160
|
+
@browser.radio(:index, 1).should respond_to(:type)
|
161
|
+
@browser.radio(:index, 1).should respond_to(:value)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
# Access methods
|
168
|
+
describe "#enabled?" do
|
169
|
+
it "returns true if the radio button is enabled" do
|
170
|
+
@browser.radio(:id, "new_user_newsletter_yes").should be_enabled
|
171
|
+
@browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").should be_enabled
|
172
|
+
end
|
173
|
+
|
174
|
+
it "returns false if the radio button is disabled" do
|
175
|
+
@browser.radio(:id, "new_user_newsletter_nah").should_not be_enabled
|
176
|
+
@browser.radio(:xpath,"//input[@id='new_user_newsletter_nah']").should_not be_enabled
|
177
|
+
end
|
178
|
+
|
179
|
+
it "raises UnknownObjectException if the radio button doesn't exist" do
|
180
|
+
lambda { @browser.radio(:id, "no_such_id").enabled? }.should raise_error(UnknownObjectException)
|
181
|
+
lambda { @browser.radio(:xpath, "//input[@id='no_such_id']").enabled? }.should raise_error(UnknownObjectException)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
describe "#disabled?" do
|
186
|
+
it "returns true if the radio is disabled" do
|
187
|
+
@browser.radio(:id, 'new_user_newsletter_nah').should be_disabled
|
188
|
+
end
|
189
|
+
|
190
|
+
it "returns false if the radio is enabled" do
|
191
|
+
@browser.radio(:id, 'new_user_newsletter_yes').should_not be_disabled
|
192
|
+
end
|
193
|
+
|
194
|
+
it "raises UnknownObjectException if the radio doesn't exist" do
|
195
|
+
lambda { @browser.radio(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
|
200
|
+
# Manipulation methods
|
201
|
+
describe "#clear" do
|
202
|
+
it "clears the radio button if it is set" do
|
203
|
+
@browser.radio(:id, "new_user_newsletter_yes").clear
|
204
|
+
@browser.radio(:id, "new_user_newsletter_yes").should_not be_set
|
205
|
+
end
|
206
|
+
|
207
|
+
it "clears the radio button when found by :xpath" do
|
208
|
+
@browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").clear
|
209
|
+
@browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").should_not be_set
|
210
|
+
end
|
211
|
+
|
212
|
+
it "raises UnknownObjectException if the radio button doesn't exist" do
|
213
|
+
lambda { @browser.radio(:name, "no_such_id").clear }.should raise_error(UnknownObjectException)
|
214
|
+
lambda { @browser.radio(:xpath, "//input[@id='no_such_id']").clear }.should raise_error(UnknownObjectException)
|
215
|
+
end
|
216
|
+
|
217
|
+
it "raises ObjectDisabledException if the radio is disabled" do
|
218
|
+
@browser.radio(:id, "new_user_newsletter_nah").should_not be_set
|
219
|
+
lambda { @browser.radio(:id, "new_user_newsletter_nah").clear }.should raise_error(ObjectDisabledException)
|
220
|
+
lambda { @browser.radio(:xpath, "//input[@id='new_user_newsletter_nah']").clear }.should raise_error(ObjectDisabledException)
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
describe "#set" do
|
225
|
+
it "sets the radio button" do
|
226
|
+
@browser.radio(:id, "new_user_newsletter_no").set
|
227
|
+
@browser.radio(:id, "new_user_newsletter_no").should be_set
|
228
|
+
end
|
229
|
+
|
230
|
+
it "sets the radio button when found by :xpath" do
|
231
|
+
@browser.radio(:xpath, "//input[@id='new_user_newsletter_no']").set
|
232
|
+
@browser.radio(:xpath, "//input[@id='new_user_newsletter_no']").should be_set
|
233
|
+
end
|
234
|
+
|
235
|
+
it "fires the onclick event" do
|
236
|
+
alerts = []
|
237
|
+
@browser.add_listener(:alert) { |_, msg| alerts << msg }
|
238
|
+
|
239
|
+
@browser.radio(:id, "new_user_newsletter_no").set
|
240
|
+
@browser.radio(:id, "new_user_newsletter_yes").set
|
241
|
+
alerts.should == ["clicked: new_user_newsletter_no", "clicked: new_user_newsletter_yes"]
|
242
|
+
end
|
243
|
+
|
244
|
+
it "fires the onchange event" do
|
245
|
+
alerts = []
|
246
|
+
@browser.add_listener(:alert) { |_, msg| alerts << msg }
|
247
|
+
|
248
|
+
@browser.radio(:value, 'certainly').set
|
249
|
+
alerts.should == ["changed: new_user_newsletter"]
|
250
|
+
|
251
|
+
@browser.radio(:value, 'certainly').set
|
252
|
+
alerts.should == ["changed: new_user_newsletter"] # no event fired here - didn't change
|
253
|
+
|
254
|
+
@browser.radio(:value, 'certainly').clear
|
255
|
+
alerts.should == ["changed: new_user_newsletter", "changed: new_user_newsletter"]
|
256
|
+
end
|
257
|
+
|
258
|
+
it "raises UnknownObjectException if the radio button doesn't exist" do
|
259
|
+
lambda { @browser.radio(:name, "no_such_name").set }.should raise_error(UnknownObjectException)
|
260
|
+
lambda { @browser.radio(:xpath, "//input[@name='no_such_name']").set }.should raise_error(UnknownObjectException)
|
261
|
+
end
|
262
|
+
|
263
|
+
it "raises ObjectDisabledException if the radio is disabled" do
|
264
|
+
lambda { @browser.radio(:id, "new_user_newsletter_nah").set }.should raise_error(ObjectDisabledException)
|
265
|
+
lambda { @browser.radio(:xpath, "//input[@id='new_user_newsletter_nah']").set }.should raise_error(ObjectDisabledException )
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
|
270
|
+
# Other
|
271
|
+
describe '#set?' do
|
272
|
+
it "returns true if the radio button is set" do
|
273
|
+
@browser.radio(:id, "new_user_newsletter_yes").should be_set
|
274
|
+
end
|
275
|
+
|
276
|
+
it "returns false if the radio button unset" do
|
277
|
+
@browser.radio(:id, "new_user_newsletter_no").should_not be_set
|
278
|
+
end
|
279
|
+
|
280
|
+
it "returns the state for radios with string values" do
|
281
|
+
@browser.radio(:name, "new_user_newsletter", 'no').should_not be_set
|
282
|
+
@browser.radio(:name, "new_user_newsletter", 'no').set
|
283
|
+
@browser.radio(:name, "new_user_newsletter", 'no').should be_set
|
284
|
+
@browser.radio(:name, "new_user_newsletter", 'no').clear
|
285
|
+
@browser.radio(:name, "new_user_newsletter", 'no').should_not be_set
|
286
|
+
end
|
287
|
+
|
288
|
+
it "raises UnknownObjectException if the radio button doesn't exist" do
|
289
|
+
lambda { @browser.radio(:id, "no_such_id").set? }.should raise_error(UnknownObjectException)
|
290
|
+
lambda { @browser.radio(:xpath, "//input[@id='no_such_id']").set? }.should raise_error(UnknownObjectException)
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
describe "#get_state" do
|
295
|
+
it "returns true if the radio is set" do
|
296
|
+
@browser.radio(:id, "new_user_newsletter_yes").get_state.should be_true
|
297
|
+
end
|
298
|
+
|
299
|
+
it "returns false if the radio is unset" do
|
300
|
+
@browser.radio(:id, "new_user_newsletter_no").get_state.should be_false
|
301
|
+
end
|
302
|
+
|
303
|
+
it "raises UnknownObjectException if the radio doesn't exist" do
|
304
|
+
lambda { @browser.radio(:name, "no_such_name").get_state }.should raise_error(UnknownObjectException)
|
305
|
+
lambda { @browser.radio(:xpath, "//input[@name='no_such_name']").get_state }.should raise_error(UnknownObjectException)
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
after :all do
|
310
|
+
@browser.close
|
311
|
+
end
|
312
|
+
|
313
|
+
end
|
314
|
+
|
data/spec/radios_spec.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Radios" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@browser = Browser.new(BROWSER_OPTIONS)
|
7
|
+
end
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
@browser.goto(HTML_DIR + "/forms_with_input_elements.html")
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#length" do
|
14
|
+
it "returns the number of radios" do
|
15
|
+
@browser.radios.length.should == 5
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#[]" do
|
20
|
+
it "returns the radio button at the given index" do
|
21
|
+
@browser.radios[1].id.should == "new_user_newsletter_yes"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#each" do
|
26
|
+
it "iterates through radio buttons correctly" do
|
27
|
+
index = 1
|
28
|
+
@browser.radios.each do |r|
|
29
|
+
r.name.should == @browser.radio(:index, index).name
|
30
|
+
r.id.should == @browser.radio(:index, index).id
|
31
|
+
r.value.should == @browser.radio(:index, index).value
|
32
|
+
index += 1
|
33
|
+
end
|
34
|
+
@browser.radios.length.should == index - 1
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
after :all do
|
39
|
+
@browser.close
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,320 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "SelectList" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@browser = Browser.new(BROWSER_OPTIONS)
|
7
|
+
end
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
@browser.goto(HTML_DIR + "/forms_with_input_elements.html")
|
11
|
+
end
|
12
|
+
|
13
|
+
# Exists method
|
14
|
+
describe "#exists?" do
|
15
|
+
it "returns true if the select list exists" do
|
16
|
+
@browser.select_list(:id, 'new_user_country').should exist
|
17
|
+
@browser.select_list(:id, /new_user_country/).should exist
|
18
|
+
@browser.select_list(:name, 'new_user_country').should exist
|
19
|
+
@browser.select_list(:name, /new_user_country/).should exist
|
20
|
+
# TODO: check behaviour in Watir
|
21
|
+
# @browser.select_list(:value, 'Norway').should exist
|
22
|
+
# @browser.select_list(:value, /Norway/).should exist
|
23
|
+
@browser.select_list(:text, 'Norway').should exist
|
24
|
+
@browser.select_list(:text, /Norway/).should exist
|
25
|
+
@browser.select_list(:class, 'country').should exist
|
26
|
+
@browser.select_list(:class, /country/).should exist
|
27
|
+
@browser.select_list(:index, 1).should exist
|
28
|
+
@browser.select_list(:xpath, "//select[@id='new_user_country']").should exist
|
29
|
+
end
|
30
|
+
|
31
|
+
it "returns true if the element exists (default how = :name)" do
|
32
|
+
@browser.select_list("new_user_country").should exist
|
33
|
+
end
|
34
|
+
|
35
|
+
it "returns false if the select list doesn't exist" do
|
36
|
+
@browser.select_list(:id, 'no_such_id').should_not exist
|
37
|
+
@browser.select_list(:id, /no_such_id/).should_not exist
|
38
|
+
@browser.select_list(:name, 'no_such_name').should_not exist
|
39
|
+
@browser.select_list(:name, /no_such_name/).should_not exist
|
40
|
+
@browser.select_list(:value, 'no_such_value').should_not exist
|
41
|
+
@browser.select_list(:value, /no_such_value/).should_not exist
|
42
|
+
@browser.select_list(:text, 'no_such_text').should_not exist
|
43
|
+
@browser.select_list(:text, /no_such_text/).should_not exist
|
44
|
+
@browser.select_list(:class, 'no_such_class').should_not exist
|
45
|
+
@browser.select_list(:class, /no_such_class/).should_not exist
|
46
|
+
@browser.select_list(:index, 1337).should_not exist
|
47
|
+
@browser.select_list(:xpath, "//select[@id='no_such_id']").should_not exist
|
48
|
+
end
|
49
|
+
|
50
|
+
it "raises TypeError when 'what' argument is invalid" do
|
51
|
+
lambda { @browser.select_list(:id, 3.14).exists? }.should raise_error(TypeError)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
55
|
+
lambda { @browser.select_list(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
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
|
+
|
125
|
+
# Access methods
|
126
|
+
describe "#enabled?" do
|
127
|
+
it "returns true if the select list is enabled" do
|
128
|
+
@browser.select_list(:name, 'new_user_country').should be_enabled
|
129
|
+
end
|
130
|
+
|
131
|
+
it "returns false if the select list is disabled" do
|
132
|
+
@browser.select_list(:name, 'new_user_role').should_not be_enabled
|
133
|
+
end
|
134
|
+
|
135
|
+
it "raises UnknownObjectException if the select_list doesn't exist" do
|
136
|
+
lambda { @browser.select_list(:name, 'no_such_name').enabled? }.should raise_error(UnknownObjectException)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe "#disabled?" do
|
141
|
+
it "returns true if the select list is disabled" do
|
142
|
+
@browser.select_list(:index, 3).should be_disabled
|
143
|
+
end
|
144
|
+
|
145
|
+
it "returns false if the select list is enabled" do
|
146
|
+
@browser.select_list(:index, 1).should_not be_disabled
|
147
|
+
end
|
148
|
+
|
149
|
+
it "shoulds raise UnknownObjectException when the select list does not exist" do
|
150
|
+
lambda { @browser.select_list(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
# Other
|
155
|
+
describe "#option" do
|
156
|
+
it "returns an instance of Option" do
|
157
|
+
option = @browser.select_list(:name, "new_user_country").option(:text, "Denmark")
|
158
|
+
option.should be_instance_of(Option)
|
159
|
+
option.value.should == "1"
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe "#options" do
|
164
|
+
it "shoulds raise UnknownObjectException if the select list doesn't exist" do
|
165
|
+
lambda { @browser.select_list(:name, 'no_such_name').options }.should raise_error(UnknownObjectException)
|
166
|
+
end
|
167
|
+
|
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
|
+
|
173
|
+
describe "#selected_options" do
|
174
|
+
it "shoulds raise UnknownObjectException if the select list doesn't exist" do
|
175
|
+
lambda { @browser.select_list(:name, 'no_such_name').selected_options }.should raise_error(UnknownObjectException)
|
176
|
+
end
|
177
|
+
|
178
|
+
it "gets the currently selected item(s)" do
|
179
|
+
@browser.select_list(:name, "new_user_country").selected_options.should == ["Norway"]
|
180
|
+
@browser.select_list(:name, "new_user_languages").selected_options.should == ["English", "Norwegian"]
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
describe "#clear" do
|
185
|
+
it "clears the selection when possible" do
|
186
|
+
@browser.select_list(:name, "new_user_languages").clear
|
187
|
+
@browser.select_list(:name, "new_user_languages").selected_options.should be_empty
|
188
|
+
end
|
189
|
+
|
190
|
+
it "does not clear selections when not possible" do
|
191
|
+
@browser.select_list(:name , "new_user_country").clear
|
192
|
+
@browser.select_list(:name, "new_user_country").selected_options.should == ["Norway"]
|
193
|
+
end
|
194
|
+
|
195
|
+
it "raises UnknownObjectException if the select list doesn't exist" do
|
196
|
+
lambda { @browser.select_list(:name, 'no_such_name').clear_selection }.should raise_error(UnknownObjectException)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
describe "#includes?" do
|
201
|
+
it "returns true if the given option exists" do
|
202
|
+
@browser.select_list(:name, 'new_user_country').includes?('Denmark').should be_true
|
203
|
+
end
|
204
|
+
|
205
|
+
it "returns false if the given option doesn't exist" do
|
206
|
+
@browser.select_list(:name, 'new_user_country').includes?('Ireland').should be_false
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
describe "#selected?" do
|
211
|
+
it "returns true if the given option is selected" do
|
212
|
+
@browser.select_list(:name, 'new_user_country').select('Denmark')
|
213
|
+
@browser.select_list(:name, 'new_user_country').selected?('Denmark').should be_true
|
214
|
+
end
|
215
|
+
|
216
|
+
it "returns false if the given option is not selected" do
|
217
|
+
@browser.select_list(:name, 'new_user_country').selected?('Sweden').should be_false
|
218
|
+
end
|
219
|
+
|
220
|
+
it "raises UnknonwObjectException if the option doesn't exist" do
|
221
|
+
lambda { @browser.select_list(:name, 'new_user_country').selected?('missing_option') }.should raise_error(UnknownObjectException)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
describe "#select" do
|
226
|
+
it "selects the given item when given a String" do
|
227
|
+
@browser.select_list(:name, "new_user_country").select("Denmark")
|
228
|
+
@browser.select_list(:name, "new_user_country").selected_options.should == ["Denmark"]
|
229
|
+
end
|
230
|
+
|
231
|
+
it "selects options by label" do
|
232
|
+
@browser.select_list(:name, "new_user_country").select("Germany")
|
233
|
+
@browser.select_list(:name, "new_user_country").selected_options.should == ["Germany"]
|
234
|
+
end
|
235
|
+
|
236
|
+
it "selects the given item when given a Regexp" do
|
237
|
+
@browser.select_list(:name, "new_user_country").select(/Denmark/)
|
238
|
+
@browser.select_list(:name, "new_user_country").selected_options.should == ["Denmark"]
|
239
|
+
end
|
240
|
+
|
241
|
+
it "selects the given item when given an Xpath" do
|
242
|
+
@browser.select_list(:xpath, "//select[@name='new_user_country']").select("Denmark")
|
243
|
+
@browser.select_list(:xpath, "//select[@name='new_user_country']").selected_options.should == ["Denmark"]
|
244
|
+
end
|
245
|
+
|
246
|
+
it "selects multiple items using :name and a String" do
|
247
|
+
@browser.select_list(:name, "new_user_languages").clear_selection
|
248
|
+
@browser.select_list(:name, "new_user_languages").select("Danish")
|
249
|
+
@browser.select_list(:name, "new_user_languages").select("Swedish")
|
250
|
+
@browser.select_list(:name, "new_user_languages").selected_options.should == ["Danish", "Swedish"]
|
251
|
+
end
|
252
|
+
|
253
|
+
it "selects multiple items using :name and a Regexp" do
|
254
|
+
@browser.select_list(:name, "new_user_languages").clear_selection
|
255
|
+
@browser.select_list(:name, "new_user_languages").select(/ish/)
|
256
|
+
@browser.select_list(:name, "new_user_languages").selected_options.should == ["Danish", "English", "Swedish"]
|
257
|
+
end
|
258
|
+
|
259
|
+
it "selects multiple items using :xpath" do
|
260
|
+
@browser.select_list(:xpath, "//select[@name='new_user_languages']").clear_selection
|
261
|
+
@browser.select_list(:xpath, "//select[@name='new_user_languages']").select(/ish/)
|
262
|
+
@browser.select_list(:xpath, "//select[@name='new_user_languages']").selected_options.should == ["Danish", "English", "Swedish"]
|
263
|
+
end
|
264
|
+
|
265
|
+
it "selects empty options" do
|
266
|
+
@browser.select_list(:id, "delete_user_username").select("")
|
267
|
+
@browser.select_list(:id, "delete_user_username").selected_options.should == [""]
|
268
|
+
end
|
269
|
+
|
270
|
+
it "returns the value selected" do
|
271
|
+
@browser.select_list(:name, "new_user_languages").select("Danish").should == "Danish"
|
272
|
+
end
|
273
|
+
|
274
|
+
it "returns the first matching value if there are multiple matches" do
|
275
|
+
@browser.select_list(:name, "new_user_languages").select(/ish/).should == "Danish"
|
276
|
+
end
|
277
|
+
|
278
|
+
it "fires onchange event when selecting an item" do
|
279
|
+
alerts = []
|
280
|
+
@browser.add_listener(:alert) { |_, msg| alerts << msg }
|
281
|
+
@browser.select_list(:id, "new_user_languages").select("Danish")
|
282
|
+
alerts.should == ['changed language']
|
283
|
+
end
|
284
|
+
|
285
|
+
it "doesn't fire onchange event when selecting an already selected item" do
|
286
|
+
alerts = []
|
287
|
+
@browser.add_listener(:alert) { |_, msg| alerts << msg }
|
288
|
+
|
289
|
+
@browser.select_list(:id, "new_user_languages").clear_selection # removes the two pre-selected options
|
290
|
+
@browser.select_list(:id, "new_user_languages").select("English")
|
291
|
+
alerts.size.should == 3
|
292
|
+
|
293
|
+
@browser.select_list(:id, "new_user_languages").select("English")
|
294
|
+
alerts.size.should == 3
|
295
|
+
end
|
296
|
+
|
297
|
+
it "raises NoValueFoundException if the option doesn't exist" do
|
298
|
+
lambda { @browser.select_list(:name, "new_user_country").select("missing_option") }.should raise_error(NoValueFoundException)
|
299
|
+
lambda { @browser.select_list(:name, "new_user_country").select(/missing_option/) }.should raise_error(NoValueFoundException)
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
describe "#select_value" do
|
304
|
+
it "selects the given item" do
|
305
|
+
@browser.select_list(:name, "new_user_languages").clear_selection
|
306
|
+
@browser.select_list(:name, "new_user_languages").select("Swedish")
|
307
|
+
@browser.select_list(:name, "new_user_languages").selected_options.should == ["Swedish"]
|
308
|
+
end
|
309
|
+
|
310
|
+
it "raises NoValueFoundException if the option doesn't exist" do
|
311
|
+
lambda { @browser.select_list(:name, "new_user_languages").select_value("no_such_option") }.should raise_error(NoValueFoundException)
|
312
|
+
lambda { @browser.select_list(:name, "new_user_languages").select_value(/no_such_option/) }.should raise_error(NoValueFoundException)
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
after :all do
|
317
|
+
@browser.close
|
318
|
+
end
|
319
|
+
|
320
|
+
end
|