watir-webdriver 0.0.1.dev6 → 0.0.1.dev7
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -2
- data/VERSION +1 -1
- data/lib/watir-webdriver.rb +1 -4
- data/lib/watir-webdriver/base_element.rb +14 -7
- data/lib/watir-webdriver/browser.rb +3 -1
- data/lib/watir-webdriver/elements/button.rb +1 -0
- data/lib/watir-webdriver/elements/form.rb +1 -1
- data/lib/watir-webdriver/elements/frame.rb +77 -0
- data/lib/watir-webdriver/elements/generated.rb +536 -536
- data/lib/watir-webdriver/elements/option.rb +3 -0
- data/lib/watir-webdriver/elements/table_row.rb +1 -0
- data/lib/watir-webdriver/elements/text_field.rb +5 -1
- data/lib/watir-webdriver/xpath_support.rb +0 -1
- data/spec/base_element_spec.rb +16 -0
- data/spec/html/keylogger.html +15 -0
- data/spec/watirspec/area_spec.rb +78 -0
- data/spec/watirspec/areas_spec.rb +31 -0
- data/spec/watirspec/browser_spec.rb +274 -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 +123 -0
- data/spec/watirspec/dds_spec.rb +31 -0
- data/spec/watirspec/div_spec.rb +211 -0
- data/spec/watirspec/divs_spec.rb +31 -0
- data/spec/watirspec/dl_spec.rb +123 -0
- data/spec/watirspec/dls_spec.rb +32 -0
- data/spec/watirspec/dt_spec.rb +123 -0
- data/spec/watirspec/dts_spec.rb +31 -0
- data/spec/watirspec/element_spec.rb +89 -0
- data/spec/watirspec/em_spec.rb +97 -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/font_spec.rb +26 -0
- data/spec/watirspec/form_spec.rb +63 -0
- data/spec/watirspec/forms_spec.rb +33 -0
- data/spec/watirspec/frame_spec.rb +135 -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 +112 -0
- data/spec/watirspec/lib/guards.rb +59 -0
- data/spec/watirspec/lib/server.rb +136 -0
- data/spec/watirspec/lib/spec_helper.rb +79 -0
- data/spec/watirspec/lib/watirspec.rb +72 -0
- data/spec/watirspec/link_spec.rb +168 -0
- data/spec/watirspec/links_spec.rb +35 -0
- data/spec/watirspec/lis_spec.rb +31 -0
- data/spec/watirspec/map_spec.rb +76 -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 +128 -0
- data/spec/watirspec/pre_spec.rb +112 -0
- data/spec/watirspec/pres_spec.rb +31 -0
- data/spec/watirspec/ps_spec.rb +31 -0
- data/spec/watirspec/radio_spec.rb +255 -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 +142 -0
- data/spec/watirspec/spans_spec.rb +31 -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 +160 -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/support/html5/html5.idl +1 -1
- metadata +181 -21
@@ -0,0 +1,32 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
+
|
4
|
+
describe "CheckBoxes" 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 checkboxes" do
|
12
|
+
browser.checkboxes.length.should == 7
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#[]" do
|
17
|
+
it "returns the checkbox at the given index" do
|
18
|
+
browser.checkboxes[0].id.should == "new_user_interests_books"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#each" do
|
23
|
+
it "iterates through checkboxes correctly" do
|
24
|
+
browser.checkboxes.each_with_index do |c, index|
|
25
|
+
c.name.should == browser.checkbox(:index, index).name
|
26
|
+
c.id.should == browser.checkbox(:index, index).id
|
27
|
+
c.value.should == browser.checkbox(:index, index).value
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
+
|
4
|
+
describe "Dd" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/definition_lists.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
# Exists method
|
11
|
+
describe "#exists?" do
|
12
|
+
it "returns true if the element exists" do
|
13
|
+
browser.dd(:id, "someone").should exist
|
14
|
+
browser.dd(:class, "name").should exist
|
15
|
+
browser.dd(:xpath, "//dd[@id='someone']").should exist
|
16
|
+
browser.dd(:index, 0).should exist
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns false if the element does not exist" do
|
20
|
+
browser.dd(:id, "no_such_id").should_not exist
|
21
|
+
end
|
22
|
+
|
23
|
+
it "raises TypeError when 'what' argument is invalid" do
|
24
|
+
lambda { browser.dd(:id, 3.14).exists? }.should raise_error(TypeError)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
28
|
+
lambda { browser.dd(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Attribute methods
|
33
|
+
describe "#class_name" do
|
34
|
+
it "returns the class attribute if the element exists" do
|
35
|
+
browser.dd(:id, "someone").class_name.should == "name"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns an empty string if the element exists but the attribute doesn't" do
|
39
|
+
browser.dd(:id, "city").class_name.should == ""
|
40
|
+
end
|
41
|
+
|
42
|
+
it "raises UnknownObjectException if the element does not exist" do
|
43
|
+
lambda { browser.dd(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
|
44
|
+
lambda { browser.dd(:title, "no_such_title").class_name }.should raise_error(UnknownObjectException)
|
45
|
+
lambda { browser.dd(:index, 1337).class_name }.should raise_error(UnknownObjectException)
|
46
|
+
lambda { browser.dd(:xpath, "//dd[@id='no_such_id']").class_name }.should raise_error(UnknownObjectException)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "#id" do
|
51
|
+
it "returns the id attribute if the element exists" do
|
52
|
+
browser.dd(:class, 'name').id.should == "someone"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns an empty string if the element exists, but the attribute doesn't" do
|
56
|
+
browser.dd(:class, 'address').id.should == ""
|
57
|
+
end
|
58
|
+
|
59
|
+
it "raises UnknownObjectException if the element does not exist" do
|
60
|
+
lambda {browser.dd(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
61
|
+
lambda {browser.dd(:title, "no_such_id").id }.should raise_error(UnknownObjectException)
|
62
|
+
lambda {browser.dd(:index, 1337).id }.should raise_error(UnknownObjectException)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#title" do
|
67
|
+
it "returns the title of the element" do
|
68
|
+
browser.dd(:class, "name").title.should == "someone"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "#text" do
|
73
|
+
it "returns the text of the element" do
|
74
|
+
browser.dd(:id, "someone").text.should == "John Doe"
|
75
|
+
end
|
76
|
+
|
77
|
+
it "returns an empty string if the element exists but contains no text" do
|
78
|
+
browser.dd(:class, 'noop').text.should == ""
|
79
|
+
end
|
80
|
+
|
81
|
+
it "raises UnknownObjectException if the element does not exist" do
|
82
|
+
lambda { browser.dd(:id, "no_such_id").text }.should raise_error(UnknownObjectException)
|
83
|
+
lambda { browser.dd(:title, "no_such_title").text }.should raise_error(UnknownObjectException)
|
84
|
+
lambda { browser.dd(:index, 1337).text }.should raise_error(UnknownObjectException)
|
85
|
+
lambda { browser.dd(:xpath, "//dd[@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.dd(:index, 0).should respond_to(:id)
|
92
|
+
browser.dd(:index, 0).should respond_to(:class_name)
|
93
|
+
browser.dd(:index, 0).should respond_to(:style)
|
94
|
+
browser.dd(:index, 0).should respond_to(:text)
|
95
|
+
browser.dd(:index, 0).should respond_to(:title)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# Manipulation methods
|
100
|
+
describe "#click" do
|
101
|
+
it "fires events when clicked" do
|
102
|
+
browser.dd(:title, 'education').text.should_not == 'changed'
|
103
|
+
browser.dd(:title, 'education').click
|
104
|
+
browser.dd(:title, 'education').text.should == 'changed'
|
105
|
+
end
|
106
|
+
|
107
|
+
it "raises UnknownObjectException if the element does not exist" do
|
108
|
+
lambda { browser.dd(:id, "no_such_id").click }.should raise_error(UnknownObjectException)
|
109
|
+
lambda { browser.dd(:title, "no_such_title").click }.should raise_error(UnknownObjectException)
|
110
|
+
lambda { browser.dd(:index, 1337).click }.should raise_error(UnknownObjectException)
|
111
|
+
lambda { browser.dd(:xpath, "//dd[@id='no_such_id']").click }.should raise_error(UnknownObjectException)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "#html" do
|
116
|
+
it "returns the HTML of the element" do
|
117
|
+
html = browser.dd(:id, 'someone').html
|
118
|
+
html.should =~ /John Doe/m
|
119
|
+
html.should_not include('</body>')
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
+
|
4
|
+
describe "Dds" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/definition_lists.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#length" do
|
11
|
+
it "returns the number of dds" do
|
12
|
+
browser.dds.length.should == 11
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#[]" do
|
17
|
+
it "returns the dd at the given index" do
|
18
|
+
browser.dds[1].title.should == "education"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#each" do
|
23
|
+
it "iterates through dds correctly" do
|
24
|
+
browser.dds.each_with_index do |d, index|
|
25
|
+
d.id.should == browser.dd(:index, index).id
|
26
|
+
d.class_name.should == browser.dd(:index, index).class_name
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,211 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
+
|
4
|
+
describe "Div" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
# Exists method
|
11
|
+
describe "#exists?" do
|
12
|
+
it "returns true if the element exists" do
|
13
|
+
browser.div(:id, "header").should exist
|
14
|
+
browser.div(:id, /header/).should exist
|
15
|
+
browser.div(:title, "Header and primary navigation").should exist
|
16
|
+
browser.div(:title, /Header and primary navigation/).should exist
|
17
|
+
browser.div(:text, "This is a footer.").should exist
|
18
|
+
browser.div(:text, /This is a footer\./).should exist
|
19
|
+
browser.div(:class, "profile").should exist
|
20
|
+
browser.div(:class, /profile/).should exist
|
21
|
+
browser.div(:index, 0).should exist
|
22
|
+
browser.div(:xpath, "//div[@id='header']").should exist
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns false if the element does not exist" do
|
26
|
+
browser.div(:id, "no_such_id").should_not exist
|
27
|
+
browser.div(:id, /no_such_id/).should_not exist
|
28
|
+
browser.div(:title, "no_such_title").should_not exist
|
29
|
+
browser.div(:title, /no_such_title/).should_not exist
|
30
|
+
browser.div(:text, "no_such_text").should_not exist
|
31
|
+
browser.div(:text, /no_such_text/).should_not exist
|
32
|
+
browser.div(:class, "no_such_class").should_not exist
|
33
|
+
browser.div(:class, /no_such_class/).should_not exist
|
34
|
+
browser.div(:index, 1337).should_not exist
|
35
|
+
browser.div(:xpath, "//div[@id='no_such_id']").should_not exist
|
36
|
+
end
|
37
|
+
|
38
|
+
it "raises TypeError when 'what' argument is invalid" do
|
39
|
+
lambda { browser.div(:id, 3.14).exists? }.should raise_error(TypeError)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
43
|
+
lambda { browser.div(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
44
|
+
end
|
45
|
+
|
46
|
+
# it "locates the correct button when there are duplicate ids and user disambiguates by parent" do
|
47
|
+
# browser.goto(WatirSpec.files + "/buttons_with_duplicate_ids.html")
|
48
|
+
# browser.form(:name, "bar-form").div(:id, "name").parent.name.should == "bar-form"
|
49
|
+
# end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
# Attribute methods
|
54
|
+
describe "#class_name" do
|
55
|
+
it "returns the class attribute if the element exists" do
|
56
|
+
browser.div(:id , "footer").class_name.should == "profile"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "returns an empty string if the element exists but the attribute doesn't" do
|
60
|
+
browser.div(:id , "content").class_name.should == ""
|
61
|
+
end
|
62
|
+
|
63
|
+
it "raises UnknownObjectException if the element does not exist" do
|
64
|
+
lambda { browser.div(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
|
65
|
+
lambda { browser.div(:title, "no_such_title").class_name }.should raise_error(UnknownObjectException)
|
66
|
+
lambda { browser.div(:index, 1337).class_name }.should raise_error(UnknownObjectException)
|
67
|
+
lambda { browser.div(:xpath, "//div[@id='no_such_id']").class_name }.should raise_error(UnknownObjectException)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "#id" do
|
72
|
+
it "returns the id attribute if the element exists" do
|
73
|
+
browser.div(:index, 1).id.should == "outer_container"
|
74
|
+
end
|
75
|
+
|
76
|
+
it "returns an empty string if the element exists, but the attribute doesn't" do
|
77
|
+
browser.div(:index, 0).id.should == ""
|
78
|
+
end
|
79
|
+
|
80
|
+
it "raises UnknownObjectException if the element does not exist" do
|
81
|
+
lambda { browser.div(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
82
|
+
lambda { browser.div(:title, "no_such_id").id }.should raise_error(UnknownObjectException)
|
83
|
+
lambda { browser.div(:index, 1337).id }.should raise_error(UnknownObjectException)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should take all conditions into account when locating by id" do
|
87
|
+
browser.goto "#{WatirSpec.files}/multiple_ids.html"
|
88
|
+
browser.div(:id => "multiple", :class => "bar").class_name.should == "bar"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "#style" do
|
93
|
+
not_compliant_on :watir do
|
94
|
+
it "returns the style attribute if the element exists" do
|
95
|
+
browser.div(:id, 'best_language').style.should == "color: red; text-decoration: underline; cursor: pointer;"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
deviates_on :watir do
|
100
|
+
it "returns the style attribute if the element exists" do
|
101
|
+
# just different order and missing semicolon here
|
102
|
+
browser.div(:id, 'best_language').style.should == "cursor: pointer; color: red; text-decoration: underline"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
it "returns an empty string if the element exists but the attribute doesn't" do
|
107
|
+
browser.div(:id, 'promo').style.should == ""
|
108
|
+
end
|
109
|
+
|
110
|
+
it "raises UnknownObjectException if the element does not exist" do
|
111
|
+
lambda {browser.div(:id, "no_such_id").style }.should raise_error(UnknownObjectException)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "#text" do
|
116
|
+
it "returns the text of the div" do
|
117
|
+
browser.div(:id, "footer").text.strip.should == "This is a footer."
|
118
|
+
browser.div(:title, "Closing remarks").text.strip.should == "This is a footer."
|
119
|
+
browser.div(:xpath, "//div[@id='footer']").text.strip.should == "This is a footer."
|
120
|
+
end
|
121
|
+
|
122
|
+
it "returns an empty string if the element exists but contains no text" do
|
123
|
+
browser.div(:index, 0).text.strip.should == ""
|
124
|
+
end
|
125
|
+
|
126
|
+
deviates_on :celerity do
|
127
|
+
it "returns an empty string if the div is hidden" do
|
128
|
+
browser.div(:id, 'hidden').text.should == ""
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
it "raises UnknownObjectException if the element does not exist" do
|
133
|
+
lambda { browser.div(:id, "no_such_id").text }.should raise_error(UnknownObjectException)
|
134
|
+
lambda { browser.div(:title, "no_such_title").text }.should raise_error(UnknownObjectException)
|
135
|
+
lambda { browser.div(:index, 1337).text }.should raise_error(UnknownObjectException)
|
136
|
+
lambda { browser.div(:xpath, "//div[@id='no_such_id']").text }.should raise_error(UnknownObjectException)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe "#value" do
|
141
|
+
it "returns the value attribute if the element exists" do
|
142
|
+
browser.div(:id, 'promo').value.should == "invalid_attribute"
|
143
|
+
end
|
144
|
+
|
145
|
+
it "returns an empty string if the element exists but the attribute doesn't" do
|
146
|
+
browser.div(:index, 0).value.should == ""
|
147
|
+
end
|
148
|
+
|
149
|
+
it "raises UnknownObjectException if the element does not exist" do
|
150
|
+
lambda {browser.div(:id, "no_such_id").value }.should raise_error(UnknownObjectException)
|
151
|
+
lambda {browser.div(:title, "no_such_title").value }.should raise_error(UnknownObjectException)
|
152
|
+
lambda {browser.div(:index, 1337).value }.should raise_error(UnknownObjectException)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe "#respond_to?" do
|
157
|
+
it "returns true for all attribute methods" do
|
158
|
+
browser.div(:index, 0).should respond_to(:class_name)
|
159
|
+
browser.div(:index, 0).should respond_to(:id)
|
160
|
+
browser.div(:index, 0).should respond_to(:style)
|
161
|
+
browser.div(:index, 0).should respond_to(:text)
|
162
|
+
browser.div(:index, 0).should respond_to(:value)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
# Manipulation methods
|
167
|
+
describe "#click" do
|
168
|
+
it "fires events when clicked" do
|
169
|
+
browser.div(:id, 'best_language').text.should_not == 'Ruby!'
|
170
|
+
browser.div(:id, 'best_language').click
|
171
|
+
browser.div(:id, 'best_language').text.should == 'Ruby!'
|
172
|
+
end
|
173
|
+
|
174
|
+
it "raises UnknownObjectException if the element does not exist" do
|
175
|
+
lambda { browser.div(:id, "no_such_id").click }.should raise_error(UnknownObjectException)
|
176
|
+
lambda { browser.div(:title, "no_such_title").click }.should raise_error(UnknownObjectException)
|
177
|
+
lambda { browser.div(:index, 1337).click }.should raise_error(UnknownObjectException)
|
178
|
+
lambda { browser.div(:xpath, "//div[@id='no_such_id']").click }.should raise_error(UnknownObjectException)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
not_compliant_on :watir, :webdriver do
|
183
|
+
describe "#double_click" do
|
184
|
+
it "fires the ondblclick event" do
|
185
|
+
browser.div(:id, 'html_test').double_click
|
186
|
+
messages.should include('double clicked')
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
describe "#right_click" do
|
191
|
+
it "fires the oncontextmenu event" do
|
192
|
+
browser.goto(WatirSpec.files + "/right_click.html")
|
193
|
+
browser.div(:id, "click").right_click
|
194
|
+
messages.first.should == 'right-clicked'
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
describe "#html" do
|
200
|
+
it "returns the HTML of the element" do
|
201
|
+
html = browser.div(:id, 'footer').html.downcase
|
202
|
+
html.should include('id="footer"')
|
203
|
+
html.should include('title="closing remarks"')
|
204
|
+
html.should include('class="profile"')
|
205
|
+
|
206
|
+
html.should_not include('<div id="content">')
|
207
|
+
html.should_not include('</body>')
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
+
|
4
|
+
describe "Divs" 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 divs" do
|
12
|
+
browser.divs.length.should == 10
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#[]" do
|
17
|
+
it "returns the div at the given index" do
|
18
|
+
browser.divs[1].id.should == "outer_container"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#each" do
|
23
|
+
it "iterates through divs correctly" do
|
24
|
+
browser.divs.each_with_index do |d, index|
|
25
|
+
d.id.should == browser.div(:index, index).id
|
26
|
+
d.class_name.should == browser.div(:index, index).class_name
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
+
|
4
|
+
describe "Dl" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/definition_lists.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
# Exists method
|
11
|
+
describe "#exists?" do
|
12
|
+
it "returns true if the element exists" do
|
13
|
+
browser.dl(:id, "experience-list").should exist
|
14
|
+
browser.dl(:class, "list").should exist
|
15
|
+
browser.dl(:xpath, "//dl[@id='experience-list']").should exist
|
16
|
+
browser.dl(:index, 0).should exist
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns false if the element does not exist" do
|
20
|
+
browser.dl(:id, "no_such_id").should_not exist
|
21
|
+
end
|
22
|
+
|
23
|
+
it "raises TypeError when 'what' argument is invalid" do
|
24
|
+
lambda { browser.dl(:id, 3.14).exists? }.should raise_error(TypeError)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
28
|
+
lambda { browser.dl(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Attribute methods
|
33
|
+
describe "#class_name" do
|
34
|
+
it "returns the class attribute if the element exists" do
|
35
|
+
browser.dl(:id , "experience-list").class_name.should == "list"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns an empty string if the element exists but the attribute doesn't" do
|
39
|
+
browser.dl(:id , "noop").class_name.should == ""
|
40
|
+
end
|
41
|
+
|
42
|
+
it "raises UnknownObjectException if the element does not exist" do
|
43
|
+
lambda { browser.dl(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
|
44
|
+
lambda { browser.dl(:title, "no_such_title").class_name }.should raise_error(UnknownObjectException)
|
45
|
+
lambda { browser.dl(:index, 1337).class_name }.should raise_error(UnknownObjectException)
|
46
|
+
lambda { browser.dl(:xpath, "//dl[@id='no_such_id']").class_name }.should raise_error(UnknownObjectException)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "#id" do
|
51
|
+
it "returns the id attribute if the element exists" do
|
52
|
+
browser.dl(:class, 'list').id.should == "experience-list"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns an empty string if the element exists, but the attribute doesn't" do
|
56
|
+
browser.dl(:class, 'personalia').id.should == ""
|
57
|
+
end
|
58
|
+
|
59
|
+
it "raises UnknownObjectException if the element does not exist" do
|
60
|
+
lambda {browser.dl(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
61
|
+
lambda {browser.dl(:title, "no_such_id").id }.should raise_error(UnknownObjectException)
|
62
|
+
lambda {browser.dl(:index, 1337).id }.should raise_error(UnknownObjectException)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#title" do
|
67
|
+
it "returns the id attribute if the element exists" do
|
68
|
+
browser.dl(:class, 'list').title.should == "experience"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "#text" do
|
73
|
+
it "returns the text of the element" do
|
74
|
+
browser.dl(:id, "experience-list").text.should include("11 years")
|
75
|
+
end
|
76
|
+
|
77
|
+
it "returns an empty string if the element exists but contains no text" do
|
78
|
+
browser.dl(:id, 'noop').text.should == ""
|
79
|
+
end
|
80
|
+
|
81
|
+
it "raises UnknownObjectException if the element does not exist" do
|
82
|
+
lambda { browser.dl(:id, "no_such_id").text }.should raise_error(UnknownObjectException)
|
83
|
+
lambda { browser.dl(:title, "no_such_title").text }.should raise_error(UnknownObjectException)
|
84
|
+
lambda { browser.dl(:index, 1337).text }.should raise_error(UnknownObjectException)
|
85
|
+
lambda { browser.dl(:xpath, "//dl[@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.dl(:index, 0).should respond_to(:id)
|
92
|
+
browser.dl(:index, 0).should respond_to(:class_name)
|
93
|
+
browser.dl(:index, 0).should respond_to(:style)
|
94
|
+
browser.dl(:index, 0).should respond_to(:text)
|
95
|
+
browser.dl(:index, 0).should respond_to(:title)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# Manipulation methods
|
100
|
+
describe "#click" do
|
101
|
+
it "fires events when clicked" do
|
102
|
+
browser.dt(:id, 'name').text.should_not == 'changed!'
|
103
|
+
browser.dt(:id, 'name').click
|
104
|
+
browser.dt(:id, 'name').text.should == 'changed!'
|
105
|
+
end
|
106
|
+
|
107
|
+
it "raises UnknownObjectException if the element does not exist" do
|
108
|
+
lambda { browser.dl(:id, "no_such_id").click }.should raise_error(UnknownObjectException)
|
109
|
+
lambda { browser.dl(:title, "no_such_title").click }.should raise_error(UnknownObjectException)
|
110
|
+
lambda { browser.dl(:index, 1337).click }.should raise_error(UnknownObjectException)
|
111
|
+
lambda { browser.dl(:xpath, "//dl[@id='no_such_id']").click }.should raise_error(UnknownObjectException)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "#html" do
|
116
|
+
it "returns the HTML of the element" do
|
117
|
+
html = browser.dl(:id, 'experience-list').html.downcase
|
118
|
+
html.should include('<dt class="current-industry">')
|
119
|
+
html.should_not include('</body>')
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|