celerity 0.0.1 → 0.0.2

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.
Files changed (93) hide show
  1. data/History.txt +10 -0
  2. data/README.txt +8 -11
  3. data/Rakefile +5 -3
  4. data/benchmark/bm_2000_spans.rb +48 -0
  5. data/benchmark/bm_digg.rb +26 -0
  6. data/benchmark/bm_google_images.rb +36 -0
  7. data/benchmark/bm_input_locator.rb +69 -0
  8. data/benchmark/loader.rb +9 -0
  9. data/lib/celerity.rb +3 -1
  10. data/lib/celerity/container.rb +23 -171
  11. data/lib/celerity/disabled_element.rb +1 -1
  12. data/lib/celerity/element.rb +78 -47
  13. data/lib/celerity/element_collections.rb +16 -32
  14. data/lib/celerity/element_locator.rb +135 -0
  15. data/lib/celerity/elements/button.rb +15 -0
  16. data/lib/celerity/elements/file_field.rb +1 -1
  17. data/lib/celerity/elements/form.rb +2 -1
  18. data/lib/celerity/elements/frame.rb +18 -21
  19. data/lib/celerity/elements/image.rb +2 -8
  20. data/lib/celerity/elements/label.rb +1 -3
  21. data/lib/celerity/elements/link.rb +1 -1
  22. data/lib/celerity/elements/option.rb +16 -0
  23. data/lib/celerity/elements/radio_check.rb +18 -7
  24. data/lib/celerity/elements/select_list.rb +1 -17
  25. data/lib/celerity/elements/table.rb +4 -4
  26. data/lib/celerity/elements/table_body.rb +6 -8
  27. data/lib/celerity/elements/table_cell.rb +3 -14
  28. data/lib/celerity/elements/table_row.rb +4 -10
  29. data/lib/celerity/elements/text_field.rb +16 -4
  30. data/lib/celerity/extra/method_generator.rb +144 -0
  31. data/lib/celerity/identifier.rb +10 -0
  32. data/lib/celerity/ie.rb +28 -13
  33. data/lib/celerity/input_element.rb +0 -4
  34. data/lib/celerity/non_control_elements.rb +12 -12
  35. data/lib/celerity/version.rb +1 -1
  36. data/spec/area_spec.rb +41 -41
  37. data/spec/areas_spec.rb +11 -11
  38. data/spec/button_spec.rb +73 -68
  39. data/spec/buttons_spec.rb +10 -10
  40. data/spec/checkbox_spec.rb +102 -96
  41. data/spec/checkboxes_spec.rb +10 -10
  42. data/spec/div_spec.rb +78 -73
  43. data/spec/divs_spec.rb +10 -10
  44. data/spec/element_spec.rb +20 -11
  45. data/spec/filefield_spec.rb +36 -41
  46. data/spec/filefields_spec.rb +10 -10
  47. data/spec/form_spec.rb +29 -29
  48. data/spec/forms_spec.rb +11 -11
  49. data/spec/frame_spec.rb +54 -49
  50. data/spec/hidden_spec.rb +43 -43
  51. data/spec/hiddens_spec.rb +10 -10
  52. data/spec/html/2000_spans.html +2009 -0
  53. data/spec/html/forms_with_input_elements.html +15 -9
  54. data/spec/html/non_control_elements.html +4 -2
  55. data/spec/ie_spec.rb +82 -48
  56. data/spec/image_spec.rb +83 -100
  57. data/spec/images_spec.rb +10 -10
  58. data/spec/label_spec.rb +29 -29
  59. data/spec/labels_spec.rb +10 -10
  60. data/spec/li_spec.rb +41 -41
  61. data/spec/link_spec.rb +65 -59
  62. data/spec/links_spec.rb +11 -11
  63. data/spec/lis_spec.rb +10 -10
  64. data/spec/map_spec.rb +30 -30
  65. data/spec/maps_spec.rb +10 -10
  66. data/spec/p_spec.rb +49 -49
  67. data/spec/pre_spec.rb +41 -41
  68. data/spec/pres_spec.rb +10 -10
  69. data/spec/ps_spec.rb +10 -10
  70. data/spec/radio_spec.rb +104 -97
  71. data/spec/radios_spec.rb +11 -11
  72. data/spec/select_list_spec.rb +118 -106
  73. data/spec/select_lists_spec.rb +15 -15
  74. data/spec/span_spec.rb +54 -54
  75. data/spec/spans_spec.rb +11 -11
  76. data/spec/spec.opts +1 -1
  77. data/spec/spec_helper.rb +23 -3
  78. data/spec/table_bodies.rb +8 -8
  79. data/spec/table_bodies_spec.rb +9 -9
  80. data/spec/table_body_spec.rb +28 -27
  81. data/spec/table_cell_spec.rb +25 -25
  82. data/spec/table_cells_spec.rb +16 -16
  83. data/spec/table_row_spec.rb +16 -16
  84. data/spec/table_rows_spec.rb +12 -12
  85. data/spec/table_spec.rb +36 -36
  86. data/spec/tables_spec.rb +12 -12
  87. data/spec/text_field_spec.rb +111 -92
  88. data/spec/text_fields_spec.rb +13 -13
  89. data/tasks/benchmark.rake +3 -0
  90. data/tasks/rspec.rake +2 -2
  91. data/tasks/testserver.rake +15 -0
  92. metadata +58 -46
  93. data/tasks/simple_ci.rake +0 -94
data/spec/div_spec.rb CHANGED
@@ -2,140 +2,144 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
3
  describe "Div" do
4
4
  before :all do
5
- @ie = IE.new
6
- add_spec_checker(@ie)
5
+ @browser = IE.new
6
+ add_spec_checker(@browser)
7
7
  end
8
8
 
9
9
  before :each do
10
- @ie.goto(TEST_HOST + "/non_control_elements.html")
10
+ @browser.goto(TEST_HOST + "/non_control_elements.html")
11
11
  end
12
12
 
13
13
 
14
14
  # Exists method
15
15
  describe "#exists?" do
16
16
  it "should return true if the element exists" do
17
- @ie.div(:id, "header").should exist
18
- @ie.div(:id, /header/).should exist
19
- @ie.div(:title, "Header and primary navigation").should exist
20
- @ie.div(:title, /Header and primary navigation/).should exist
21
- @ie.div(:text, "This is a footer.").should exist
22
- @ie.div(:text, /This is a footer\./).should exist
23
- @ie.div(:class, "profile").should exist
24
- @ie.div(:class, /profile/).should exist
25
- @ie.div(:index, 1).should exist
26
- @ie.div(:xpath, "//div[@id='header']").should exist
17
+ @browser.div(:id, "header").should exist
18
+ @browser.div(:id, /header/).should exist
19
+ @browser.div(:title, "Header and primary navigation").should exist
20
+ @browser.div(:title, /Header and primary navigation/).should exist
21
+ @browser.div(:text, "This is a footer.").should exist
22
+ @browser.div(:text, /This is a footer\./).should exist
23
+ @browser.div(:class, "profile").should exist
24
+ @browser.div(:class, /profile/).should exist
25
+ @browser.div(:index, 1).should exist
26
+ @browser.div(:xpath, "//div[@id='header']").should exist
27
27
  end
28
28
  it "should return false if the element does not exist" do
29
- @ie.div(:id, "no_such_id").should_not exist
30
- @ie.div(:id, /no_such_id/).should_not exist
31
- @ie.div(:title, "no_such_title").should_not exist
32
- @ie.div(:title, /no_such_title/).should_not exist
33
- @ie.div(:text, "no_such_text").should_not exist
34
- @ie.div(:text, /no_such_text/).should_not exist
35
- @ie.div(:class, "no_such_class").should_not exist
36
- @ie.div(:class, /no_such_class/).should_not exist
37
- @ie.div(:index, 1337).should_not exist
38
- @ie.div(:xpath, "//div[@id='no_such_id']").should_not exist
29
+ @browser.div(:id, "no_such_id").should_not exist
30
+ @browser.div(:id, /no_such_id/).should_not exist
31
+ @browser.div(:title, "no_such_title").should_not exist
32
+ @browser.div(:title, /no_such_title/).should_not exist
33
+ @browser.div(:text, "no_such_text").should_not exist
34
+ @browser.div(:text, /no_such_text/).should_not exist
35
+ @browser.div(:class, "no_such_class").should_not exist
36
+ @browser.div(:class, /no_such_class/).should_not exist
37
+ @browser.div(:index, 1337).should_not exist
38
+ @browser.div(:xpath, "//div[@id='no_such_id']").should_not exist
39
39
  end
40
- it "should raise ArgumentError when what argument is invalid" do
41
- lambda { @ie.div(:id, 3.14).exists? }.should raise_error(ArgumentError)
40
+ it "should raise ArgumentError when 'what' argument is invalid" do
41
+ lambda { @browser.div(:id, 3.14).exists? }.should raise_error(ArgumentError)
42
42
  end
43
- it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
44
- lambda { @ie.div(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
43
+ it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
44
+ lambda { @browser.div(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
45
45
  end
46
46
  end
47
47
 
48
48
  # Attribute methods
49
49
  describe "#class_name" do
50
50
  it "should return the class attribute if the element exists" do
51
- @ie.div(:id , "footer").class_name.should == "profile"
51
+ @browser.div(:id , "footer").class_name.should == "profile"
52
52
  end
53
53
  it "should return an empty string if the element exists but the attribute doesn't" do
54
- @ie.div(:id , "content").class_name.should == ""
54
+ @browser.div(:id , "content").class_name.should == ""
55
55
  end
56
56
  it "should raise UnknownObjectException if the element does not exist" do
57
- lambda { @ie.div(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
58
- lambda { @ie.div(:title, "no_such_title").class_name }.should raise_error(UnknownObjectException)
59
- lambda { @ie.div(:index, 1337).class_name }.should raise_error(UnknownObjectException)
60
- lambda { @ie.div(:xpath, "//div[@id='no_such_id']").class_name }.should raise_error(UnknownObjectException)
57
+ lambda { @browser.div(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
58
+ lambda { @browser.div(:title, "no_such_title").class_name }.should raise_error(UnknownObjectException)
59
+ lambda { @browser.div(:index, 1337).class_name }.should raise_error(UnknownObjectException)
60
+ lambda { @browser.div(:xpath, "//div[@id='no_such_id']").class_name }.should raise_error(UnknownObjectException)
61
61
  end
62
62
  end
63
63
 
64
64
  describe "#id" do
65
65
  it "should return the id attribute if the element exists" do
66
- @ie.div(:index, 2).id.should == "outer_container"
66
+ @browser.div(:index, 2).id.should == "outer_container"
67
67
  end
68
68
  it "should return an empty string if the element exists, but the attribute doesn't" do
69
- @ie.div(:index, 1).id.should == ""
69
+ @browser.div(:index, 1).id.should == ""
70
70
  end
71
71
  it "should raise UnknownObjectException if the element does not exist" do
72
- lambda {@ie.div(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
73
- lambda {@ie.div(:title, "no_such_id").id }.should raise_error(UnknownObjectException)
74
- lambda {@ie.div(:index, 1337).id }.should raise_error(UnknownObjectException)
72
+ lambda {@browser.div(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
73
+ lambda {@browser.div(:title, "no_such_id").id }.should raise_error(UnknownObjectException)
74
+ lambda {@browser.div(:index, 1337).id }.should raise_error(UnknownObjectException)
75
75
  end
76
76
  end
77
77
 
78
78
  describe "#name" do
79
79
  it "should return the name attribute if the element exists" do
80
- @ie.div(:id, 'promo').name.should == "invalid_attribute"
80
+ @browser.div(:id, 'promo').name.should == "invalid_attribute"
81
81
  end
82
82
  it "should return an empty string if the element exists but the attribute doesn't" do
83
- @ie.div(:index, 1).name.should == ""
83
+ @browser.div(:index, 1).name.should == ""
84
84
  end
85
85
  it "should raise UnknownObjectException if the element does not exist" do
86
- lambda {@ie.div(:id, "div77").name }.should raise_error(UnknownObjectException)
87
- lambda {@ie.div(:title, "div77").name }.should raise_error(UnknownObjectException)
88
- lambda {@ie.div(:index, 44).name }.should raise_error(UnknownObjectException)
86
+ lambda {@browser.div(:id, "div77").name }.should raise_error(UnknownObjectException)
87
+ lambda {@browser.div(:title, "div77").name }.should raise_error(UnknownObjectException)
88
+ lambda {@browser.div(:index, 44).name }.should raise_error(UnknownObjectException)
89
89
  end
90
90
  end
91
91
 
92
92
  describe "#text" do
93
93
  it "should return the text of the div" do
94
- @ie.div(:id, "footer").text.strip.should == "This is a footer."
95
- @ie.div(:title, "Closing remarks").text.strip.should == "This is a footer."
96
- @ie.div(:xpath, "//div[@id='footer']").text.strip.should == "This is a footer."
94
+ @browser.div(:id, "footer").text.strip.should == "This is a footer."
95
+ @browser.div(:title, "Closing remarks").text.strip.should == "This is a footer."
96
+ @browser.div(:xpath, "//div[@id='footer']").text.strip.should == "This is a footer."
97
97
  end
98
98
  it "should return an empty string if the element exists but contains no text" do
99
- @ie.div(:index, 1).text.strip.should == ""
99
+ @browser.div(:index, 1).text.strip.should == ""
100
100
  end
101
101
  it "should raise UnknownObjectException if the element does not exist" do
102
- lambda { @ie.div(:id, "no_such_id").text }.should raise_error(UnknownObjectException)
103
- lambda { @ie.div(:title, "no_such_title").text }.should raise_error(UnknownObjectException)
104
- lambda { @ie.div(:index, 1337).text }.should raise_error(UnknownObjectException)
105
- lambda { @ie.div(:xpath, "//div[@id='no_such_id']").text }.should raise_error(UnknownObjectException)
102
+ lambda { @browser.div(:id, "no_such_id").text }.should raise_error(UnknownObjectException)
103
+ lambda { @browser.div(:title, "no_such_title").text }.should raise_error(UnknownObjectException)
104
+ lambda { @browser.div(:index, 1337).text }.should raise_error(UnknownObjectException)
105
+ lambda { @browser.div(:xpath, "//div[@id='no_such_id']").text }.should raise_error(UnknownObjectException)
106
106
  end
107
107
  end
108
108
 
109
109
  describe "#value" do
110
110
  it "should return the value attribute if the element exists" do
111
- @ie.div(:id, 'promo').value.should == "invalid_attribute"
111
+ @browser.div(:id, 'promo').value.should == "invalid_attribute"
112
112
  end
113
113
  it "should return an empty string if the element exists but the attribute doesn't" do
114
- @ie.div(:index, 1).value.should == ""
114
+ @browser.div(:index, 1).value.should == ""
115
115
  end
116
116
  it "should raise UnknownObjectException if the element does not exist" do
117
- lambda {@ie.div(:id, "no_such_id").value }.should raise_error(UnknownObjectException)
118
- lambda {@ie.div(:title, "no_such_title").value }.should raise_error(UnknownObjectException)
119
- lambda {@ie.div(:index, 1337).value }.should raise_error(UnknownObjectException)
117
+ lambda {@browser.div(:id, "no_such_id").value }.should raise_error(UnknownObjectException)
118
+ lambda {@browser.div(:title, "no_such_title").value }.should raise_error(UnknownObjectException)
119
+ lambda {@browser.div(:index, 1337).value }.should raise_error(UnknownObjectException)
120
120
  end
121
121
  end
122
122
 
123
123
  # Manipulation methods
124
124
  describe "#click" do
125
- it "should fire events when clicked"
125
+ it "should fire events when clicked" do
126
+ @browser.div(:id, 'best_language').text.should_not == 'Ruby!'
127
+ @browser.div(:id, 'best_language').click
128
+ @browser.div(:id, 'best_language').text.should == 'Ruby!'
129
+ end
126
130
  it "should raise UnknownObjectException if the element does not exist" do
127
- lambda { @ie.div(:id, "no_such_id").click }.should raise_error(UnknownObjectException)
128
- lambda { @ie.div(:title, "no_such_title").click }.should raise_error(UnknownObjectException)
129
- lambda { @ie.div(:index, 1337).click }.should raise_error(UnknownObjectException)
130
- lambda { @ie.div(:xpath, "//div[@id='no_such_id']").click }.should raise_error(UnknownObjectException)
131
+ lambda { @browser.div(:id, "no_such_id").click }.should raise_error(UnknownObjectException)
132
+ lambda { @browser.div(:title, "no_such_title").click }.should raise_error(UnknownObjectException)
133
+ lambda { @browser.div(:index, 1337).click }.should raise_error(UnknownObjectException)
134
+ lambda { @browser.div(:xpath, "//div[@id='no_such_id']").click }.should raise_error(UnknownObjectException)
131
135
  end
132
136
  end
133
137
 
134
138
  describe "#html" do
135
139
  it "should return the HTML of the element" do
136
- html = @ie.div(:id, 'footer').html
140
+ html = @browser.div(:id, 'footer').html
137
141
  html.should include('<div id="footer" title="Closing remarks" class="profile">')
138
- html.should include('<span class="footer">This is a footer.</span>')
142
+ html.should include('This is a footer.')
139
143
  html.should_not include('<div id="content">')
140
144
  html.should_not include('</body>')
141
145
  end
@@ -143,31 +147,32 @@ describe "Div" do
143
147
 
144
148
  describe "#to_s" do
145
149
  it "should return a human readable representation of the element" do
146
- @ie.div(:id, 'footer').to_s.should == "tag: div\n" +
147
- " id: footer\n" +
148
- " title: Closing remarks\n" +
149
- " class: profile\n" +
150
- " text: This is a footer."
150
+ @browser.div(:id, 'footer').to_s.should ==
151
+ %q{tag: div
152
+ id: footer
153
+ title: Closing remarks
154
+ class: profile
155
+ text: This is a footer.}
151
156
  end
152
157
  end
153
158
 
154
159
  # Divs can't be disabled
155
160
  # describe "#disabled?" do
156
161
  # it "should raise UnknownObjectException if the element does not exist" do
157
- # lambda {@ie.div(:id , "div77").disabled? }.should raise_error(UnknownObjectException)
158
- # lambda {@ie.div(:title , "div77").disabled? }.should raise_error(UnknownObjectException)
159
- # lambda {@ie.div(:index , 44).disabled? }.should raise_error(UnknownObjectException)
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)
160
165
  # end
161
166
  #
162
167
  # it "should return false if the element is enabled" do
163
- # @ie.div(:index , 2).should_not be_disabled
168
+ # @browser.div(:index , 2).should_not be_disabled
164
169
  # end
165
170
  #
166
171
  # it "should return true if the element is disabled"
167
172
  # end
168
173
 
169
174
  after :all do
170
- @ie.close
175
+ @browser.close
171
176
  end
172
177
 
173
178
  end
data/spec/divs_spec.rb CHANGED
@@ -2,38 +2,38 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
3
  describe "Divs" do
4
4
  before :all do
5
- @ie = IE.new
6
- add_spec_checker(@ie)
5
+ @browser = IE.new
6
+ add_spec_checker(@browser)
7
7
  end
8
8
 
9
9
  before :each do
10
- @ie.goto(TEST_HOST + "/non_control_elements.html")
10
+ @browser.goto(TEST_HOST + "/non_control_elements.html")
11
11
  end
12
12
 
13
13
  describe "#length" do
14
14
  it "should return the number of divs" do
15
- @ie.divs.length.should == 6
15
+ @browser.divs.length.should == 7
16
16
  end
17
17
  end
18
18
 
19
19
  describe "#[]" do
20
20
  it "should return the div at the given index" do
21
- @ie.divs[2].id.should == "outer_container"
21
+ @browser.divs[2].id.should == "outer_container"
22
22
  end
23
23
  end
24
24
 
25
25
  describe "#each" do
26
26
  it "should iterate through divs correctly" do
27
- @ie.divs.each_with_index do |d, index|
28
- d.name.should == @ie.div(:index, index+1).name
29
- d.id.should == @ie.div(:index, index+1).id
30
- d.class_name.should == @ie.div(:index, index+1).class_name
27
+ @browser.divs.each_with_index do |d, index|
28
+ d.name.should == @browser.div(:index, index+1).name
29
+ d.id.should == @browser.div(:index, index+1).id
30
+ d.class_name.should == @browser.div(:index, index+1).class_name
31
31
  end
32
32
  end
33
33
  end
34
34
 
35
35
  after :all do
36
- @ie.close
36
+ @browser.close
37
37
  end
38
38
 
39
39
  end
data/spec/element_spec.rb CHANGED
@@ -3,27 +3,36 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
3
3
  describe "Element" do
4
4
 
5
5
  before :all do
6
- @ie = IE.new
7
- add_spec_checker(@ie)
6
+ @browser = IE.new
7
+ add_spec_checker(@browser)
8
8
  end
9
9
 
10
10
  before :each do
11
- @ie.goto(TEST_HOST + "/forms_with_input_elements.html")
11
+ @browser.goto(TEST_HOST + "/forms_with_input_elements.html")
12
12
  end
13
-
13
+
14
+ describe "#new" do
15
+ it "should find elements matching the conditions when given a hash of :how => 'what' arguments" do
16
+ @browser.checkbox(:name => 'new_user_interests', :title => 'Dancing is fun!').value.should == 'dancing'
17
+ @browser.text_field(:class_name => 'name', :index => 2).id.should == 'new_user_last_name'
18
+ end
19
+
20
+ it "should raise UnknownObjectException with a sane error message when given a hash of :how => 'what' arguments" do
21
+ conditions = {:index => 100, :name => "foo"}
22
+ lambda { @browser.text_field(conditions).id }.should raise_error(UnknownObjectException, /Unable to locate object, using (\{:name=>"foo", :index=>100\}|\{:index=>100, :name=>"foo"\})/)
23
+ end
24
+ end
25
+
14
26
  describe "#method_missing" do
15
27
  it "should magically return the requested attribute if the attribute is defined in the attribute list" do
16
- @ie.form(:index, 1).action.should == 'forms_with_input_elements.html'
17
- end
18
- it "should call the super class method if the attribute is not defined in the element's attribute list" do
19
- @ie.form(:index, 2).text.should == 'Username Username 1 Delete'
28
+ @browser.form(:index, 1).action.should == 'post_to_me'
20
29
  end
21
- it "should raise NoMethodError if the requested method is not defined in the super class" do
22
- lambda { @ie.button(:index, 1).no_such_attribute_or_method }.should raise_error(NoMethodError)
30
+ it "should raise NoMethodError if the requested method isn't among the attributes" do
31
+ lambda { @browser.button(:index, 1).no_such_attribute_or_method }.should raise_error(NoMethodError)
23
32
  end
24
33
  end
25
34
 
26
35
  after :all do
27
- @ie.close
36
+ @browser.close
28
37
  end
29
38
  end
@@ -2,91 +2,87 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
3
  describe "FileField" do
4
4
  before :all do
5
- @ie = IE.new
6
- add_spec_checker(@ie)
5
+ @browser = IE.new
6
+ add_spec_checker(@browser)
7
7
  end
8
8
 
9
9
  before :each do
10
- @ie.goto(TEST_HOST + "/forms_with_input_elements.html")
10
+ @browser.goto(TEST_HOST + "/forms_with_input_elements.html")
11
11
  end
12
12
 
13
-
14
- # Exist method
15
-
16
13
  describe "#exist?" do
17
14
  it "should return true if the file field exists" do
18
- @ie.file_field(:id, 'new_user_portrait').should exist
19
- @ie.file_field(:id, /new_user_portrait/).should exist
20
- @ie.file_field(:name, 'new_user_portrait').should exist
21
- @ie.file_field(:name, /new_user_portrait/).should exist
22
- @ie.file_field(:class, 'portrait').should exist
23
- @ie.file_field(:class, /portrait/).should exist
24
- @ie.file_field(:index, 1).should exist
25
- @ie.file_field(:xpath, "//input[@id='new_user_portrait']").should exist
15
+ @browser.file_field(:id, 'new_user_portrait').should exist
16
+ @browser.file_field(:id, /new_user_portrait/).should exist
17
+ @browser.file_field(:name, 'new_user_portrait').should exist
18
+ @browser.file_field(:name, /new_user_portrait/).should exist
19
+ @browser.file_field(:class, 'portrait').should exist
20
+ @browser.file_field(:class, /portrait/).should exist
21
+ @browser.file_field(:index, 1).should exist
22
+ @browser.file_field(:xpath, "//input[@id='new_user_portrait']").should exist
26
23
  end
27
24
 
28
25
  it "should return false if the file field doesn't exist" do
29
- @ie.file_field(:id, 'no_such_id').should_not exist
30
- @ie.file_field(:id, /no_such_id/).should_not exist
31
- @ie.file_field(:name, 'no_such_name').should_not exist
32
- @ie.file_field(:name, /no_such_name/).should_not exist
33
- @ie.file_field(:class, 'no_such_class').should_not exist
34
- @ie.file_field(:class, /no_such_class/).should_not exist
35
- @ie.file_field(:index, 1337).should_not exist
36
- @ie.file_field(:xpath, "//input[@id='no_such_id']").should_not exist
26
+ @browser.file_field(:id, 'no_such_id').should_not exist
27
+ @browser.file_field(:id, /no_such_id/).should_not exist
28
+ @browser.file_field(:name, 'no_such_name').should_not exist
29
+ @browser.file_field(:name, /no_such_name/).should_not exist
30
+ @browser.file_field(:class, 'no_such_class').should_not exist
31
+ @browser.file_field(:class, /no_such_class/).should_not exist
32
+ @browser.file_field(:index, 1337).should_not exist
33
+ @browser.file_field(:xpath, "//input[@id='no_such_id']").should_not exist
37
34
  end
38
35
 
39
- it "should raise ArgumentError when what argument is invalid" do
40
- lambda { @ie.file_field(:id, 3.14).exists? }.should raise_error(ArgumentError)
36
+ it "should raise ArgumentError when 'what' argument is invalid" do
37
+ lambda { @browser.file_field(:id, 3.14).exists? }.should raise_error(ArgumentError)
41
38
  end
42
39
 
43
- it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
44
- lambda { @ie.file_field(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
40
+ it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
41
+ lambda { @browser.file_field(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
45
42
  end
46
43
  end
47
44
 
48
-
49
45
  # Attribute methods
50
46
 
51
47
  describe "#class_name" do
52
48
  it "should return the class attribute if the text field exists" do
53
- @ie.file_field(:index, 1).class_name.should == "portrait"
49
+ @browser.file_field(:index, 1).class_name.should == "portrait"
54
50
  end
55
51
  it "should raise UnknownObjectException if the text field doesn't exist" do
56
- lambda { @ie.file_field(:index, 1337).class_name }.should raise_error(UnknownObjectException)
52
+ lambda { @browser.file_field(:index, 1337).class_name }.should raise_error(UnknownObjectException)
57
53
  end
58
54
  end
59
55
 
60
56
  describe "#id" do
61
57
  it "should return the id attribute if the text field exists" do
62
- @ie.file_field(:index, 1).id.should == "new_user_portrait"
58
+ @browser.file_field(:index, 1).id.should == "new_user_portrait"
63
59
  end
64
60
  it "should raise UnknownObjectException if the text field doesn't exist" do
65
- lambda { @ie.file_field(:index, 1337).id }.should raise_error(UnknownObjectException)
61
+ lambda { @browser.file_field(:index, 1337).id }.should raise_error(UnknownObjectException)
66
62
  end
67
63
  end
68
64
 
69
65
  describe "#name" do
70
66
  it "should return the name attribute if the text field exists" do
71
- @ie.file_field(:index, 1).name.should == "new_user_portrait"
67
+ @browser.file_field(:index, 1).name.should == "new_user_portrait"
72
68
  end
73
69
  it "should raise UnknownObjectException if the text field doesn't exist" do
74
- lambda { @ie.file_field(:index, 1337).name }.should raise_error(UnknownObjectException)
70
+ lambda { @browser.file_field(:index, 1337).name }.should raise_error(UnknownObjectException)
75
71
  end
76
72
  end
77
73
 
78
74
  describe "#title" do
79
75
  it "should return the title attribute if the text field exists" do
80
- @ie.file_field(:id, "new_user_portrait").title.should == "Smile!"
76
+ @browser.file_field(:id, "new_user_portrait").title.should == "Smile!"
81
77
  end
82
78
  end
83
79
 
84
80
  describe "#type" do
85
81
  it "should return the type attribute if the text field exists" do
86
- @ie.file_field(:index, 1).type.should == "file"
82
+ @browser.file_field(:index, 1).type.should == "file"
87
83
  end
88
84
  it "should raise UnknownObjectException if the text field doesn't exist" do
89
- lambda { @ie.file_field(:index, 1337).type }.should raise_error(UnknownObjectException)
85
+ lambda { @browser.file_field(:index, 1337).type }.should raise_error(UnknownObjectException)
90
86
  end
91
87
  end
92
88
 
@@ -95,15 +91,14 @@ describe "FileField" do
95
91
 
96
92
  describe "#set" do
97
93
  it "should be able to set a file path in the field and click the upload button" do
98
- @ie.file_field(:name, "new_user_portrait").set(__FILE__)
99
- @ie.file_field(:name, "new_user_portrait").value.should == __FILE__
100
- # @ie.button(:name, "new_user_submit").click
101
- pending
94
+ @browser.file_field(:name, "new_user_portrait").set(__FILE__)
95
+ @browser.file_field(:name, "new_user_portrait").value.should == __FILE__
96
+ @browser.button(:name, "new_user_submit").click
102
97
  end
103
98
  end
104
99
 
105
100
  after :all do
106
- @ie.close
101
+ @browser.close
107
102
  end
108
103
 
109
104
  end