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,167 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "P" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
# Exists method
|
11
|
+
describe "#exist?" do
|
12
|
+
it "returns true if the 'p' exists" do
|
13
|
+
browser.p(:id, "lead").should exist
|
14
|
+
browser.p(:id, /lead/).should exist
|
15
|
+
browser.p(:text, "Dubito, ergo cogito, ergo sum.").should exist
|
16
|
+
browser.p(:text, /Dubito, ergo cogito, ergo sum/).should exist
|
17
|
+
browser.p(:class, "lead").should exist
|
18
|
+
browser.p(:class, /lead/).should exist
|
19
|
+
browser.p(:index, 1).should exist
|
20
|
+
browser.p(:xpath, "//p[@id='lead']").should exist
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns true if the element exists (default how = :id)" do
|
24
|
+
browser.p("lead").should exist
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns the first p if given no args" do
|
28
|
+
browser.p.should exist
|
29
|
+
end
|
30
|
+
|
31
|
+
it "returns false if the 'p' doesn't exist" do
|
32
|
+
browser.p(:id, "no_such_id").should_not exist
|
33
|
+
browser.p(:id, /no_such_id/).should_not exist
|
34
|
+
browser.p(:text, "no_such_text").should_not exist
|
35
|
+
browser.p(:text, /no_such_text/).should_not exist
|
36
|
+
browser.p(:class, "no_such_class").should_not exist
|
37
|
+
browser.p(:class, /no_such_class/).should_not exist
|
38
|
+
browser.p(:index, 1337).should_not exist
|
39
|
+
browser.p(:xpath, "//p[@id='no_such_id']").should_not exist
|
40
|
+
end
|
41
|
+
|
42
|
+
it "raises TypeError when 'what' argument is invalid" do
|
43
|
+
lambda { browser.p(:id, 3.14).exists? }.should raise_error(TypeError)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
47
|
+
lambda { browser.p(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Attribute methods
|
52
|
+
describe "#class_name" do
|
53
|
+
it "returns the class attribute" do
|
54
|
+
browser.p(:index, 1).class_name.should == 'lead'
|
55
|
+
end
|
56
|
+
|
57
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
58
|
+
browser.p(:index, 3).class_name.should == ''
|
59
|
+
end
|
60
|
+
|
61
|
+
it "raises UnknownObjectException if the p doesn't exist" do
|
62
|
+
lambda { browser.p(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#id" do
|
67
|
+
it "returns the id attribute" do
|
68
|
+
browser.p(:index, 1).id.should == "lead"
|
69
|
+
end
|
70
|
+
|
71
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
72
|
+
browser.p(:index, 3).id.should == ''
|
73
|
+
end
|
74
|
+
|
75
|
+
it "raises UnknownObjectException if the p doesn't exist" do
|
76
|
+
lambda { browser.p(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
77
|
+
lambda { browser.p(:index, 1337).id }.should raise_error(UnknownObjectException)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "#name" do
|
82
|
+
it "returns the name attribute" do
|
83
|
+
browser.p(:index, 2).name.should == "invalid_attribute"
|
84
|
+
end
|
85
|
+
|
86
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
87
|
+
browser.p(:index, 3).name.should == ''
|
88
|
+
end
|
89
|
+
|
90
|
+
it "raises UnknownObjectException if the p doesn't exist" do
|
91
|
+
lambda { browser.p(:id, "no_such_id").name }.should raise_error(UnknownObjectException)
|
92
|
+
lambda { browser.p(:index, 1337).name }.should raise_error(UnknownObjectException)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "#title" do
|
97
|
+
it "returns the title attribute" do
|
98
|
+
browser.p(:index, 1).title.should == 'Lorem ipsum'
|
99
|
+
end
|
100
|
+
|
101
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
102
|
+
browser.p(:index, 3).title.should == ''
|
103
|
+
end
|
104
|
+
|
105
|
+
it "raises UnknownObjectException if the p doesn't exist" do
|
106
|
+
lambda { browser.p(:id, 'no_such_id').title }.should raise_error( UnknownObjectException)
|
107
|
+
lambda { browser.p(:xpath, "//p[@id='no_such_id']").title }.should raise_error( UnknownObjectException)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "#text" do
|
112
|
+
it "returns the text of the p" do
|
113
|
+
browser.p(:index, 2).text.should == 'Sed pretium metus et quam. Nullam odio dolor, vestibulum non, tempor ut, vehicula sed, sapien. Vestibulum placerat ligula at quam. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.'
|
114
|
+
end
|
115
|
+
|
116
|
+
it "returns an empty string if the element doesn't contain any text" do
|
117
|
+
browser.p(:index, 5).text.should == ''
|
118
|
+
end
|
119
|
+
|
120
|
+
it "raises UnknownObjectException if the p doesn't exist" do
|
121
|
+
lambda { browser.p(:id, 'no_such_id').text }.should raise_error( UnknownObjectException)
|
122
|
+
lambda { browser.p(:xpath , "//p[@id='no_such_id']").text }.should raise_error( UnknownObjectException)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe "#value" do
|
127
|
+
it "returns the value attribute" do
|
128
|
+
browser.p(:index, 2).value.should == "invalid_attribute"
|
129
|
+
end
|
130
|
+
|
131
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
132
|
+
browser.p(:index, 3).value.should == ''
|
133
|
+
end
|
134
|
+
|
135
|
+
it "raises UnknownObjectException if the p doesn't exist" do
|
136
|
+
lambda { browser.p(:id , "no_such_id").value }.should raise_error(UnknownObjectException)
|
137
|
+
lambda { browser.p(:index , 1337).value }.should raise_error(UnknownObjectException)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
describe "#respond_to?" do
|
142
|
+
it "returns true for all attribute methods" do
|
143
|
+
browser.p(:index, 1).should respond_to(:class_name)
|
144
|
+
browser.p(:index, 1).should respond_to(:id)
|
145
|
+
browser.p(:index, 1).should respond_to(:name)
|
146
|
+
browser.p(:index, 1).should respond_to(:title)
|
147
|
+
browser.p(:index, 1).should respond_to(:text)
|
148
|
+
browser.p(:index, 1).should respond_to(:value)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
# Other
|
153
|
+
describe "#to_s" do
|
154
|
+
it "returns a human readable representation of the element" do
|
155
|
+
browser.p(:index, 1).to_s.should == "tag: p\n" +
|
156
|
+
" id: lead\n" +
|
157
|
+
" class: lead\n" +
|
158
|
+
" title: Lorem ipsum\n" +
|
159
|
+
" text: Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur eu pede. Ut justo. Praesent feugiat, elit in feugiat iaculis, sem risus rutrum justo, eget fermentum dolor arcu non nunc."
|
160
|
+
end
|
161
|
+
|
162
|
+
it "raises UnknownObjectException if the p doesn't exist" do
|
163
|
+
lambda { browser.p(:xpath, "//p[@id='no_such_id']").to_s }.should raise_error( UnknownObjectException)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Pre" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
# Exists method
|
11
|
+
describe "#exist?" do
|
12
|
+
it "returns true if the 'p' exists" do
|
13
|
+
browser.pre(:id, "rspec").should exist
|
14
|
+
browser.pre(:id, /rspec/).should exist
|
15
|
+
browser.pre(:text, 'browser.pre(:id, "rspec").should exist').should exist
|
16
|
+
browser.pre(:text, /browser\.pre/).should exist
|
17
|
+
browser.pre(:class, "ruby").should exist
|
18
|
+
browser.pre(:class, /ruby/).should exist
|
19
|
+
browser.pre(:index, 1).should exist
|
20
|
+
browser.pre(:xpath, "//pre[@id='rspec']").should exist
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns true if the element exists (default how = :id)" do
|
24
|
+
browser.pre("rspec").should exist
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns the first pre if given no args" do
|
28
|
+
browser.pre.should exist
|
29
|
+
end
|
30
|
+
|
31
|
+
it "returns false if the 'p' doesn't exist" do
|
32
|
+
browser.pre(:id, "no_such_id").should_not exist
|
33
|
+
browser.pre(:id, /no_such_id/).should_not exist
|
34
|
+
browser.pre(:text, "no_such_text").should_not exist
|
35
|
+
browser.pre(:text, /no_such_text/).should_not exist
|
36
|
+
browser.pre(:class, "no_such_class").should_not exist
|
37
|
+
browser.pre(:class, /no_such_class/).should_not exist
|
38
|
+
browser.pre(:index, 1337).should_not exist
|
39
|
+
browser.pre(:xpath, "//pre[@id='no_such_id']").should_not exist
|
40
|
+
end
|
41
|
+
|
42
|
+
it "raises TypeError when 'what' argument is invalid" do
|
43
|
+
lambda { browser.pre(:id, 3.14).exists? }.should raise_error(TypeError)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
47
|
+
lambda { browser.pre(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Attribute methods
|
52
|
+
describe "#class_name" do
|
53
|
+
it "returns the class attribute" do
|
54
|
+
browser.pre(:id, 'rspec').class_name.should == 'ruby'
|
55
|
+
end
|
56
|
+
|
57
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
58
|
+
browser.pre(:index, 1).class_name.should == ''
|
59
|
+
end
|
60
|
+
|
61
|
+
it "raises UnknownObjectException if the p doesn't exist" do
|
62
|
+
lambda { browser.pre(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#id" do
|
67
|
+
it "returns the id attribute" do
|
68
|
+
browser.pre(:class, 'ruby').id.should == "rspec"
|
69
|
+
end
|
70
|
+
|
71
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
72
|
+
browser.pre(:index, 1).id.should == ''
|
73
|
+
end
|
74
|
+
|
75
|
+
it "raises UnknownObjectException if the p doesn't exist" do
|
76
|
+
lambda { browser.pre(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
77
|
+
lambda { browser.pre(:index, 1337).id }.should raise_error(UnknownObjectException)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "#title" do
|
82
|
+
it "returns the title attribute" do
|
83
|
+
browser.pre(:class, 'brainfuck').title.should == 'The brainfuck language is an esoteric programming language noted for its extreme minimalism'
|
84
|
+
end
|
85
|
+
|
86
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
87
|
+
browser.pre(:index, 1).title.should == ''
|
88
|
+
end
|
89
|
+
|
90
|
+
it "raises UnknownObjectException if the p doesn't exist" do
|
91
|
+
lambda { browser.pre(:id, 'no_such_id').title }.should raise_error( UnknownObjectException)
|
92
|
+
lambda { browser.pre(:xpath, "//pre[@id='no_such_id']").title }.should raise_error( UnknownObjectException)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "#text" do
|
97
|
+
it "returns the text of the p" do
|
98
|
+
browser.pre(:class, 'haskell').text.should == 'main = putStrLn "Hello World"'
|
99
|
+
end
|
100
|
+
|
101
|
+
it "returns an empty string if the element doesn't contain any text" do
|
102
|
+
browser.pre(:index, 1).text.should == ''
|
103
|
+
end
|
104
|
+
|
105
|
+
it "raises UnknownObjectException if the p doesn't exist" do
|
106
|
+
lambda { browser.pre(:id, 'no_such_id').text }.should raise_error( UnknownObjectException)
|
107
|
+
lambda { browser.pre(:xpath , "//pre[@id='no_such_id']").text }.should raise_error( UnknownObjectException)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "#respond_to?" do
|
112
|
+
it "returns true for all attribute methods" do
|
113
|
+
browser.image(:index, 1).should respond_to(:class_name)
|
114
|
+
browser.image(:index, 1).should respond_to(:id)
|
115
|
+
browser.image(:index, 1).should respond_to(:title)
|
116
|
+
browser.image(:index, 1).should respond_to(:text)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
# Other
|
121
|
+
describe "#to_s" do
|
122
|
+
bug "WTR-350", :watir do
|
123
|
+
it "returns a human readable representation of the element" do
|
124
|
+
browser.pre(:index, 1).to_s.should == "tag: pre"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
it "raises UnknownObjectException if the p doesn't exist" do
|
129
|
+
lambda { browser.pre(:xpath, "//pre[@id='no_such_id']").to_s }.should raise_error( UnknownObjectException)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Pres" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#length" do
|
11
|
+
it "returns the number of pres" do
|
12
|
+
browser.pres.length.should == 7
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#[]" do
|
17
|
+
it "returns the pre at the given index" do
|
18
|
+
browser.pres[2].id.should == "rspec"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#each" do
|
23
|
+
it "iterates through pres correctly" do
|
24
|
+
count = 0
|
25
|
+
|
26
|
+
browser.pres.each_with_index do |p, index|
|
27
|
+
p.name.should == browser.pre(:index, index+1).name
|
28
|
+
p.id.should == browser.pre(:index, index+1).id
|
29
|
+
p.value.should == browser.pre(:index, index+1).value
|
30
|
+
|
31
|
+
count += 1
|
32
|
+
end
|
33
|
+
|
34
|
+
count.should > 0
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Ps" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#length" do
|
11
|
+
it "returns the number of ps" do
|
12
|
+
browser.ps.length.should == 5
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#[]" do
|
17
|
+
it "returns the p at the given index" do
|
18
|
+
browser.ps[1].id.should == "lead"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#each" do
|
23
|
+
it "iterates through ps correctly" do
|
24
|
+
count = 0
|
25
|
+
|
26
|
+
browser.ps.each_with_index do |p, index|
|
27
|
+
p.name.should == browser.p(:index, index+1).name
|
28
|
+
p.id.should == browser.p(:index, index+1).id
|
29
|
+
p.value.should == browser.p(:index, index+1).value
|
30
|
+
|
31
|
+
count += 1
|
32
|
+
end
|
33
|
+
|
34
|
+
count.should > 0
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,286 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Radio" 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 radio button exists" do
|
13
|
+
browser.radio(:id, "new_user_newsletter_yes").should exist
|
14
|
+
browser.radio(:id, /new_user_newsletter_yes/).should exist
|
15
|
+
browser.radio(:name, "new_user_newsletter").should exist
|
16
|
+
browser.radio(:name, /new_user_newsletter/).should exist
|
17
|
+
browser.radio(:value, "yes").should exist
|
18
|
+
browser.radio(:value, /yes/).should exist
|
19
|
+
# TODO: figure out what :text means for a radio button
|
20
|
+
# browser.radio(:text, "yes").should exist
|
21
|
+
# browser.radio(:text, /yes/).should exist
|
22
|
+
browser.radio(:class, "huge").should exist
|
23
|
+
browser.radio(:class, /huge/).should exist
|
24
|
+
browser.radio(:index, 1).should exist
|
25
|
+
browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").should exist
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns the first radio if given no args" do
|
29
|
+
browser.radio.should exist
|
30
|
+
end
|
31
|
+
|
32
|
+
it "returns true if the element exists (default how = :name)" do
|
33
|
+
browser.radio("new_user_newsletter").should exist
|
34
|
+
end
|
35
|
+
|
36
|
+
it "returns true if the radio button exists (search by name and value)" do
|
37
|
+
browser.radio(:name, "new_user_newsletter", 'yes').should exist
|
38
|
+
browser.radio(:xpath, "//input[@name='new_user_newsletter' and @value='yes']").set
|
39
|
+
end
|
40
|
+
|
41
|
+
it "returns false if the radio button does not exist" do
|
42
|
+
browser.radio(:id, "no_such_id").should_not exist
|
43
|
+
browser.radio(:id, /no_such_id/).should_not exist
|
44
|
+
browser.radio(:name, "no_such_name").should_not exist
|
45
|
+
browser.radio(:name, /no_such_name/).should_not exist
|
46
|
+
browser.radio(:value, "no_such_value").should_not exist
|
47
|
+
browser.radio(:value, /no_such_value/).should_not exist
|
48
|
+
browser.radio(:text, "no_such_text").should_not exist
|
49
|
+
browser.radio(:text, /no_such_text/).should_not exist
|
50
|
+
browser.radio(:class, "no_such_class").should_not exist
|
51
|
+
browser.radio(:class, /no_such_class/).should_not exist
|
52
|
+
browser.radio(:index, 1337).should_not exist
|
53
|
+
browser.radio(:xpath, "input[@id='no_such_id']").should_not exist
|
54
|
+
end
|
55
|
+
|
56
|
+
it "returns false if the radio button does not exist (search by name and value)" do
|
57
|
+
browser.radio(:name, "new_user_newsletter", 'no_such_value').should_not exist
|
58
|
+
browser.radio(:xpath, "//input[@name='new_user_newsletter' and @value='no_such_value']").should_not exist
|
59
|
+
browser.radio(:name, "no_such_name", 'yes').should_not exist
|
60
|
+
browser.radio(:xpath, "//input[@name='no_such_name' and @value='yes']").should_not exist
|
61
|
+
end
|
62
|
+
|
63
|
+
it "returns true for radios with a string value" do
|
64
|
+
browser.radio(:name, 'new_user_newsletter', 'yes').should exist
|
65
|
+
browser.radio(:name, 'new_user_newsletter', 'no').should exist
|
66
|
+
end
|
67
|
+
|
68
|
+
it "raises TypeError when 'what' argument is invalid" do
|
69
|
+
lambda { browser.radio(:id, 3.14).exists? }.should raise_error(TypeError)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
73
|
+
lambda { browser.radio(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
74
|
+
end
|
75
|
+
end
|
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
|
+
# Access methods
|
166
|
+
describe "#enabled?" do
|
167
|
+
it "returns true if the radio button is enabled" do
|
168
|
+
browser.radio(:id, "new_user_newsletter_yes").should be_enabled
|
169
|
+
browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").should be_enabled
|
170
|
+
end
|
171
|
+
|
172
|
+
it "returns false if the radio button is disabled" do
|
173
|
+
browser.radio(:id, "new_user_newsletter_nah").should_not be_enabled
|
174
|
+
browser.radio(:xpath,"//input[@id='new_user_newsletter_nah']").should_not be_enabled
|
175
|
+
end
|
176
|
+
|
177
|
+
it "raises UnknownObjectException if the radio button doesn't exist" do
|
178
|
+
lambda { browser.radio(:id, "no_such_id").enabled? }.should raise_error(UnknownObjectException)
|
179
|
+
lambda { browser.radio(:xpath, "//input[@id='no_such_id']").enabled? }.should raise_error(UnknownObjectException)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
describe "#disabled?" do
|
184
|
+
it "returns true if the radio is disabled" do
|
185
|
+
browser.radio(:id, 'new_user_newsletter_nah').should be_disabled
|
186
|
+
end
|
187
|
+
|
188
|
+
it "returns false if the radio is enabled" do
|
189
|
+
browser.radio(:id, 'new_user_newsletter_yes').should_not be_disabled
|
190
|
+
end
|
191
|
+
|
192
|
+
it "raises UnknownObjectException if the radio doesn't exist" do
|
193
|
+
lambda { browser.radio(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
# Manipulation methods
|
198
|
+
describe "#clear" do
|
199
|
+
it "clears the radio button if it is set" do
|
200
|
+
browser.radio(:id, "new_user_newsletter_yes").clear
|
201
|
+
browser.radio(:id, "new_user_newsletter_yes").should_not be_set
|
202
|
+
end
|
203
|
+
|
204
|
+
it "clears the radio button when found by :xpath" do
|
205
|
+
browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").clear
|
206
|
+
browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").should_not be_set
|
207
|
+
end
|
208
|
+
|
209
|
+
it "raises UnknownObjectException if the radio button doesn't exist" do
|
210
|
+
lambda { browser.radio(:name, "no_such_id").clear }.should raise_error(UnknownObjectException)
|
211
|
+
lambda { browser.radio(:xpath, "//input[@id='no_such_id']").clear }.should raise_error(UnknownObjectException)
|
212
|
+
end
|
213
|
+
|
214
|
+
it "raises ObjectDisabledException if the radio is disabled" do
|
215
|
+
browser.radio(:id, "new_user_newsletter_nah").should_not be_set
|
216
|
+
lambda { browser.radio(:id, "new_user_newsletter_nah").clear }.should raise_error(ObjectDisabledException)
|
217
|
+
lambda { browser.radio(:xpath, "//input[@id='new_user_newsletter_nah']").clear }.should raise_error(ObjectDisabledException)
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
describe "#set" do
|
222
|
+
it "sets the radio button" do
|
223
|
+
browser.radio(:id, "new_user_newsletter_no").set
|
224
|
+
browser.radio(:id, "new_user_newsletter_no").should be_set
|
225
|
+
end
|
226
|
+
|
227
|
+
it "sets the radio button when found by :xpath" do
|
228
|
+
browser.radio(:xpath, "//input[@id='new_user_newsletter_no']").set
|
229
|
+
browser.radio(:xpath, "//input[@id='new_user_newsletter_no']").should be_set
|
230
|
+
end
|
231
|
+
|
232
|
+
it "fires the onclick event" do
|
233
|
+
browser.radio(:id, "new_user_newsletter_no").set
|
234
|
+
browser.radio(:id, "new_user_newsletter_yes").set
|
235
|
+
messages.should == ["clicked: new_user_newsletter_no", "clicked: new_user_newsletter_yes"]
|
236
|
+
end
|
237
|
+
|
238
|
+
bug "WTR-337", :watir do
|
239
|
+
it "fires the onchange event" do
|
240
|
+
browser.radio(:value, 'certainly').set
|
241
|
+
messages.should == ["changed: new_user_newsletter"]
|
242
|
+
|
243
|
+
browser.radio(:value, 'certainly').set
|
244
|
+
messages.should == ["changed: new_user_newsletter"] # no event fired here - didn't change
|
245
|
+
|
246
|
+
browser.radio(:value, 'certainly').clear
|
247
|
+
messages.should == ["changed: new_user_newsletter", "changed: new_user_newsletter"]
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
it "raises UnknownObjectException if the radio button doesn't exist" do
|
252
|
+
lambda { browser.radio(:name, "no_such_name").set }.should raise_error(UnknownObjectException)
|
253
|
+
lambda { browser.radio(:xpath, "//input[@name='no_such_name']").set }.should raise_error(UnknownObjectException)
|
254
|
+
end
|
255
|
+
|
256
|
+
it "raises ObjectDisabledException if the radio is disabled" do
|
257
|
+
lambda { browser.radio(:id, "new_user_newsletter_nah").set }.should raise_error(ObjectDisabledException)
|
258
|
+
lambda { browser.radio(:xpath, "//input[@id='new_user_newsletter_nah']").set }.should raise_error(ObjectDisabledException )
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
# Other
|
263
|
+
describe '#set?' do
|
264
|
+
it "returns true if the radio button is set" do
|
265
|
+
browser.radio(:id, "new_user_newsletter_yes").should be_set
|
266
|
+
end
|
267
|
+
|
268
|
+
it "returns false if the radio button unset" do
|
269
|
+
browser.radio(:id, "new_user_newsletter_no").should_not be_set
|
270
|
+
end
|
271
|
+
|
272
|
+
it "returns the state for radios with string values" do
|
273
|
+
browser.radio(:name, "new_user_newsletter", 'no').should_not be_set
|
274
|
+
browser.radio(:name, "new_user_newsletter", 'no').set
|
275
|
+
browser.radio(:name, "new_user_newsletter", 'no').should be_set
|
276
|
+
browser.radio(:name, "new_user_newsletter", 'no').clear
|
277
|
+
browser.radio(:name, "new_user_newsletter", 'no').should_not be_set
|
278
|
+
end
|
279
|
+
|
280
|
+
it "raises UnknownObjectException if the radio button doesn't exist" do
|
281
|
+
lambda { browser.radio(:id, "no_such_id").set? }.should raise_error(UnknownObjectException)
|
282
|
+
lambda { browser.radio(:xpath, "//input[@id='no_such_id']").set? }.should raise_error(UnknownObjectException)
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
end
|