watir-webdriver 0.1.4 → 0.1.5
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/.gitignore +9 -0
- data/Gemfile +3 -3
- data/Rakefile +3 -28
- data/lib/watir-webdriver.rb +1 -0
- data/lib/watir-webdriver/version.rb +3 -0
- data/watir-webdriver.gemspec +23 -247
- metadata +34 -326
- data/VERSION +0 -1
- data/spec/watirspec/area_spec.rb +0 -77
- data/spec/watirspec/areas_spec.rb +0 -45
- data/spec/watirspec/browser_spec.rb +0 -274
- data/spec/watirspec/button_spec.rb +0 -255
- data/spec/watirspec/buttons_spec.rb +0 -58
- data/spec/watirspec/checkbox_spec.rb +0 -276
- data/spec/watirspec/checkboxes_spec.rb +0 -47
- data/spec/watirspec/collections_spec.rb +0 -20
- data/spec/watirspec/dd_spec.rb +0 -127
- data/spec/watirspec/dds_spec.rb +0 -45
- data/spec/watirspec/del_spec.rb +0 -145
- data/spec/watirspec/dels_spec.rb +0 -45
- data/spec/watirspec/div_spec.rb +0 -221
- data/spec/watirspec/divs_spec.rb +0 -45
- data/spec/watirspec/dl_spec.rb +0 -137
- data/spec/watirspec/dls_spec.rb +0 -46
- data/spec/watirspec/dt_spec.rb +0 -127
- data/spec/watirspec/dts_spec.rb +0 -45
- data/spec/watirspec/element_spec.rb +0 -149
- data/spec/watirspec/em_spec.rb +0 -101
- data/spec/watirspec/ems_spec.rb +0 -46
- data/spec/watirspec/filefield_spec.rb +0 -156
- data/spec/watirspec/filefields_spec.rb +0 -46
- data/spec/watirspec/font_spec.rb +0 -32
- data/spec/watirspec/form_spec.rb +0 -63
- data/spec/watirspec/forms_spec.rb +0 -47
- data/spec/watirspec/frame_spec.rb +0 -144
- data/spec/watirspec/frames_spec.rb +0 -83
- data/spec/watirspec/hidden_spec.rb +0 -103
- data/spec/watirspec/hiddens_spec.rb +0 -46
- data/spec/watirspec/hn_spec.rb +0 -97
- data/spec/watirspec/hns_spec.rb +0 -42
- data/spec/watirspec/image_spec.rb +0 -208
- data/spec/watirspec/images_spec.rb +0 -45
- data/spec/watirspec/ins_spec.rb +0 -146
- data/spec/watirspec/inses_spec.rb +0 -45
- data/spec/watirspec/label_spec.rb +0 -81
- data/spec/watirspec/labels_spec.rb +0 -45
- data/spec/watirspec/li_spec.rb +0 -116
- data/spec/watirspec/lib/guards.rb +0 -59
- data/spec/watirspec/lib/implementation.rb +0 -48
- data/spec/watirspec/lib/runner.rb +0 -83
- data/spec/watirspec/lib/server.rb +0 -194
- data/spec/watirspec/lib/watirspec.rb +0 -75
- data/spec/watirspec/link_spec.rb +0 -174
- data/spec/watirspec/links_spec.rb +0 -49
- data/spec/watirspec/lis_spec.rb +0 -45
- data/spec/watirspec/map_spec.rb +0 -80
- data/spec/watirspec/maps_spec.rb +0 -46
- data/spec/watirspec/meta_spec.rb +0 -24
- data/spec/watirspec/metas_spec.rb +0 -43
- data/spec/watirspec/ol_spec.rb +0 -90
- data/spec/watirspec/ols_spec.rb +0 -45
- data/spec/watirspec/option_spec.rb +0 -152
- data/spec/watirspec/p_spec.rb +0 -132
- data/spec/watirspec/pre_spec.rb +0 -116
- data/spec/watirspec/pres_spec.rb +0 -45
- data/spec/watirspec/ps_spec.rb +0 -45
- data/spec/watirspec/radio_spec.rb +0 -262
- data/spec/watirspec/radios_spec.rb +0 -46
- data/spec/watirspec/select_list_spec.rb +0 -335
- data/spec/watirspec/select_lists_spec.rb +0 -49
- data/spec/watirspec/span_spec.rb +0 -146
- data/spec/watirspec/spans_spec.rb +0 -45
- data/spec/watirspec/spec_helper.rb +0 -20
- data/spec/watirspec/strong_spec.rb +0 -93
- data/spec/watirspec/strongs_spec.rb +0 -46
- data/spec/watirspec/table_nesting_spec.rb +0 -50
- data/spec/watirspec/table_spec.rb +0 -150
- data/spec/watirspec/tables_spec.rb +0 -47
- data/spec/watirspec/tbody_spec.rb +0 -97
- data/spec/watirspec/tbodys_spec.rb +0 -65
- data/spec/watirspec/td_spec.rb +0 -72
- data/spec/watirspec/tds_spec.rb +0 -60
- data/spec/watirspec/text_field_spec.rb +0 -283
- data/spec/watirspec/text_fields_spec.rb +0 -49
- data/spec/watirspec/tfoot_spec.rb +0 -92
- data/spec/watirspec/tfoots_spec.rb +0 -71
- data/spec/watirspec/thead_spec.rb +0 -92
- data/spec/watirspec/theads_spec.rb +0 -71
- data/spec/watirspec/tr_spec.rb +0 -88
- data/spec/watirspec/trs_spec.rb +0 -68
- data/spec/watirspec/ul_spec.rb +0 -80
- data/spec/watirspec/uls_spec.rb +0 -44
- data/spec/watirspec/window_switching_spec.rb +0 -164
@@ -1,47 +0,0 @@
|
|
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
|
-
bug "http://github.com/jarib/celerity/issues#issue/25", :celerity do
|
11
|
-
describe "with selectors" do
|
12
|
-
it "returns the matching elements" do
|
13
|
-
browser.forms(:method => "post").to_a.should == [browser.form(:method => "post")]
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "#length" do
|
19
|
-
it "returns the number of forms in the container" do
|
20
|
-
browser.forms.length.should == 2
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "#[]n" do
|
25
|
-
it "provides access to the nth form" do
|
26
|
-
browser.forms[0].action.should =~ /post_to_me$/ # varies between browsers
|
27
|
-
browser.forms[0].attribute_value('method').should == 'post'
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "#each" do
|
32
|
-
it "iterates through forms correctly" do
|
33
|
-
count = 0
|
34
|
-
|
35
|
-
browser.forms.each_with_index do |f, index|
|
36
|
-
f.name.should == browser.form(:index, index).name
|
37
|
-
f.id.should == browser.form(:index, index).id
|
38
|
-
f.class_name.should == browser.form(:index, index).class_name
|
39
|
-
|
40
|
-
count += 1
|
41
|
-
end
|
42
|
-
|
43
|
-
count.should > 0
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
@@ -1,144 +0,0 @@
|
|
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
|
-
describe "#exist?" do
|
18
|
-
it "returns true if the frame exists" do
|
19
|
-
browser.frame(:id, "frame_1").should exist
|
20
|
-
browser.frame(:name, "frame1").should exist
|
21
|
-
browser.frame(:index, 0).should exist
|
22
|
-
|
23
|
-
bug "http://github.com/jarib/watir-webdriver/issues#issue/17", :webdriver do
|
24
|
-
browser.frame(:class, "half").should exist
|
25
|
-
browser.frame(:xpath, "//frame[@id='frame_1']").should exist
|
26
|
-
browser.frame(:src, "frame_1.html").should exist
|
27
|
-
browser.frame(:id, /frame/).should exist
|
28
|
-
browser.frame(:name, /frame/).should exist
|
29
|
-
browser.frame(:src, /frame_1/).should exist
|
30
|
-
browser.frame(:class, /half/).should exist
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
it "returns true if the iframe exists" do
|
35
|
-
browser.goto(WatirSpec.files + "/iframes.html")
|
36
|
-
browser.frame(:id, "frame_1").should exist
|
37
|
-
browser.frame(:id, /frame/).should exist
|
38
|
-
browser.frame(:name, "frame1").should exist
|
39
|
-
browser.frame(:name, /frame/).should exist
|
40
|
-
browser.frame(:src, "frame_1.html").should exist
|
41
|
-
browser.frame(:src, /frame_1/).should exist
|
42
|
-
browser.frame(:class, "iframe").should exist
|
43
|
-
browser.frame(:class, /iframe/).should exist
|
44
|
-
browser.frame(:index, 0).should exist
|
45
|
-
browser.frame(:xpath, "//iframe[@id='frame_1']").should exist
|
46
|
-
end
|
47
|
-
|
48
|
-
bug "http://github.com/jarib/watir-webdriver/issues#issue/17", :webdriver do
|
49
|
-
it "returns the first frame if given no args" do
|
50
|
-
browser.frame.should exist
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
it "returns false if the frame doesn't exist" do
|
55
|
-
browser.frame(:id, "no_such_id").should_not exist
|
56
|
-
browser.frame(:name, "no_such_text").should_not exist
|
57
|
-
browser.frame(:index, 1337).should_not exist
|
58
|
-
|
59
|
-
bug "http://github.com/jarib/watir-webdriver/issues#issue/17", :webdriver do
|
60
|
-
browser.frame(:src, "no_such_src").should_not exist
|
61
|
-
browser.frame(:class, "no_such_class").should_not exist
|
62
|
-
browser.frame(:id, /no_such_id/).should_not exist
|
63
|
-
browser.frame(:name, /no_such_text/).should_not exist
|
64
|
-
browser.frame(:src, /no_such_src/).should_not exist
|
65
|
-
browser.frame(:class, /no_such_class/).should_not exist
|
66
|
-
browser.frame(:xpath, "//frame[@id='no_such_id']").should_not exist
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
it "handles nested frames" do
|
71
|
-
browser.goto(WatirSpec.host + "/nested_frames.html")
|
72
|
-
|
73
|
-
browser.frame(:id, "two").frame(:id, "three").link(:id => "four").click
|
74
|
-
browser.title.should == "definition_lists"
|
75
|
-
end
|
76
|
-
|
77
|
-
it "raises TypeError when 'what' argument is invalid" do
|
78
|
-
lambda { browser.frame(:id, 3.14).exists? }.should raise_error(TypeError)
|
79
|
-
end
|
80
|
-
|
81
|
-
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
82
|
-
lambda { browser.frame(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
it "raises UnknownFrameException when accessing elements inside non-existing frame" do
|
87
|
-
lambda { browser.frame(:name, "no_such_name").p(:index, 0).id }.should raise_error(UnknownFrameException)
|
88
|
-
end
|
89
|
-
|
90
|
-
it "raises UnknownFrameException when accessing a non-existing frame" do
|
91
|
-
lambda { browser.frame(:name, "no_such_name").id }.should raise_error(UnknownFrameException)
|
92
|
-
end
|
93
|
-
|
94
|
-
it "raises UnknownFrameException when accessing a non-existing subframe" do
|
95
|
-
lambda { browser.frame(:name, "frame1").frame(:name, "no_such_name").id }.should raise_error(UnknownFrameException)
|
96
|
-
end
|
97
|
-
|
98
|
-
it "raises UnknownObjectException when accessing a non-existing element inside an existing frame" do
|
99
|
-
lambda { browser.frame(:index, 0).p(:index, 1337).id }.should raise_error(UnknownObjectException)
|
100
|
-
end
|
101
|
-
|
102
|
-
it "raises NoMethodError when trying to access attributes it doesn't have" do
|
103
|
-
lambda { browser.frame(:index, 0).foo }.should raise_error(NoMethodError)
|
104
|
-
end
|
105
|
-
|
106
|
-
it "is able to send a value to another frame by using Javascript" do
|
107
|
-
frame1, frame2 = browser.frame(:index, 0), browser.frame(:index, 1)
|
108
|
-
frame1.text_field(:index, 0).value.should == "send_this_value"
|
109
|
-
frame2.text_field(:index, 0).value.should == "old_value"
|
110
|
-
frame1.button(:index, 0).click
|
111
|
-
frame2.text_field(:index, 0).value.should == "send_this_value"
|
112
|
-
end
|
113
|
-
|
114
|
-
it "is able to set a field" do
|
115
|
-
browser.frame(:index, 0).text_field(:name, 'senderElement').set("new value")
|
116
|
-
browser.frame(:index, 0).text_field(:name, 'senderElement').value.should == "new value"
|
117
|
-
end
|
118
|
-
|
119
|
-
describe "#execute_script" do
|
120
|
-
it "executes the given javascript in the specified frame" do
|
121
|
-
frame = browser.frame(:index, 0)
|
122
|
-
frame.div(:id, 'set_by_js').text.should == ""
|
123
|
-
frame.execute_script(%Q{document.getElementById('set_by_js').innerHTML = 'Art consists of limitation. The most beautiful part of every picture is the frame.'})
|
124
|
-
frame.div(:id, 'set_by_js').text.should == "Art consists of limitation. The most beautiful part of every picture is the frame."
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
describe "#elements_by_xpath" do
|
129
|
-
before :each do
|
130
|
-
browser.goto(WatirSpec.files + "/iframes.html")
|
131
|
-
end
|
132
|
-
|
133
|
-
it "returns an Array of matching elements" do
|
134
|
-
objects = browser.frame(:index, 0).elements_by_xpath("/html")
|
135
|
-
objects.size.should == 1
|
136
|
-
end
|
137
|
-
|
138
|
-
it "returns an empty Array if there are no matching elements" do
|
139
|
-
objects = browser.frame(:index, 0).elements_by_xpath("//*[@type='foobar']")
|
140
|
-
objects.size.should == 0
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require File.expand_path("../spec_helper", __FILE__)
|
3
|
-
|
4
|
-
bug "http://github.com/jarib/watir-webdriver/issues#issue/17", :webdriver do
|
5
|
-
|
6
|
-
describe "<frame> Frames" do
|
7
|
-
|
8
|
-
before :each do
|
9
|
-
browser.goto(WatirSpec.files + "/frames.html")
|
10
|
-
end
|
11
|
-
|
12
|
-
bug "http://github.com/jarib/celerity/issues#issue/25", :celerity do
|
13
|
-
describe "with selectors" do
|
14
|
-
it "returns the matching elements" do
|
15
|
-
browser.frames(:name => "frame1").to_a.should == [browser.frame(:class => "frame1")]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "#length" do
|
21
|
-
it "returns the correct number of frames" do
|
22
|
-
browser.frames.length.should == 2
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#[]" do
|
27
|
-
it "returns the frame at the given index" do
|
28
|
-
browser.frames[0].id.should == "frame_1"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "#each" do
|
33
|
-
it "iterates through frames correctly" do
|
34
|
-
count = 0
|
35
|
-
|
36
|
-
browser.frames.each_with_index do |f, index|
|
37
|
-
f.id.should == browser.frame(:index, index).id
|
38
|
-
f.value.should == browser.frame(:index, index).value
|
39
|
-
|
40
|
-
count += 1
|
41
|
-
end
|
42
|
-
|
43
|
-
count.should > 0
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "<iframe> Frames" do
|
49
|
-
|
50
|
-
before :each do
|
51
|
-
browser.goto(WatirSpec.files + "/iframes.html")
|
52
|
-
end
|
53
|
-
|
54
|
-
describe "#length" do
|
55
|
-
it "returns the correct number of frames" do
|
56
|
-
browser.frames.length.should == 2
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe "#[]" do
|
61
|
-
it "returns the frame at the given index" do
|
62
|
-
browser.frames[0].id.should == "frame_1"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe "#each" do
|
67
|
-
it "iterates through frames correctly" do
|
68
|
-
count = 0
|
69
|
-
|
70
|
-
browser.frames.each_with_index do |f, index|
|
71
|
-
f.name.should == browser.frame(:index, index).name
|
72
|
-
f.id.should == browser.frame(:index, index).id
|
73
|
-
f.value.should == browser.frame(:index, index).value
|
74
|
-
|
75
|
-
count += 1
|
76
|
-
end
|
77
|
-
|
78
|
-
count.should > 0
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
@@ -1,103 +0,0 @@
|
|
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, 0).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 false if the element does not exist" do
|
30
|
-
browser.hidden(:id, 'no_such_id').should_not exist
|
31
|
-
browser.hidden(:id, /no_such_id/).should_not exist
|
32
|
-
browser.hidden(:name, 'no_such_name').should_not exist
|
33
|
-
browser.hidden(:name, /no_such_name/).should_not exist
|
34
|
-
browser.hidden(:value, 'no_such_value').should_not exist
|
35
|
-
browser.hidden(:value, /no_such_value/).should_not exist
|
36
|
-
browser.hidden(:text, 'no_such_text').should_not exist
|
37
|
-
browser.hidden(:text, /no_such_text/).should_not exist
|
38
|
-
browser.hidden(:class, 'no_such_class').should_not exist
|
39
|
-
browser.hidden(:class, /no_such_class/).should_not exist
|
40
|
-
browser.hidden(:index, 1337).should_not exist
|
41
|
-
browser.hidden(:xpath, "//input[@id='no_such_id']").should_not exist
|
42
|
-
end
|
43
|
-
|
44
|
-
it "raises TypeError when 'what' argument is invalid" do
|
45
|
-
lambda { browser.hidden(:id, 3.14).exists? }.should raise_error(TypeError)
|
46
|
-
end
|
47
|
-
|
48
|
-
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
49
|
-
lambda { browser.hidden(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
# Attribute methods
|
54
|
-
describe "#id" do
|
55
|
-
it "returns the id attribute if the text field exists" do
|
56
|
-
browser.hidden(:index, 0).id.should == "new_user_interests_dolls"
|
57
|
-
end
|
58
|
-
|
59
|
-
it "raises UnknownObjectException if the text field doesn't exist" do
|
60
|
-
lambda { browser.hidden(:index, 1337).id }.should raise_error(UnknownObjectException)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe "#name" do
|
65
|
-
it "returns the name attribute if the text field exists" do
|
66
|
-
browser.hidden(:index, 0).name.should == "new_user_interests"
|
67
|
-
end
|
68
|
-
|
69
|
-
it "raises UnknownObjectException if the text field doesn't exist" do
|
70
|
-
lambda { browser.hidden(:index, 1337).name }.should raise_error(UnknownObjectException)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe "#type" do
|
75
|
-
it "returns the type attribute if the text field exists" do
|
76
|
-
browser.hidden(:index, 0).type.should == "hidden"
|
77
|
-
end
|
78
|
-
|
79
|
-
it "raises UnknownObjectException if the text field doesn't exist" do
|
80
|
-
lambda { browser.hidden(:index, 1337).type }.should raise_error(UnknownObjectException)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
describe "#value" do
|
85
|
-
it "returns the value attribute if the text field exists" do
|
86
|
-
browser.hidden(:index, 0).value.should == "dolls"
|
87
|
-
end
|
88
|
-
|
89
|
-
it "raises UnknownObjectException if the text field doesn't exist" do
|
90
|
-
lambda { browser.hidden(:index, 1337).value }.should raise_error(UnknownObjectException)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
describe "#respond_to?" do
|
95
|
-
it "returns true for all attribute methods" do
|
96
|
-
browser.hidden(:index, 0).should respond_to(:id)
|
97
|
-
browser.hidden(:index, 0).should respond_to(:name)
|
98
|
-
browser.hidden(:index, 0).should respond_to(:type)
|
99
|
-
browser.hidden(:index, 0).should respond_to(:value)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|
@@ -1,46 +0,0 @@
|
|
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
|
-
bug "http://github.com/jarib/celerity/issues#issue/25", :celerity do
|
11
|
-
describe "with selectors" do
|
12
|
-
it "returns the matching elements" do
|
13
|
-
browser.hiddens(:value => "dolls").to_a.should == [browser.hidden(:value => "dolls")]
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "#length" do
|
19
|
-
it "returns the number of hiddens" do
|
20
|
-
browser.hiddens.length.should == 1
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "#[]" do
|
25
|
-
it "returns the Hidden at the given index" do
|
26
|
-
browser.hiddens[0].id.should == "new_user_interests_dolls"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "#each" do
|
31
|
-
it "iterates through hiddens correctly" do
|
32
|
-
count = 0
|
33
|
-
|
34
|
-
browser.hiddens.each_with_index do |h, index|
|
35
|
-
h.name.should == browser.hidden(:index, index).name
|
36
|
-
h.id.should == browser.hidden(:index, index).id
|
37
|
-
h.value.should == browser.hidden(:index, index).value
|
38
|
-
|
39
|
-
count += 1
|
40
|
-
end
|
41
|
-
|
42
|
-
count.should > 0
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
data/spec/watirspec/hn_spec.rb
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require File.expand_path("../spec_helper", __FILE__)
|
3
|
-
|
4
|
-
describe "H1", "H2", "H3", "H4", "H5", "H6" 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 element exists" do
|
13
|
-
browser.h1(:id, "header1").should exist
|
14
|
-
browser.h2(:id, /header2/).should exist
|
15
|
-
browser.h3(:text, "Header 3").should exist
|
16
|
-
browser.h4(:text, /Header 4/).should exist
|
17
|
-
browser.h5(:index, 0).should exist
|
18
|
-
browser.h6(:index, 0).should exist
|
19
|
-
browser.h1(:xpath, "//h1[@id='first_header']").should exist
|
20
|
-
end
|
21
|
-
|
22
|
-
it "returns the first h1 if given no args" do
|
23
|
-
browser.h1.should exist
|
24
|
-
end
|
25
|
-
|
26
|
-
it "returns true if the element exists" do
|
27
|
-
browser.h1(:id, "no_such_id").should_not exist
|
28
|
-
browser.h1(:id, /no_such_id/).should_not exist
|
29
|
-
browser.h1(:text, "no_such_text").should_not exist
|
30
|
-
browser.h1(:text, /no_such_text 1/).should_not exist
|
31
|
-
browser.h1(:index, 1337).should_not exist
|
32
|
-
browser.h1(:xpath, "//p[@id='no_such_id']").should_not exist
|
33
|
-
end
|
34
|
-
|
35
|
-
it "raises TypeError when 'what' argument is invalid" do
|
36
|
-
lambda { browser.h1(:id, 3.14).exists? }.should raise_error(TypeError)
|
37
|
-
end
|
38
|
-
|
39
|
-
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
40
|
-
lambda { browser.h1(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
# Attribute methods
|
45
|
-
describe "#class_name" do
|
46
|
-
it "returns the class attribute" do
|
47
|
-
browser.h1(:index, 0).class_name.should == 'primary'
|
48
|
-
end
|
49
|
-
|
50
|
-
it "returns an empty string if the element exists and the attribute doesn't" do
|
51
|
-
browser.h2(:index, 0).class_name.should == ''
|
52
|
-
end
|
53
|
-
|
54
|
-
it "raises UnknownObjectException if the p doesn't exist" do
|
55
|
-
lambda { browser.h2(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "#id" do
|
60
|
-
it "returns the id attribute" do
|
61
|
-
browser.h1(:index, 0).id.should == "first_header"
|
62
|
-
end
|
63
|
-
|
64
|
-
it "returns an empty string if the element exists and the attribute doesn't" do
|
65
|
-
browser.h3(:index, 0).id.should == ''
|
66
|
-
end
|
67
|
-
|
68
|
-
it "raises UnknownObjectException if the p doesn't exist" do
|
69
|
-
lambda { browser.h1(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
70
|
-
lambda { browser.h1(:index, 1337).id }.should raise_error(UnknownObjectException)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe "#text" do
|
75
|
-
it "returns the text of the element" do
|
76
|
-
browser.h1(:index, 0).text.should == 'Header 1'
|
77
|
-
end
|
78
|
-
|
79
|
-
it "returns an empty string if the element doesn't contain any text" do
|
80
|
-
browser.h6(:id, "empty_header").text.should == ''
|
81
|
-
end
|
82
|
-
|
83
|
-
it "raises UnknownObjectException if the p doesn't exist" do
|
84
|
-
lambda { browser.h1(:id, 'no_such_id').text }.should raise_error(UnknownObjectException)
|
85
|
-
lambda { browser.h1(:xpath , "//h1[@id='no_such_id']").text }.should raise_error(UnknownObjectException)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
describe "#respond_to?" do
|
90
|
-
it "returns true for all attribute methods" do
|
91
|
-
browser.h1(:index, 0).should respond_to(:class_name)
|
92
|
-
browser.h1(:index, 0).should respond_to(:id)
|
93
|
-
browser.h1(:index, 0).should respond_to(:text)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|