watir-webdriver 0.0.1.dev
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/.document +5 -0
- data/.gitignore +5 -0
- data/.gitmodules +3 -0
- data/LICENSE +20 -0
- data/README.rdoc +32 -0
- data/Rakefile +107 -0
- data/TODO +15 -0
- data/VERSION +1 -0
- data/lib/watir-webdriver.rb +74 -0
- data/lib/watir-webdriver/base_element.rb +347 -0
- data/lib/watir-webdriver/browser.rb +130 -0
- data/lib/watir-webdriver/browserbot.js +34 -0
- data/lib/watir-webdriver/collections/buttons_collection.rb +13 -0
- data/lib/watir-webdriver/collections/element_collection.rb +45 -0
- data/lib/watir-webdriver/collections/table_rows_collection.rb +14 -0
- data/lib/watir-webdriver/collections/text_fields_collection.rb +13 -0
- data/lib/watir-webdriver/container.rb +24 -0
- data/lib/watir-webdriver/core_ext/string.rb +22 -0
- data/lib/watir-webdriver/elements/button.rb +27 -0
- data/lib/watir-webdriver/elements/checkbox.rb +23 -0
- data/lib/watir-webdriver/elements/file_field.rb +20 -0
- data/lib/watir-webdriver/elements/form.rb +11 -0
- data/lib/watir-webdriver/elements/generated.rb +941 -0
- data/lib/watir-webdriver/elements/headings.rb +48 -0
- data/lib/watir-webdriver/elements/hidden.rb +18 -0
- data/lib/watir-webdriver/elements/image.rb +33 -0
- data/lib/watir-webdriver/elements/input.rb +39 -0
- data/lib/watir-webdriver/elements/link.rb +13 -0
- data/lib/watir-webdriver/elements/option.rb +36 -0
- data/lib/watir-webdriver/elements/radio.rb +23 -0
- data/lib/watir-webdriver/elements/select_list.rb +73 -0
- data/lib/watir-webdriver/elements/shared_radio_checkbox.rb +13 -0
- data/lib/watir-webdriver/elements/table.rb +18 -0
- data/lib/watir-webdriver/elements/table_row.rb +17 -0
- data/lib/watir-webdriver/elements/text_field.rb +60 -0
- data/lib/watir-webdriver/exception.rb +20 -0
- data/lib/watir-webdriver/locators/button_locator.rb +57 -0
- data/lib/watir-webdriver/locators/element_locator.rb +269 -0
- data/lib/watir-webdriver/locators/table_row_locator.rb +25 -0
- data/lib/watir-webdriver/locators/text_field_locator.rb +61 -0
- data/lib/watir-webdriver/xpath_support.rb +23 -0
- data/spec/element_locator_spec.rb +11 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/watirspec/area_spec.rb +78 -0
- data/spec/watirspec/areas_spec.rb +31 -0
- data/spec/watirspec/browser_spec.rb +262 -0
- data/spec/watirspec/button_spec.rb +242 -0
- data/spec/watirspec/buttons_spec.rb +48 -0
- data/spec/watirspec/checkbox_spec.rb +272 -0
- data/spec/watirspec/checkboxes_spec.rb +32 -0
- data/spec/watirspec/dd_spec.rb +136 -0
- data/spec/watirspec/dds_spec.rb +31 -0
- data/spec/watirspec/div_spec.rb +222 -0
- data/spec/watirspec/divs_spec.rb +31 -0
- data/spec/watirspec/dl_spec.rb +136 -0
- data/spec/watirspec/dls_spec.rb +32 -0
- data/spec/watirspec/dt_spec.rb +136 -0
- data/spec/watirspec/dts_spec.rb +31 -0
- data/spec/watirspec/element_spec.rb +87 -0
- data/spec/watirspec/em_spec.rb +110 -0
- data/spec/watirspec/ems_spec.rb +32 -0
- data/spec/watirspec/filefield_spec.rb +119 -0
- data/spec/watirspec/filefields_spec.rb +32 -0
- data/spec/watirspec/form_spec.rb +63 -0
- data/spec/watirspec/forms_spec.rb +33 -0
- data/spec/watirspec/frame_spec.rb +140 -0
- data/spec/watirspec/frames_spec.rb +62 -0
- data/spec/watirspec/hidden_spec.rb +102 -0
- data/spec/watirspec/hiddens_spec.rb +32 -0
- data/spec/watirspec/hn_spec.rb +93 -0
- data/spec/watirspec/hns_spec.rb +38 -0
- data/spec/watirspec/image_spec.rb +207 -0
- data/spec/watirspec/images_spec.rb +31 -0
- data/spec/watirspec/label_spec.rb +75 -0
- data/spec/watirspec/labels_spec.rb +31 -0
- data/spec/watirspec/li_spec.rb +127 -0
- data/spec/watirspec/lib/guards.rb +59 -0
- data/spec/watirspec/lib/server.rb +127 -0
- data/spec/watirspec/lib/spec_helper.rb +79 -0
- data/spec/watirspec/lib/watirspec.rb +72 -0
- data/spec/watirspec/link_spec.rb +165 -0
- data/spec/watirspec/links_spec.rb +35 -0
- data/spec/watirspec/lis_spec.rb +31 -0
- data/spec/watirspec/map_spec.rb +92 -0
- data/spec/watirspec/maps_spec.rb +32 -0
- data/spec/watirspec/meta_spec.rb +22 -0
- data/spec/watirspec/metas_spec.rb +30 -0
- data/spec/watirspec/ol_spec.rb +78 -0
- data/spec/watirspec/ols_spec.rb +31 -0
- data/spec/watirspec/option_spec.rb +173 -0
- data/spec/watirspec/p_spec.rb +143 -0
- data/spec/watirspec/pre_spec.rb +125 -0
- data/spec/watirspec/pres_spec.rb +31 -0
- data/spec/watirspec/ps_spec.rb +31 -0
- data/spec/watirspec/radio_spec.rb +278 -0
- data/spec/watirspec/radios_spec.rb +32 -0
- data/spec/watirspec/select_list_spec.rb +318 -0
- data/spec/watirspec/select_lists_spec.rb +35 -0
- data/spec/watirspec/span_spec.rb +157 -0
- data/spec/watirspec/spans_spec.rb +57 -0
- data/spec/watirspec/spec_helper.rb +17 -0
- data/spec/watirspec/strong_spec.rb +89 -0
- data/spec/watirspec/strongs_spec.rb +32 -0
- data/spec/watirspec/table_bodies_spec.rb +45 -0
- data/spec/watirspec/table_body_spec.rb +98 -0
- data/spec/watirspec/table_cell_spec.rb +68 -0
- data/spec/watirspec/table_cells_spec.rb +47 -0
- data/spec/watirspec/table_footer_spec.rb +85 -0
- data/spec/watirspec/table_footers_spec.rb +47 -0
- data/spec/watirspec/table_header_spec.rb +85 -0
- data/spec/watirspec/table_headers_spec.rb +45 -0
- data/spec/watirspec/table_row_spec.rb +87 -0
- data/spec/watirspec/table_rows_spec.rb +50 -0
- data/spec/watirspec/table_spec.rb +166 -0
- data/spec/watirspec/tables_spec.rb +33 -0
- data/spec/watirspec/text_field_spec.rb +276 -0
- data/spec/watirspec/text_fields_spec.rb +35 -0
- data/spec/watirspec/ul_spec.rb +76 -0
- data/spec/watirspec/uls_spec.rb +33 -0
- data/spec/xpath_builder_spec.rb +49 -0
- data/support/html5/html5.idl +815 -0
- data/support/html5/html5_extras.idl +147 -0
- data/support/html5/idl_extractor.rb +73 -0
- data/support/html5/watir_visitor.rb +169 -0
- metadata +220 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
+
|
4
|
+
describe "FileFields" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#length" do
|
11
|
+
it "returns the correct number of file fields" do
|
12
|
+
browser.file_fields.length.should == 2
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#[]" do
|
17
|
+
it "returns the file field at the given index" do
|
18
|
+
browser.file_fields[0].id.should == "new_user_portrait"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#each" do
|
23
|
+
it "iterates through file fields correctly" do
|
24
|
+
browser.file_fields.each_with_index do |f, index|
|
25
|
+
f.name.should == browser.file_field(:index, index).name
|
26
|
+
f.id.should == browser.file_field(:index, index).id
|
27
|
+
f.value.should == browser.file_field(:index, index).value
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
+
|
4
|
+
describe "Form" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#exists?" do
|
11
|
+
it "returns true if the form exists" do
|
12
|
+
browser.form(:id, 'new_user').should exist
|
13
|
+
browser.form(:id, /new_user/).should exist
|
14
|
+
|
15
|
+
bug "WTR-355", :watir do
|
16
|
+
browser.form(:class, 'user').should exist
|
17
|
+
browser.form(:class, /user/).should exist
|
18
|
+
end
|
19
|
+
|
20
|
+
browser.form(:method, 'post').should exist
|
21
|
+
browser.form(:method, /post/).should exist
|
22
|
+
browser.form(:action, 'post_to_me').should exist
|
23
|
+
browser.form(:action, /to_me/).should exist
|
24
|
+
browser.form(:index, 0).should exist
|
25
|
+
browser.form(:xpath, "//form[@id='new_user']").should exist
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns false if the form doesn't exist" do
|
29
|
+
browser.form(:id, 'no_such_id').should_not exist
|
30
|
+
browser.form(:id, /no_such_id/).should_not exist
|
31
|
+
|
32
|
+
bug "WTR-355", :watir do
|
33
|
+
browser.form(:class, 'no_such_class').should_not exist
|
34
|
+
browser.form(:class, /no_such_class/).should_not exist
|
35
|
+
end
|
36
|
+
|
37
|
+
browser.form(:method, 'no_such_method').should_not exist
|
38
|
+
browser.form(:method, /no_such_method/).should_not exist
|
39
|
+
browser.form(:action, 'no_such_action').should_not exist
|
40
|
+
browser.form(:action, /no_such_action/).should_not exist
|
41
|
+
browser.form(:index, 1337).should_not exist
|
42
|
+
browser.form(:xpath, "//form[@id='no_such_id']").should_not exist
|
43
|
+
end
|
44
|
+
|
45
|
+
bug "WTR-356", :watir do
|
46
|
+
it "raises TypeError when 'what' argument is invalid" do
|
47
|
+
lambda { browser.form(:id, 3.14).exists? }.should raise_error(TypeError)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
52
|
+
lambda { browser.form(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#submit" do
|
57
|
+
it "submits the form" do
|
58
|
+
browser.form(:id, "delete_user").submit
|
59
|
+
browser.text.should include("Semantic table")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
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[0].action.should == 'post_to_me'
|
19
|
+
browser.forms[0].attribute_value('method').should == 'post'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#each" do
|
24
|
+
it "iterates through forms correctly" do
|
25
|
+
browser.forms.each_with_index do |f, index|
|
26
|
+
f.name.should == browser.form(:index, index).name
|
27
|
+
f.id.should == browser.form(:index, index).id
|
28
|
+
f.class_name.should == browser.form(:index, index).class_name
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
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, 0).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, 0).should exist
|
43
|
+
browser.frame(:xpath, "//iframe[@id='frame_1']").should exist
|
44
|
+
end
|
45
|
+
|
46
|
+
it "returns false if the frame doesn't exist" do
|
47
|
+
browser.frame(:id, "no_such_id").should_not exist
|
48
|
+
browser.frame(:id, /no_such_id/).should_not exist
|
49
|
+
browser.frame(:name, "no_such_text").should_not exist
|
50
|
+
browser.frame(:name, /no_such_text/).should_not exist
|
51
|
+
browser.frame(:src, "no_such_src").should_not exist
|
52
|
+
browser.frame(:src, /no_such_src/).should_not exist
|
53
|
+
browser.frame(:class, "no_such_class").should_not exist
|
54
|
+
browser.frame(:class, /no_such_class/).should_not exist
|
55
|
+
browser.frame(:index, 1337).should_not exist
|
56
|
+
browser.frame(:xpath, "//frame[@id='no_such_id']").should_not exist
|
57
|
+
end
|
58
|
+
|
59
|
+
it "raises TypeError when 'what' argument is invalid" do
|
60
|
+
lambda { browser.frame(:id, 3.14).exists? }.should raise_error(TypeError)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
64
|
+
lambda { browser.frame(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
it "raises UnknownFrameException when accessing elements inside non-existing frame" do
|
70
|
+
lambda { browser.frame(:name, "no_such_name").p(:index, 0).id }.should raise_error(UnknownFrameException)
|
71
|
+
end
|
72
|
+
|
73
|
+
it "raises UnknownFrameException when accessing a non-existing frame" do
|
74
|
+
lambda { browser.frame(:name, "no_such_name").id }.should raise_error(UnknownFrameException)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "raises UnknownFrameException when accessing a non-existing subframe" do
|
78
|
+
lambda { browser.frame(:name, "frame1").frame(:name, "no_such_name").id }.should raise_error(UnknownFrameException)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "raises UnknownObjectException when accessing a non-existing element inside an existing frame" do
|
82
|
+
lambda { browser.frame(:index, 0).p(:index, 1337).id }.should raise_error(UnknownObjectException)
|
83
|
+
end
|
84
|
+
|
85
|
+
it "raises NoMethodError when trying to access attributes it doesn't have" do
|
86
|
+
lambda { browser.frame(:index, 0).foo }.should raise_error(NoMethodError)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "is able to send a value to another frame by using Javascript" do
|
90
|
+
frame1, frame2 = browser.frame(:index, 0), browser.frame(:index, 1)
|
91
|
+
frame1.text_field(:index, 0).value.should == "send_this_value"
|
92
|
+
frame2.text_field(:index, 0).value.should == "old_value"
|
93
|
+
frame1.button(:index, 0).click
|
94
|
+
frame2.text_field(:index, 0).value.should == "send_this_value"
|
95
|
+
end
|
96
|
+
|
97
|
+
it "is able to set a field" do
|
98
|
+
browser.frame(:index, 0).text_field(:name, 'senderElement').set("new value")
|
99
|
+
browser.frame(:index, 0).text_field(:name, 'senderElement').value.should == "new value"
|
100
|
+
end
|
101
|
+
|
102
|
+
not_compliant_on :watir do
|
103
|
+
describe "#execute_script" do
|
104
|
+
it "executes the given javascript in the specified frame" do
|
105
|
+
frame = browser.frame(:index, 0)
|
106
|
+
frame.div(:id, 'set_by_js').text.should == ""
|
107
|
+
frame.execute_script(%Q{document.getElementById('set_by_js').innerHTML = 'Art consists of limitation. The most beautiful part of every picture is the frame.'})
|
108
|
+
frame.div(:id, 'set_by_js').text.should == "Art consists of limitation. The most beautiful part of every picture is the frame."
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
describe "#to_s" do
|
114
|
+
it "returns a human readable representation of the frame" do
|
115
|
+
browser.frame(:index, 0).to_s.should == "tag: frame\n" +
|
116
|
+
" src: frame_1.html\n" +
|
117
|
+
" id: frame_1\n" +
|
118
|
+
" name: frame1\n" +
|
119
|
+
" class: half"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe "#elements_by_xpath" do
|
124
|
+
before :each do
|
125
|
+
browser.goto(WatirSpec.files + "/iframes.html")
|
126
|
+
end
|
127
|
+
|
128
|
+
it "returns an Array of matching elements" do
|
129
|
+
objects = browser.frame(:index, 0).elements_by_xpath("/html")
|
130
|
+
objects.size.should == 1
|
131
|
+
end
|
132
|
+
|
133
|
+
it "returns an empty Array if there are no matching elements" do
|
134
|
+
objects = browser.frame(:index, 0).elements_by_xpath("//*[@type='foobar']")
|
135
|
+
objects.size.should == 0
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
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[0].id.should == "frame_1"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#each" do
|
24
|
+
it "iterates through frames correctly" do
|
25
|
+
browser.frames.each_with_index do |f, index|
|
26
|
+
f.id.should == browser.frame(:index, index).id
|
27
|
+
f.value.should == browser.frame(:index, index).value
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "<iframe> Frames" do
|
34
|
+
|
35
|
+
before :each do
|
36
|
+
browser.goto(WatirSpec.files + "/iframes.html")
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#length" do
|
40
|
+
it "returns the correct number of frames" do
|
41
|
+
browser.frames.length.should == 2
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#[]" do
|
46
|
+
it "returns the frame at the given index" do
|
47
|
+
browser.frames[0].id.should == "frame_1"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "#each" do
|
52
|
+
it "iterates through frames correctly" do
|
53
|
+
browser.frames.each_with_index do |f, index|
|
54
|
+
f.name.should == browser.frame(:index, index).name
|
55
|
+
f.id.should == browser.frame(:index, index).id
|
56
|
+
f.value.should == browser.frame(:index, index).value
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
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
|
+
# TODO: figure out what :text means for Hidden
|
20
|
+
# browser.hidden(:text, 'dolls').should exist
|
21
|
+
# browser.hidden(:text, /dolls/).should exist
|
22
|
+
browser.hidden(:class, 'fun').should exist
|
23
|
+
browser.hidden(:class, /fun/).should exist
|
24
|
+
browser.hidden(:index, 0).should exist
|
25
|
+
browser.hidden(:xpath, "//input[@id='new_user_interests_dolls']").should exist
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns false if the element does not exist" do
|
29
|
+
browser.hidden(:id, 'no_such_id').should_not exist
|
30
|
+
browser.hidden(:id, /no_such_id/).should_not exist
|
31
|
+
browser.hidden(:name, 'no_such_name').should_not exist
|
32
|
+
browser.hidden(:name, /no_such_name/).should_not exist
|
33
|
+
browser.hidden(:value, 'no_such_value').should_not exist
|
34
|
+
browser.hidden(:value, /no_such_value/).should_not exist
|
35
|
+
browser.hidden(:text, 'no_such_text').should_not exist
|
36
|
+
browser.hidden(:text, /no_such_text/).should_not exist
|
37
|
+
browser.hidden(:class, 'no_such_class').should_not exist
|
38
|
+
browser.hidden(:class, /no_such_class/).should_not exist
|
39
|
+
browser.hidden(:index, 1337).should_not exist
|
40
|
+
browser.hidden(:xpath, "//input[@id='no_such_id']").should_not exist
|
41
|
+
end
|
42
|
+
|
43
|
+
it "raises TypeError when 'what' argument is invalid" do
|
44
|
+
lambda { browser.hidden(:id, 3.14).exists? }.should raise_error(TypeError)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
48
|
+
lambda { browser.hidden(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Attribute methods
|
53
|
+
describe "#id" do
|
54
|
+
it "returns the id attribute if the text field exists" do
|
55
|
+
browser.hidden(:index, 0).id.should == "new_user_interests_dolls"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
59
|
+
lambda { browser.hidden(:index, 1337).id }.should raise_error(UnknownObjectException)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#name" do
|
64
|
+
it "returns the name attribute if the text field exists" do
|
65
|
+
browser.hidden(:index, 0).name.should == "new_user_interests"
|
66
|
+
end
|
67
|
+
|
68
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
69
|
+
lambda { browser.hidden(:index, 1337).name }.should raise_error(UnknownObjectException)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "#type" do
|
74
|
+
it "returns the type attribute if the text field exists" do
|
75
|
+
browser.hidden(:index, 0).type.should == "hidden"
|
76
|
+
end
|
77
|
+
|
78
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
79
|
+
lambda { browser.hidden(:index, 1337).type }.should raise_error(UnknownObjectException)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "#value" do
|
84
|
+
it "returns the value attribute if the text field exists" do
|
85
|
+
browser.hidden(:index, 0).value.should == "dolls"
|
86
|
+
end
|
87
|
+
|
88
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
89
|
+
lambda { browser.hidden(:index, 1337).value }.should raise_error(UnknownObjectException)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "#respond_to?" do
|
94
|
+
it "returns true for all attribute methods" do
|
95
|
+
browser.hidden(:index, 0).should respond_to(:id)
|
96
|
+
browser.hidden(:index, 0).should respond_to(:name)
|
97
|
+
browser.hidden(:index, 0).should respond_to(:type)
|
98
|
+
browser.hidden(:index, 0).should respond_to(:value)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
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[0].id.should == "new_user_interests_dolls"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#each" do
|
23
|
+
it "iterates through hiddens correctly" do
|
24
|
+
browser.hiddens.each_with_index do |h, index|
|
25
|
+
h.name.should == browser.hidden(:index, index).name
|
26
|
+
h.id.should == browser.hidden(:index, index).id
|
27
|
+
h.value.should == browser.hidden(:index, index).value
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|