celerity 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +15 -1
- data/Manifest.txt +174 -0
- data/README.txt +19 -10
- data/config/hoe.rb +68 -0
- data/config/requirements.rb +15 -0
- data/lib/celerity.rb +14 -11
- data/lib/celerity/collections.rb +37 -8
- data/lib/celerity/container.rb +100 -3
- data/lib/celerity/disabled_element.rb +4 -2
- data/lib/celerity/element.rb +21 -8
- data/lib/celerity/element_collections.rb +4 -7
- data/lib/celerity/element_locator.rb +1 -0
- data/lib/celerity/elements/button.rb +6 -2
- data/lib/celerity/elements/file_field.rb +1 -1
- data/lib/celerity/elements/form.rb +1 -2
- data/lib/celerity/elements/frame.rb +0 -3
- data/lib/celerity/elements/image.rb +1 -4
- data/lib/celerity/elements/label.rb +1 -0
- data/lib/celerity/elements/link.rb +2 -0
- data/lib/celerity/elements/option.rb +1 -0
- data/lib/celerity/elements/radio_check.rb +3 -5
- data/lib/celerity/elements/select_list.rb +3 -10
- data/lib/celerity/elements/table.rb +8 -22
- data/lib/celerity/elements/table_body.rb +5 -11
- data/lib/celerity/elements/table_cell.rb +1 -0
- data/lib/celerity/elements/table_footer.rb +30 -0
- data/lib/celerity/elements/table_header.rb +30 -0
- data/lib/celerity/elements/table_row.rb +5 -3
- data/lib/celerity/elements/text_field.rb +18 -13
- data/lib/celerity/exception.rb +8 -8
- data/lib/celerity/extra/method_generator.rb +5 -2
- data/lib/celerity/htmlunit/htmlunit-2.2-SNAPSHOT.jar +0 -0
- data/lib/celerity/ie.rb +195 -141
- data/lib/celerity/non_control_elements.rb +30 -4
- data/lib/celerity/version.rb +1 -1
- data/lib/celerity/watir_compatibility.rb +62 -0
- data/setup.rb +0 -2
- data/spec/area_spec.rb +4 -1
- data/spec/areas_spec.rb +1 -1
- data/spec/button_spec.rb +35 -17
- data/spec/buttons_spec.rb +1 -1
- data/spec/checkbox_spec.rb +6 -4
- data/spec/checkboxes_spec.rb +1 -1
- data/spec/div_spec.rb +20 -19
- data/spec/divs_spec.rb +2 -2
- data/spec/element_spec.rb +13 -2
- data/spec/filefield_spec.rb +6 -3
- data/spec/filefields_spec.rb +1 -1
- data/spec/form_spec.rb +4 -1
- data/spec/forms_spec.rb +1 -1
- data/spec/frame_spec.rb +6 -2
- data/spec/hidden_spec.rb +8 -4
- data/spec/hiddens_spec.rb +1 -1
- data/spec/hn_spec.rb +86 -0
- data/spec/hns_spec.rb +41 -0
- data/spec/html/bug_duplicate_attributes.html +14 -0
- data/spec/html/bug_javascript_001.html +11 -0
- data/spec/html/forms_with_input_elements.html +11 -11
- data/spec/html/images.html +18 -15
- data/spec/html/latin1_text.html +16 -0
- data/spec/html/non_control_elements.html +28 -4
- data/spec/html/tables.html +3 -3
- data/spec/html/utf8_text.html +15 -0
- data/spec/htmlunit_spec.rb +27 -0
- data/spec/ie_spec.rb +47 -12
- data/spec/image_spec.rb +4 -7
- data/spec/images_spec.rb +3 -2
- data/spec/label_spec.rb +4 -3
- data/spec/labels_spec.rb +1 -1
- data/spec/li_spec.rb +11 -8
- data/spec/link_spec.rb +5 -1
- data/spec/links_spec.rb +2 -1
- data/spec/lis_spec.rb +3 -2
- data/spec/map_spec.rb +4 -1
- data/spec/maps_spec.rb +1 -1
- data/spec/meta_spec.rb +6 -0
- data/spec/ol_spec.rb +73 -0
- data/spec/ols_spec.rb +41 -0
- data/spec/option_spec.rb +129 -0
- data/spec/p_spec.rb +4 -1
- data/spec/pre_spec.rb +4 -1
- data/spec/pres_spec.rb +1 -1
- data/spec/ps_spec.rb +2 -1
- data/spec/radio_spec.rb +7 -19
- data/spec/radios_spec.rb +1 -1
- data/spec/select_list_spec.rb +19 -57
- data/spec/select_lists_spec.rb +3 -2
- data/spec/span_spec.rb +8 -5
- data/spec/spans_spec.rb +2 -1
- data/spec/spec_helper.rb +8 -43
- data/spec/table_bodies_spec.rb +17 -4
- data/spec/table_body_spec.rb +47 -16
- data/spec/table_cell_spec.rb +5 -3
- data/spec/table_cells_spec.rb +1 -1
- data/spec/table_footer_spec.rb +94 -0
- data/spec/table_footers_spec.rb +53 -0
- data/spec/table_header_spec.rb +94 -0
- data/spec/table_headers_spec.rb +53 -0
- data/spec/table_row_spec.rb +25 -4
- data/spec/table_rows_spec.rb +1 -1
- data/spec/table_spec.rb +22 -2
- data/spec/tables_spec.rb +2 -1
- data/spec/text_field_spec.rb +52 -20
- data/spec/text_fields_spec.rb +1 -1
- data/spec/ul_spec.rb +73 -0
- data/spec/uls_spec.rb +41 -0
- data/spec/watir_compatability_spec.rb +253 -0
- data/support/celerity_viewer/rubycocoa/CelerityViewer.icns +0 -0
- data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/classes.nib +37 -0
- data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/info.nib +19 -0
- data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/keyedobjects.nib +0 -0
- data/support/celerity_viewer/rubycocoa/Info.plist.erb +28 -0
- data/support/celerity_viewer/rubycocoa/MainController.rb +23 -0
- data/support/celerity_viewer/rubycocoa/README +94 -0
- data/support/celerity_viewer/rubycocoa/Rakefile +100 -0
- data/support/celerity_viewer/rubycocoa/distributed_viewer.rb +86 -0
- data/support/celerity_viewer/rubycocoa/main.m +7 -0
- data/support/celerity_viewer/rubycocoa/main.rb +27 -0
- data/support/spec_server.rb +64 -0
- data/tasks/benchmark.rake +1 -0
- data/tasks/rdoc.rake +4 -0
- data/tasks/rspec.rake +10 -3
- data/tasks/simple_ci.rake +94 -0
- data/tasks/specserver.rake +21 -0
- metadata +160 -114
- data/spec/table_bodies.rb +0 -40
- data/tasks/testserver.rake +0 -32
@@ -7,6 +7,8 @@ module Celerity
|
|
7
7
|
#
|
8
8
|
class NonControlElement < Element
|
9
9
|
include Exception
|
10
|
+
ATTRIBUTES = BASE_ATTRIBUTES
|
11
|
+
DEFAULT_HOW = :id
|
10
12
|
|
11
13
|
# Can't use ClickableElement as it does assert_enabled - maybe we don't need the module after all?
|
12
14
|
def click
|
@@ -30,21 +32,45 @@ module Celerity
|
|
30
32
|
class Span < NonControlElement
|
31
33
|
TAGS = [ Identifier.new('span') ]
|
32
34
|
end
|
35
|
+
|
36
|
+
class Ul < NonControlElement
|
37
|
+
TAGS = [ Identifier.new('ul') ]
|
38
|
+
end
|
39
|
+
|
40
|
+
class Ol < NonControlElement
|
41
|
+
TAGS = [ Identifier.new('ol') ]
|
42
|
+
end
|
33
43
|
|
34
44
|
class Li < NonControlElement
|
35
45
|
TAGS = [ Identifier.new('li') ]
|
36
46
|
end
|
37
47
|
|
38
48
|
class Map < NonControlElement
|
39
|
-
# double-check my DTD reading here! :)
|
40
|
-
ATTRIBUTES = BASE_ATTRIBUTES | [:id, :class, :style, :title, :name]
|
41
49
|
TAGS = [ Identifier.new('map') ]
|
42
50
|
end
|
43
51
|
|
44
52
|
class Area < NonControlElement
|
45
|
-
|
46
|
-
ATTRIBUTES = BASE_ATTRIBUTES | [:shape, :coords, :href, :nohref, :alt]
|
53
|
+
ATTRIBUTES = ATTRIBUTES | [:shape, :coords, :href, :nohref, :alt, :tabindex, :accesskey, :onfocus, :onblur]
|
47
54
|
TAGS = [ Identifier.new('area') ]
|
48
55
|
end
|
49
56
|
|
57
|
+
class H1 < NonControlElement
|
58
|
+
TAGS = [ Identifier.new('h1') ]
|
59
|
+
end
|
60
|
+
class H2 < NonControlElement
|
61
|
+
TAGS = [ Identifier.new('h2') ]
|
62
|
+
end
|
63
|
+
class H3 < NonControlElement
|
64
|
+
TAGS = [ Identifier.new('h3') ]
|
65
|
+
end
|
66
|
+
class H4 < NonControlElement
|
67
|
+
TAGS = [ Identifier.new('h4') ]
|
68
|
+
end
|
69
|
+
class H5 < NonControlElement
|
70
|
+
TAGS = [ Identifier.new('h5') ]
|
71
|
+
end
|
72
|
+
class H6 < NonControlElement
|
73
|
+
TAGS = [ Identifier.new('h6') ]
|
74
|
+
end
|
75
|
+
|
50
76
|
end
|
data/lib/celerity/version.rb
CHANGED
@@ -0,0 +1,62 @@
|
|
1
|
+
module Celerity
|
2
|
+
class IE
|
3
|
+
# these are just for Watir compatability - should we keep them?
|
4
|
+
class << self
|
5
|
+
attr_accessor :speed, :attach_timeout, :visible
|
6
|
+
alias_method :start_window, :start
|
7
|
+
def reset_attach_timeout; @attach_timeout = 2.0; end
|
8
|
+
def each; end
|
9
|
+
def quit; end
|
10
|
+
def set_fast_speed; @speed = :fast; end
|
11
|
+
def set_slow_speed; @speed = :slow; end
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_accessor :visible
|
15
|
+
|
16
|
+
def bring_to_front; true; end
|
17
|
+
def speed=(s); end
|
18
|
+
def wait; end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
module ClickableElement
|
23
|
+
alias_method :click_no_wait, :click
|
24
|
+
end
|
25
|
+
|
26
|
+
module Container
|
27
|
+
alias_method :checkbox, :check_box
|
28
|
+
alias_method :checkBox, :check_box
|
29
|
+
alias_method :body, :tbody
|
30
|
+
alias_method :bodies, :tbodies
|
31
|
+
end
|
32
|
+
|
33
|
+
class Image
|
34
|
+
alias_method :hasLoaded?, :loaded?
|
35
|
+
alias_method :has_loaded?, :loaded?
|
36
|
+
alias_method :fileSize, :file_size
|
37
|
+
alias_method :fileCreatedDate, :file_created_date
|
38
|
+
end
|
39
|
+
|
40
|
+
class Link
|
41
|
+
alias_method :click_no_wait, :click
|
42
|
+
end
|
43
|
+
|
44
|
+
class RadioCheckCommon
|
45
|
+
alias_method :is_set?, :set?
|
46
|
+
alias_method :get_state, :set?
|
47
|
+
alias_method :isSet?, :set?
|
48
|
+
alias_method :getState, :set?
|
49
|
+
end
|
50
|
+
|
51
|
+
class SelectList
|
52
|
+
alias_method :getSelectedItems, :get_selected_items
|
53
|
+
alias_method :getAllContents, :get_all_contents
|
54
|
+
alias_method :clearSelection, :clear_selection
|
55
|
+
alias_method :select_value, :select
|
56
|
+
end
|
57
|
+
|
58
|
+
class TextField
|
59
|
+
alias_method :dragContentsTo, :drag_contents_to
|
60
|
+
alias_method :getContents, :get_contents
|
61
|
+
end
|
62
|
+
end
|
data/setup.rb
CHANGED
data/spec/area_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Area do
|
4
4
|
|
5
5
|
before :all do
|
6
6
|
@browser = IE.new
|
@@ -25,6 +25,9 @@ describe "Area" do
|
|
25
25
|
@browser.area(:index, 1).should exist
|
26
26
|
@browser.area(:xpath, "//area[@id='NCE']").should exist
|
27
27
|
end
|
28
|
+
it "should return true if the element exists (default how = :id)" do
|
29
|
+
@browser.area("NCE").should exist
|
30
|
+
end
|
28
31
|
it "should return false if the area doesn't exist" do
|
29
32
|
@browser.area(:id, "no_such_id").should_not exist
|
30
33
|
@browser.area(:id, /no_such_id/).should_not exist
|
data/spec/areas_spec.rb
CHANGED
data/spec/button_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Button do
|
4
4
|
|
5
5
|
before :all do
|
6
6
|
@browser = IE.new
|
@@ -18,10 +18,10 @@ describe "Button" do
|
|
18
18
|
@browser.button(:id, /new_user_submit/).should exist
|
19
19
|
@browser.button(:name, "new_user_reset").should exist
|
20
20
|
@browser.button(:name, /new_user_reset/).should exist
|
21
|
-
# we need to figure out what :text and :value/:caption means on input type="button" and <button /> elements
|
22
|
-
# it should return the value attribute for <input> elements, and the inner text for <button> elements - Jari 2008-05-10
|
23
21
|
@browser.button(:value, "Button 2").should exist
|
24
22
|
@browser.button(:value, /Button 2/).should exist
|
23
|
+
@browser.button(:src, "images/button.jpg").should exist
|
24
|
+
@browser.button(:src, /button.jpg/).should exist
|
25
25
|
@browser.button(:text, "Button 2").should exist
|
26
26
|
@browser.button(:text, /Button 2/).should exist
|
27
27
|
@browser.button(:class, "image").should exist
|
@@ -29,25 +29,22 @@ describe "Button" do
|
|
29
29
|
@browser.button(:index, 1).should exist
|
30
30
|
@browser.button(:xpath, "//input[@id='new_user_submit']").should exist
|
31
31
|
end
|
32
|
-
|
33
32
|
it "should return true if the button exists (how = :caption)" do
|
34
|
-
# we need to figure out what :text and :value/:caption means on input type="button" and <button /> elements
|
35
33
|
@browser.button(:caption, "Button 2").should exist
|
36
34
|
@browser.button(:caption, /Button 2/).should exist
|
37
35
|
end
|
38
|
-
|
39
36
|
it "should return true if the button exists (default how = :value)" do
|
40
37
|
@browser.button("Submit").should exist
|
41
38
|
end
|
42
|
-
|
43
39
|
it "should return false if the button doesn't exist" do
|
44
40
|
@browser.button(:id, "no_such_id").should_not exist
|
45
41
|
@browser.button(:id, /no_such_id/).should_not exist
|
46
42
|
@browser.button(:name, "no_such_name").should_not exist
|
47
43
|
@browser.button(:name, /no_such_name/).should_not exist
|
48
|
-
# we need to figure out what :text and :value/:caption means on input type="button" and <button /> elements
|
49
44
|
@browser.button(:value, "no_such_value").should_not exist
|
50
45
|
@browser.button(:value, /no_such_value/).should_not exist
|
46
|
+
@browser.button(:src, "no_such_src").should_not exist
|
47
|
+
@browser.button(:src, /no_such_src/).should_not exist
|
51
48
|
@browser.button(:text, "no_such_text").should_not exist
|
52
49
|
@browser.button(:text, /no_such_text/).should_not exist
|
53
50
|
@browser.button(:class, "no_such_class").should_not exist
|
@@ -80,7 +77,7 @@ describe "Button" do
|
|
80
77
|
@browser.button(:index, 3).id.should == 'new_user_button'
|
81
78
|
end
|
82
79
|
it "should raise UnknownObjectException if button does not exist" do
|
83
|
-
lambda { @browser.button(:index, 1337).id }.should raise_error(UnknownObjectException)
|
80
|
+
lambda { @browser.button(:index, 1337).id }.should raise_error(UnknownObjectException, 'Unable to locate object, using :index and 1337')
|
84
81
|
end
|
85
82
|
end
|
86
83
|
|
@@ -90,8 +87,29 @@ describe "Button" do
|
|
90
87
|
@browser.button(:index, 2).name.should == 'new_user_reset'
|
91
88
|
@browser.button(:index, 3).name.should == 'new_user_button'
|
92
89
|
end
|
93
|
-
it "should raise UnknownObjectException if button does not exist" do
|
94
|
-
lambda { @browser.button(:name, "no_such_name").name }.should raise_error(UnknownObjectException)
|
90
|
+
it "should raise UnknownObjectException if the button does not exist" do
|
91
|
+
lambda { @browser.button(:name, "no_such_name").name }.should raise_error(UnknownObjectException, 'Unable to locate object, using :name and "no_such_name"')
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "#src" do
|
96
|
+
it "should return the url for the button image" do
|
97
|
+
@browser.button(:name, "new_user_image").src.should == "images/button.jpg"
|
98
|
+
end
|
99
|
+
it "should raise UnknownObjectException if the button does not exist" do
|
100
|
+
lambda { @browser.button(:name, "no_such_name").src }.should raise_error(UnknownObjectException, 'Unable to locate object, using :name and "no_such_name"')
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "#style" do
|
105
|
+
it "should return the style attribute if the button exists" do
|
106
|
+
@browser.button(:id, 'delete_user_submit').style.should == "border: 4px solid red;"
|
107
|
+
end
|
108
|
+
it "should return an empty string if the element exists and the attribute doesn't" do
|
109
|
+
@browser.button(:id, 'new_user_submit').style.should == ""
|
110
|
+
end
|
111
|
+
it "should raise UnknownObjectException if the button does not exist" do
|
112
|
+
lambda { @browser.button(:name, "no_such_name").style }.should raise_error(UnknownObjectException, 'Unable to locate object, using :name and "no_such_name"')
|
95
113
|
end
|
96
114
|
end
|
97
115
|
|
@@ -111,7 +129,7 @@ describe "Button" do
|
|
111
129
|
@browser.button(:index, 3).type.should == 'button'
|
112
130
|
end
|
113
131
|
it "should raise UnknownObjectException if button does not exist" do
|
114
|
-
lambda { @browser.button(:name, "no_such_name").type }.should raise_error(UnknownObjectException)
|
132
|
+
lambda { @browser.button(:name, "no_such_name").type }.should raise_error(UnknownObjectException, 'Unable to locate object, using :name and "no_such_name"')
|
115
133
|
end
|
116
134
|
end
|
117
135
|
|
@@ -122,7 +140,7 @@ describe "Button" do
|
|
122
140
|
@browser.button(:index, 3).value.should == 'Button'
|
123
141
|
end
|
124
142
|
it "should raise UnknownObjectException if button does not exist" do
|
125
|
-
lambda { @browser.button(:name, "no_such_name").value }.should raise_error(UnknownObjectException)
|
143
|
+
lambda { @browser.button(:name, "no_such_name").value }.should raise_error(UnknownObjectException, 'Unable to locate object, using :name and "no_such_name"')
|
126
144
|
end
|
127
145
|
end
|
128
146
|
|
@@ -135,7 +153,7 @@ describe "Button" do
|
|
135
153
|
@browser.button(:name, 'new_user_submit_disabled').should_not be_enabled
|
136
154
|
end
|
137
155
|
it "should raise UnknownObjectException if the button doesn't exist" do
|
138
|
-
lambda { @browser.button(:name, "no_such_name").enabled? }.should raise_error(UnknownObjectException)
|
156
|
+
lambda { @browser.button(:name, "no_such_name").enabled? }.should raise_error(UnknownObjectException, 'Unable to locate object, using :name and "no_such_name"')
|
139
157
|
end
|
140
158
|
end
|
141
159
|
|
@@ -147,7 +165,7 @@ describe "Button" do
|
|
147
165
|
@browser.button(:name, 'new_user_submit_disabled').should be_disabled
|
148
166
|
end
|
149
167
|
it "should raise UnknownObjectException if button does not exist" do
|
150
|
-
lambda { @browser.button(:name, "no_such_name").disabled? }.should raise_error(UnknownObjectException)
|
168
|
+
lambda { @browser.button(:name, "no_such_name").disabled? }.should raise_error(UnknownObjectException, 'Unable to locate object, using :name and "no_such_name"')
|
151
169
|
end
|
152
170
|
end
|
153
171
|
|
@@ -162,8 +180,8 @@ describe "Button" do
|
|
162
180
|
@browser.button(:id, 'new_user_button').value.should == 'new_value_set_by_onclick_event'
|
163
181
|
end
|
164
182
|
it "should raise UnknownObjectException when clicking a button that doesn't exist" do
|
165
|
-
lambda { @browser.button(:value, "no_such_value").click }.should raise_error(UnknownObjectException)
|
166
|
-
lambda { @browser.button(:id, "no_such_id").click }.should raise_error(UnknownObjectException)
|
183
|
+
lambda { @browser.button(:value, "no_such_value").click }.should raise_error(UnknownObjectException, 'Unable to locate object, using :value and "no_such_value"')
|
184
|
+
lambda { @browser.button(:id, "no_such_id").click }.should raise_error(UnknownObjectException, 'Unable to locate object, using :id and "no_such_id"')
|
167
185
|
end
|
168
186
|
it "should raise ObjectDisabledException when clicking a disabled button" do
|
169
187
|
lambda { @browser.button(:value, "Disabled").click }.should raise_error(ObjectDisabledException)
|
data/spec/buttons_spec.rb
CHANGED
data/spec/checkbox_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe CheckBox do
|
4
4
|
|
5
5
|
before :all do
|
6
6
|
@browser = IE.new
|
@@ -22,7 +22,7 @@ describe "Checkbox" do
|
|
22
22
|
@browser.checkbox(:name, /new_user_interests/).should exist
|
23
23
|
@browser.checkbox(:value, "books").should exist
|
24
24
|
@browser.checkbox(:value, /books/).should exist
|
25
|
-
#
|
25
|
+
# not sure what :text is supposed to represent here
|
26
26
|
# @browser.checkbox(:text, "books").should exist
|
27
27
|
# @browser.checkbox(:text, /books/).should exist
|
28
28
|
@browser.checkbox(:class, "fun").should exist
|
@@ -30,7 +30,9 @@ describe "Checkbox" do
|
|
30
30
|
@browser.checkbox(:index, 1).should exist
|
31
31
|
@browser.checkbox(:xpath, "//input[@id='new_user_interests_books']").should exist
|
32
32
|
end
|
33
|
-
|
33
|
+
it "should return true if the element exists (default how = :name)" do
|
34
|
+
@browser.checkbox("new_user_interests").should exist
|
35
|
+
end
|
34
36
|
it "should return true if the checkbox button exists (search by name and value)" do
|
35
37
|
@browser.checkbox(:name, "new_user_interests", 'cars').should exist
|
36
38
|
@browser.checkbox(:xpath, "//input[@name='new_user_interests' and @value='cars']").set
|
@@ -211,7 +213,7 @@ describe "Checkbox" do
|
|
211
213
|
@browser.checkbox(:id, "toggle_button_checkbox").clear
|
212
214
|
@browser.button(:id, "disabled_button").should be_disabled
|
213
215
|
end
|
214
|
-
|
216
|
+
|
215
217
|
it "should raise UnknownObjectException if the checkbox button doesn't exist" do
|
216
218
|
lambda { @browser.checkbox(:name, "no_such_name").set }.should raise_error(UnknownObjectException)
|
217
219
|
lambda { @browser.checkbox(:xpath, "//input[@name='no_such_name']").set }.should raise_error(UnknownObjectException)
|
data/spec/checkboxes_spec.rb
CHANGED
data/spec/div_spec.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Div do
|
4
|
+
|
4
5
|
before :all do
|
5
6
|
@browser = IE.new
|
6
7
|
add_spec_checker(@browser)
|
@@ -25,6 +26,9 @@ describe "Div" do
|
|
25
26
|
@browser.div(:index, 1).should exist
|
26
27
|
@browser.div(:xpath, "//div[@id='header']").should exist
|
27
28
|
end
|
29
|
+
it "should return true if the element exists (default how = :id)" do
|
30
|
+
@browser.div("header").should exist
|
31
|
+
end
|
28
32
|
it "should return false if the element does not exist" do
|
29
33
|
@browser.div(:id, "no_such_id").should_not exist
|
30
34
|
@browser.div(:id, /no_such_id/).should_not exist
|
@@ -83,9 +87,21 @@ describe "Div" do
|
|
83
87
|
@browser.div(:index, 1).name.should == ""
|
84
88
|
end
|
85
89
|
it "should raise UnknownObjectException if the element does not exist" do
|
86
|
-
lambda {@browser.div(:id, "
|
87
|
-
lambda {@browser.div(:title, "
|
88
|
-
lambda {@browser.div(:index,
|
90
|
+
lambda {@browser.div(:id, "no_such_id").name }.should raise_error(UnknownObjectException)
|
91
|
+
lambda {@browser.div(:title, "no_such_title").name }.should raise_error(UnknownObjectException)
|
92
|
+
lambda {@browser.div(:index, 1337).name }.should raise_error(UnknownObjectException)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "#style" do
|
97
|
+
it "should return the style attribute if the element exists" do
|
98
|
+
@browser.div(:id, 'best_language').style.should == "color: red; text-decoration: underline; cursor: pointer;"
|
99
|
+
end
|
100
|
+
it "should return an empty string if the element exists but the attribute doesn't" do
|
101
|
+
@browser.div(:id, 'promo').style.should == ""
|
102
|
+
end
|
103
|
+
it "should raise UnknownObjectException if the element does not exist" do
|
104
|
+
lambda {@browser.div(:id, "no_such_id").style }.should raise_error(UnknownObjectException)
|
89
105
|
end
|
90
106
|
end
|
91
107
|
|
@@ -156,21 +172,6 @@ describe "Div" do
|
|
156
172
|
end
|
157
173
|
end
|
158
174
|
|
159
|
-
# Divs can't be disabled
|
160
|
-
# describe "#disabled?" do
|
161
|
-
# it "should raise UnknownObjectException if the element does not exist" do
|
162
|
-
# lambda {@browser.div(:id , "div77").disabled? }.should raise_error(UnknownObjectException)
|
163
|
-
# lambda {@browser.div(:title , "div77").disabled? }.should raise_error(UnknownObjectException)
|
164
|
-
# lambda {@browser.div(:index , 44).disabled? }.should raise_error(UnknownObjectException)
|
165
|
-
# end
|
166
|
-
#
|
167
|
-
# it "should return false if the element is enabled" do
|
168
|
-
# @browser.div(:index , 2).should_not be_disabled
|
169
|
-
# end
|
170
|
-
#
|
171
|
-
# it "should return true if the element is disabled"
|
172
|
-
# end
|
173
|
-
|
174
175
|
after :all do
|
175
176
|
@browser.close
|
176
177
|
end
|
data/spec/divs_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Divs do
|
4
4
|
before :all do
|
5
5
|
@browser = IE.new
|
6
6
|
add_spec_checker(@browser)
|
@@ -12,7 +12,7 @@ describe "Divs" do
|
|
12
12
|
|
13
13
|
describe "#length" do
|
14
14
|
it "should return the number of divs" do
|
15
|
-
@browser.divs.length.should ==
|
15
|
+
@browser.divs.length.should == 8
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
data/spec/element_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Element do
|
4
4
|
|
5
5
|
before :all do
|
6
6
|
@browser = IE.new
|
@@ -16,7 +16,6 @@ describe "Element" do
|
|
16
16
|
@browser.checkbox(:name => 'new_user_interests', :title => 'Dancing is fun!').value.should == 'dancing'
|
17
17
|
@browser.text_field(:class_name => 'name', :index => 2).id.should == 'new_user_last_name'
|
18
18
|
end
|
19
|
-
|
20
19
|
it "should raise UnknownObjectException with a sane error message when given a hash of :how => 'what' arguments" do
|
21
20
|
conditions = {:index => 100, :name => "foo"}
|
22
21
|
lambda { @browser.text_field(conditions).id }.should raise_error(UnknownObjectException, /Unable to locate object, using (\{:name=>"foo", :index=>100\}|\{:index=>100, :name=>"foo"\})/)
|
@@ -32,6 +31,18 @@ describe "Element" do
|
|
32
31
|
end
|
33
32
|
end
|
34
33
|
|
34
|
+
describe "#html" do
|
35
|
+
it "should return the normative (actual) html for the image element" do
|
36
|
+
@browser.goto(TEST_HOST + "/images.html")
|
37
|
+
@browser.image(:id, 'non_self_closing').html.chomp.should == '<img src="images/1.gif" alt="1" id="non_self_closing"></img>'
|
38
|
+
@browser.goto(TEST_HOST + "/non_control_elements.html")
|
39
|
+
@browser.div(:id, 'html_test').html.chomp.should ==
|
40
|
+
'<div id="html_test" class=some_class title = "This is a title">
|
41
|
+
asdf
|
42
|
+
</div>' #TODO: This expected value might be a little off, whitespace-wise
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
35
46
|
after :all do
|
36
47
|
@browser.close
|
37
48
|
end
|