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,39 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Forms" 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 forms in the container" do
|
12
|
+
browser.forms.length.should == 2
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#[]n" do
|
17
|
+
it "provides access to the nth form" do
|
18
|
+
browser.forms[1].action.should == 'post_to_me'
|
19
|
+
browser.forms[1].attribute_value('method').should == 'post'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#each" do
|
24
|
+
it "iterates through forms correctly" do
|
25
|
+
count = 0
|
26
|
+
|
27
|
+
browser.forms.each_with_index do |f, index|
|
28
|
+
f.name.should == browser.form(:index, index+1).name
|
29
|
+
f.id.should == browser.form(:index, index+1).id
|
30
|
+
f.class_name.should == browser.form(:index, index+1).class_name
|
31
|
+
|
32
|
+
count += 1
|
33
|
+
end
|
34
|
+
|
35
|
+
count.should > 0
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,161 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Frame" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/frames.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "handles crossframe javascript" do
|
11
|
+
browser.frame(:id, "frame_1").text_field(:name, 'senderElement').value.should == 'send_this_value'
|
12
|
+
browser.frame(:id, "frame_2").text_field(:name, 'recieverElement').value.should == 'old_value'
|
13
|
+
browser.frame(:id, "frame_1").button(:id, 'send').click
|
14
|
+
browser.frame(:id, "frame_2").text_field(:name, 'recieverElement').value.should == 'send_this_value'
|
15
|
+
end
|
16
|
+
|
17
|
+
not_compliant_on :watir do
|
18
|
+
describe "#exist?" do
|
19
|
+
it "returns true if the frame exists" do
|
20
|
+
browser.frame(:id, "frame_1").should exist
|
21
|
+
browser.frame(:id, /frame/).should exist
|
22
|
+
browser.frame(:name, "frame1").should exist
|
23
|
+
browser.frame(:name, /frame/).should exist
|
24
|
+
browser.frame(:src, "frame_1.html").should exist
|
25
|
+
browser.frame(:src, /frame_1/).should exist
|
26
|
+
browser.frame(:class, "half").should exist
|
27
|
+
browser.frame(:class, /half/).should exist
|
28
|
+
browser.frame(:index, 1).should exist
|
29
|
+
browser.frame(:xpath, "//frame[@id='frame_1']").should exist
|
30
|
+
end
|
31
|
+
|
32
|
+
it "returns true if the iframe exists" do
|
33
|
+
browser.goto(WatirSpec.files + "/iframes.html")
|
34
|
+
browser.frame(:id, "frame_1").should exist
|
35
|
+
browser.frame(:id, /frame/).should exist
|
36
|
+
browser.frame(:name, "frame1").should exist
|
37
|
+
browser.frame(:name, /frame/).should exist
|
38
|
+
browser.frame(:src, "frame_1.html").should exist
|
39
|
+
browser.frame(:src, /frame_1/).should exist
|
40
|
+
browser.frame(:class, "iframe").should exist
|
41
|
+
browser.frame(:class, /iframe/).should exist
|
42
|
+
browser.frame(:index, 1).should exist
|
43
|
+
browser.frame(:xpath, "//iframe[@id='frame_1']").should exist
|
44
|
+
end
|
45
|
+
|
46
|
+
it "returns true if the element exists (default how = :name)" do
|
47
|
+
browser.frame("frame1").should exist
|
48
|
+
browser.goto(WatirSpec.files + "/iframes.html")
|
49
|
+
browser.frame("frame1").should exist
|
50
|
+
end
|
51
|
+
|
52
|
+
it "returns the first frame if given no args" do
|
53
|
+
browser.frame.should exist
|
54
|
+
end
|
55
|
+
|
56
|
+
it "returns false if the frame doesn't exist" do
|
57
|
+
browser.frame(:id, "no_such_id").should_not exist
|
58
|
+
browser.frame(:id, /no_such_id/).should_not exist
|
59
|
+
browser.frame(:name, "no_such_text").should_not exist
|
60
|
+
browser.frame(:name, /no_such_text/).should_not exist
|
61
|
+
browser.frame(:src, "no_such_src").should_not exist
|
62
|
+
browser.frame(:src, /no_such_src/).should_not exist
|
63
|
+
browser.frame(:class, "no_such_class").should_not exist
|
64
|
+
browser.frame(:class, /no_such_class/).should_not exist
|
65
|
+
browser.frame(:index, 1337).should_not exist
|
66
|
+
browser.frame(:xpath, "//frame[@id='no_such_id']").should_not exist
|
67
|
+
end
|
68
|
+
|
69
|
+
it "raises TypeError when 'what' argument is invalid" do
|
70
|
+
lambda { browser.frame(:id, 3.14).exists? }.should raise_error(TypeError)
|
71
|
+
end
|
72
|
+
|
73
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
74
|
+
lambda { browser.frame(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
it "raises UnknownFrameException when accessing elements inside non-existing frame" do
|
80
|
+
lambda { browser.frame(:name, "no_such_name").p(:index, 1).id }.should raise_error(UnknownFrameException)
|
81
|
+
end
|
82
|
+
|
83
|
+
it "raises UnknownFrameException when accessing a non-existing frame" do
|
84
|
+
lambda { browser.frame(:name, "no_such_name").id }.should raise_error(UnknownFrameException)
|
85
|
+
end
|
86
|
+
|
87
|
+
it "raises UnknownFrameException when accessing a non-existing subframe" do
|
88
|
+
lambda { browser.frame(:name, "frame1").frame(:name, "no_such_name").id }.should raise_error(UnknownFrameException)
|
89
|
+
end
|
90
|
+
|
91
|
+
it "raises UnknownObjectException when accessing a non-existing element inside an existing frame" do
|
92
|
+
lambda { browser.frame(:index, 1).p(:index, 1337).id }.should raise_error(UnknownObjectException)
|
93
|
+
end
|
94
|
+
|
95
|
+
it "raises NoMethodError when trying to access attributes it doesn't have" do
|
96
|
+
lambda { browser.frame(:index, 1).foo }.should raise_error(NoMethodError)
|
97
|
+
end
|
98
|
+
|
99
|
+
it "is able to send a value to another frame by using Javascript" do
|
100
|
+
frame1, frame2 = browser.frame(:index, 1), browser.frame(:index, 2)
|
101
|
+
frame1.text_field(:index, 1).value.should == "send_this_value"
|
102
|
+
frame2.text_field(:index, 1).value.should == "old_value"
|
103
|
+
frame1.button(:index, 1).click
|
104
|
+
frame2.text_field(:index, 1).value.should == "send_this_value"
|
105
|
+
end
|
106
|
+
|
107
|
+
it "is able to set a field" do
|
108
|
+
browser.frame(:index, 1).text_field(:name, 'senderElement').set("new value")
|
109
|
+
browser.frame(:index, 1).text_field(:name, 'senderElement').value.should == "new value"
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "#contains_text" do
|
113
|
+
it "finds text in a frame" do
|
114
|
+
browser.frame(:name, 'frame1').contains_text('Suspendisse sit amet nisi.').should be_instance_of(Fixnum)
|
115
|
+
end
|
116
|
+
|
117
|
+
it "raises TypeError when given an invalid argument" do
|
118
|
+
lambda { browser.frame(:name, 'frame1').contains_text(3.14) }.should raise_error(TypeError)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
not_compliant_on :watir do
|
124
|
+
describe "#execute_script" do
|
125
|
+
it "executes the given javascript in the specified frame" do
|
126
|
+
frame = browser.frame(:index, 1)
|
127
|
+
frame.div(:id, 'set_by_js').text.should == ""
|
128
|
+
frame.execute_script(%Q{document.getElementById('set_by_js').innerHTML = 'Art consists of limitation. The most beautiful part of every picture is the frame.'})
|
129
|
+
frame.div(:id, 'set_by_js').text.should == "Art consists of limitation. The most beautiful part of every picture is the frame."
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
describe "#to_s" do
|
135
|
+
it "returns a human readable representation of the frame" do
|
136
|
+
browser.frame(:index, 1).to_s.should == "tag: frame\n" +
|
137
|
+
" src: frame_1.html\n" +
|
138
|
+
" id: frame_1\n" +
|
139
|
+
" name: frame1\n" +
|
140
|
+
" class: half"
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe "#elements_by_xpath" do
|
145
|
+
before :each do
|
146
|
+
browser.goto(WatirSpec.files + "/iframes.html")
|
147
|
+
end
|
148
|
+
|
149
|
+
it "returns an Array of matching elements" do
|
150
|
+
objects = browser.frame(:index, 1).elements_by_xpath("/html")
|
151
|
+
objects.size.should == 1
|
152
|
+
end
|
153
|
+
|
154
|
+
it "returns an empty Array if there are no matching elements" do
|
155
|
+
objects = browser.frame(:index, 1).elements_by_xpath("//*[@type='foobar']")
|
156
|
+
objects.size.should == 0
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
161
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
not_compliant_on :watir do
|
5
|
+
describe "<frame> Frames" do
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
browser.goto(WatirSpec.files + "/frames.html")
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#length" do
|
12
|
+
it "returns the correct number of frames" do
|
13
|
+
browser.frames.length.should == 2
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#[]" do
|
18
|
+
it "returns the frame at the given index" do
|
19
|
+
browser.frames[1].id.should == "frame_1"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#each" do
|
24
|
+
it "iterates through frames correctly" do
|
25
|
+
count = 0
|
26
|
+
|
27
|
+
browser.frames.each_with_index do |f, index|
|
28
|
+
f.name.should == browser.frame(:index, index+1).name
|
29
|
+
f.id.should == browser.frame(:index, index+1).id
|
30
|
+
f.value.should == browser.frame(:index, index+1).value
|
31
|
+
|
32
|
+
count += 1
|
33
|
+
end
|
34
|
+
|
35
|
+
count.should > 0
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "<iframe> Frames" do
|
41
|
+
|
42
|
+
before :each do
|
43
|
+
browser.goto(WatirSpec.files + "/iframes.html")
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#length" do
|
47
|
+
it "returns the correct number of frames" do
|
48
|
+
browser.frames.length.should == 2
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#[]" do
|
53
|
+
it "returns the frame at the given index" do
|
54
|
+
browser.frames[1].id.should == "frame_1"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "#each" do
|
59
|
+
it "iterates through frames correctly" do
|
60
|
+
count = 0
|
61
|
+
|
62
|
+
browser.frames.each_with_index do |f, index|
|
63
|
+
f.name.should == browser.frame(:index, index+1).name
|
64
|
+
f.id.should == browser.frame(:index, index+1).id
|
65
|
+
f.value.should == browser.frame(:index, index+1).value
|
66
|
+
|
67
|
+
count += 1
|
68
|
+
end
|
69
|
+
|
70
|
+
count.should > 0
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module WatirSpec
|
2
|
+
class Guard
|
3
|
+
|
4
|
+
attr_accessor :type, :browsers, :data
|
5
|
+
|
6
|
+
def initialize(type, browsers, data={})
|
7
|
+
self.type, self.browsers, self.data = type, browsers, data
|
8
|
+
WatirSpec.guards << self
|
9
|
+
end
|
10
|
+
|
11
|
+
def guarded?(browser)
|
12
|
+
WatirSpec.guarded? || browsers.include?(browser.name)
|
13
|
+
end
|
14
|
+
|
15
|
+
module Helpers
|
16
|
+
def deviates_on(*browsers)
|
17
|
+
guard = WatirSpec::Guard.new :deviation, browsers, :file => caller.first
|
18
|
+
yield unless guard.guarded?(OperaWatir::Helper.browser)
|
19
|
+
end
|
20
|
+
|
21
|
+
def not_compliant_on(*browsers)
|
22
|
+
guard = WatirSpec::Guard.new :non_compliance, browsers, :file => caller.first
|
23
|
+
yield unless guard.guarded?(OperaWatir::Helper.browser)
|
24
|
+
end
|
25
|
+
|
26
|
+
def compliant_on(*browsers)
|
27
|
+
guard = WatirSpec::Guard.new :compliance, browsers, :file => caller.first
|
28
|
+
yield unless guard.guarded?(OperaWatir::Helper.browser)
|
29
|
+
end
|
30
|
+
|
31
|
+
def bug(url, *browsers)
|
32
|
+
guard = WatirSpec::Guard.new :bug, browsers, :file => caller.first, :url => url
|
33
|
+
yield unless guard.guarded?(OperaWatir::Helper.browser)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Hidden" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
# Exist method
|
11
|
+
describe "#exists?" do
|
12
|
+
it "returns true if the element exists" do
|
13
|
+
browser.hidden(:id, 'new_user_interests_dolls').should exist
|
14
|
+
browser.hidden(:id, /new_user_interests_dolls/).should exist
|
15
|
+
browser.hidden(:name, 'new_user_interests').should exist
|
16
|
+
browser.hidden(:name, /new_user_interests/).should exist
|
17
|
+
browser.hidden(:value, 'dolls').should exist
|
18
|
+
browser.hidden(:value, /dolls/).should exist
|
19
|
+
browser.hidden(:class, 'fun').should exist
|
20
|
+
browser.hidden(:class, /fun/).should exist
|
21
|
+
browser.hidden(:index, 1).should exist
|
22
|
+
browser.hidden(:xpath, "//input[@id='new_user_interests_dolls']").should exist
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns the first hidden if given no args" do
|
26
|
+
browser.hidden.should exist
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns true if the element exists (default how = :name)" do
|
30
|
+
browser.hidden("new_user_interests").should exist
|
31
|
+
end
|
32
|
+
|
33
|
+
it "returns false if the element does not exist" do
|
34
|
+
browser.hidden(:id, 'no_such_id').should_not exist
|
35
|
+
browser.hidden(:id, /no_such_id/).should_not exist
|
36
|
+
browser.hidden(:name, 'no_such_name').should_not exist
|
37
|
+
browser.hidden(:name, /no_such_name/).should_not exist
|
38
|
+
browser.hidden(:value, 'no_such_value').should_not exist
|
39
|
+
browser.hidden(:value, /no_such_value/).should_not exist
|
40
|
+
browser.hidden(:text, 'no_such_text').should_not exist
|
41
|
+
browser.hidden(:text, /no_such_text/).should_not exist
|
42
|
+
browser.hidden(:class, 'no_such_class').should_not exist
|
43
|
+
browser.hidden(:class, /no_such_class/).should_not exist
|
44
|
+
browser.hidden(:index, 1337).should_not exist
|
45
|
+
browser.hidden(:xpath, "//input[@id='no_such_id']").should_not exist
|
46
|
+
end
|
47
|
+
|
48
|
+
it "raises TypeError when 'what' argument is invalid" do
|
49
|
+
lambda { browser.hidden(:id, 3.14).exists? }.should raise_error(TypeError)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
53
|
+
lambda { browser.hidden(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Attribute methods
|
58
|
+
describe "#id" do
|
59
|
+
it "returns the id attribute if the text field exists" do
|
60
|
+
browser.hidden(:index, 1).id.should == "new_user_interests_dolls"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
64
|
+
lambda { browser.hidden(:index, 1337).id }.should raise_error(UnknownObjectException)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "#name" do
|
69
|
+
it "returns the name attribute if the text field exists" do
|
70
|
+
browser.hidden(:index, 1).name.should == "new_user_interests"
|
71
|
+
end
|
72
|
+
|
73
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
74
|
+
lambda { browser.hidden(:index, 1337).name }.should raise_error(UnknownObjectException)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "#type" do
|
79
|
+
it "returns the type attribute if the text field exists" do
|
80
|
+
browser.hidden(:index, 1).type.should == "hidden"
|
81
|
+
end
|
82
|
+
|
83
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
84
|
+
lambda { browser.hidden(:index, 1337).type }.should raise_error(UnknownObjectException)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "#value" do
|
89
|
+
it "returns the value attribute if the text field exists" do
|
90
|
+
browser.hidden(:index, 1).value.should == "dolls"
|
91
|
+
end
|
92
|
+
|
93
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
94
|
+
lambda { browser.hidden(:index, 1337).value }.should raise_error(UnknownObjectException)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "#respond_to?" do
|
99
|
+
it "returns true for all attribute methods" do
|
100
|
+
browser.hidden(:index, 1).should respond_to(:id)
|
101
|
+
browser.hidden(:index, 1).should respond_to(:name)
|
102
|
+
browser.hidden(:index, 1).should respond_to(:type)
|
103
|
+
browser.hidden(:index, 1).should respond_to(:value)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# Manipulation methods
|
108
|
+
describe "#value=" do
|
109
|
+
it "sets the value of the element" do
|
110
|
+
browser.hidden(:id, 'new_user_interests_dolls').value = 'guns'
|
111
|
+
browser.hidden(:id, "new_user_interests_dolls").value.should == 'guns'
|
112
|
+
end
|
113
|
+
|
114
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
115
|
+
lambda { browser.hidden(:id, 'no_such_id').value = 'guns' }.should raise_error(UnknownObjectException)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Hiddens" 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 hiddens" do
|
12
|
+
browser.hiddens.length.should == 1
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#[]" do
|
17
|
+
it "returns the Hidden at the given index" do
|
18
|
+
browser.hiddens[1].id.should == "new_user_interests_dolls"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#each" do
|
23
|
+
it "iterates through hiddens correctly" do
|
24
|
+
count = 0
|
25
|
+
|
26
|
+
browser.hiddens.each_with_index do |h, index|
|
27
|
+
h.name.should == browser.hidden(:index, index+1).name
|
28
|
+
h.id.should == browser.hidden(:index, index+1).id
|
29
|
+
h.value.should == browser.hidden(:index, index+1).value
|
30
|
+
|
31
|
+
count += 1
|
32
|
+
end
|
33
|
+
|
34
|
+
count.should > 0
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|