celerity 0.0.2 → 0.0.3

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 (127) hide show
  1. data/History.txt +15 -1
  2. data/Manifest.txt +174 -0
  3. data/README.txt +19 -10
  4. data/config/hoe.rb +68 -0
  5. data/config/requirements.rb +15 -0
  6. data/lib/celerity.rb +14 -11
  7. data/lib/celerity/collections.rb +37 -8
  8. data/lib/celerity/container.rb +100 -3
  9. data/lib/celerity/disabled_element.rb +4 -2
  10. data/lib/celerity/element.rb +21 -8
  11. data/lib/celerity/element_collections.rb +4 -7
  12. data/lib/celerity/element_locator.rb +1 -0
  13. data/lib/celerity/elements/button.rb +6 -2
  14. data/lib/celerity/elements/file_field.rb +1 -1
  15. data/lib/celerity/elements/form.rb +1 -2
  16. data/lib/celerity/elements/frame.rb +0 -3
  17. data/lib/celerity/elements/image.rb +1 -4
  18. data/lib/celerity/elements/label.rb +1 -0
  19. data/lib/celerity/elements/link.rb +2 -0
  20. data/lib/celerity/elements/option.rb +1 -0
  21. data/lib/celerity/elements/radio_check.rb +3 -5
  22. data/lib/celerity/elements/select_list.rb +3 -10
  23. data/lib/celerity/elements/table.rb +8 -22
  24. data/lib/celerity/elements/table_body.rb +5 -11
  25. data/lib/celerity/elements/table_cell.rb +1 -0
  26. data/lib/celerity/elements/table_footer.rb +30 -0
  27. data/lib/celerity/elements/table_header.rb +30 -0
  28. data/lib/celerity/elements/table_row.rb +5 -3
  29. data/lib/celerity/elements/text_field.rb +18 -13
  30. data/lib/celerity/exception.rb +8 -8
  31. data/lib/celerity/extra/method_generator.rb +5 -2
  32. data/lib/celerity/htmlunit/htmlunit-2.2-SNAPSHOT.jar +0 -0
  33. data/lib/celerity/ie.rb +195 -141
  34. data/lib/celerity/non_control_elements.rb +30 -4
  35. data/lib/celerity/version.rb +1 -1
  36. data/lib/celerity/watir_compatibility.rb +62 -0
  37. data/setup.rb +0 -2
  38. data/spec/area_spec.rb +4 -1
  39. data/spec/areas_spec.rb +1 -1
  40. data/spec/button_spec.rb +35 -17
  41. data/spec/buttons_spec.rb +1 -1
  42. data/spec/checkbox_spec.rb +6 -4
  43. data/spec/checkboxes_spec.rb +1 -1
  44. data/spec/div_spec.rb +20 -19
  45. data/spec/divs_spec.rb +2 -2
  46. data/spec/element_spec.rb +13 -2
  47. data/spec/filefield_spec.rb +6 -3
  48. data/spec/filefields_spec.rb +1 -1
  49. data/spec/form_spec.rb +4 -1
  50. data/spec/forms_spec.rb +1 -1
  51. data/spec/frame_spec.rb +6 -2
  52. data/spec/hidden_spec.rb +8 -4
  53. data/spec/hiddens_spec.rb +1 -1
  54. data/spec/hn_spec.rb +86 -0
  55. data/spec/hns_spec.rb +41 -0
  56. data/spec/html/bug_duplicate_attributes.html +14 -0
  57. data/spec/html/bug_javascript_001.html +11 -0
  58. data/spec/html/forms_with_input_elements.html +11 -11
  59. data/spec/html/images.html +18 -15
  60. data/spec/html/latin1_text.html +16 -0
  61. data/spec/html/non_control_elements.html +28 -4
  62. data/spec/html/tables.html +3 -3
  63. data/spec/html/utf8_text.html +15 -0
  64. data/spec/htmlunit_spec.rb +27 -0
  65. data/spec/ie_spec.rb +47 -12
  66. data/spec/image_spec.rb +4 -7
  67. data/spec/images_spec.rb +3 -2
  68. data/spec/label_spec.rb +4 -3
  69. data/spec/labels_spec.rb +1 -1
  70. data/spec/li_spec.rb +11 -8
  71. data/spec/link_spec.rb +5 -1
  72. data/spec/links_spec.rb +2 -1
  73. data/spec/lis_spec.rb +3 -2
  74. data/spec/map_spec.rb +4 -1
  75. data/spec/maps_spec.rb +1 -1
  76. data/spec/meta_spec.rb +6 -0
  77. data/spec/ol_spec.rb +73 -0
  78. data/spec/ols_spec.rb +41 -0
  79. data/spec/option_spec.rb +129 -0
  80. data/spec/p_spec.rb +4 -1
  81. data/spec/pre_spec.rb +4 -1
  82. data/spec/pres_spec.rb +1 -1
  83. data/spec/ps_spec.rb +2 -1
  84. data/spec/radio_spec.rb +7 -19
  85. data/spec/radios_spec.rb +1 -1
  86. data/spec/select_list_spec.rb +19 -57
  87. data/spec/select_lists_spec.rb +3 -2
  88. data/spec/span_spec.rb +8 -5
  89. data/spec/spans_spec.rb +2 -1
  90. data/spec/spec_helper.rb +8 -43
  91. data/spec/table_bodies_spec.rb +17 -4
  92. data/spec/table_body_spec.rb +47 -16
  93. data/spec/table_cell_spec.rb +5 -3
  94. data/spec/table_cells_spec.rb +1 -1
  95. data/spec/table_footer_spec.rb +94 -0
  96. data/spec/table_footers_spec.rb +53 -0
  97. data/spec/table_header_spec.rb +94 -0
  98. data/spec/table_headers_spec.rb +53 -0
  99. data/spec/table_row_spec.rb +25 -4
  100. data/spec/table_rows_spec.rb +1 -1
  101. data/spec/table_spec.rb +22 -2
  102. data/spec/tables_spec.rb +2 -1
  103. data/spec/text_field_spec.rb +52 -20
  104. data/spec/text_fields_spec.rb +1 -1
  105. data/spec/ul_spec.rb +73 -0
  106. data/spec/uls_spec.rb +41 -0
  107. data/spec/watir_compatability_spec.rb +253 -0
  108. data/support/celerity_viewer/rubycocoa/CelerityViewer.icns +0 -0
  109. data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/classes.nib +37 -0
  110. data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/info.nib +19 -0
  111. data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/keyedobjects.nib +0 -0
  112. data/support/celerity_viewer/rubycocoa/Info.plist.erb +28 -0
  113. data/support/celerity_viewer/rubycocoa/MainController.rb +23 -0
  114. data/support/celerity_viewer/rubycocoa/README +94 -0
  115. data/support/celerity_viewer/rubycocoa/Rakefile +100 -0
  116. data/support/celerity_viewer/rubycocoa/distributed_viewer.rb +86 -0
  117. data/support/celerity_viewer/rubycocoa/main.m +7 -0
  118. data/support/celerity_viewer/rubycocoa/main.rb +27 -0
  119. data/support/spec_server.rb +64 -0
  120. data/tasks/benchmark.rake +1 -0
  121. data/tasks/rdoc.rake +4 -0
  122. data/tasks/rspec.rake +10 -3
  123. data/tasks/simple_ci.rake +94 -0
  124. data/tasks/specserver.rake +21 -0
  125. metadata +160 -114
  126. data/spec/table_bodies.rb +0 -40
  127. data/tasks/testserver.rake +0 -32
@@ -0,0 +1,94 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe TableHeader do
4
+
5
+ before :all do
6
+ @browser = IE.new
7
+ add_spec_checker(@browser)
8
+ end
9
+
10
+ before :each do
11
+ @browser = IE.new
12
+ @browser.goto(TEST_HOST + "/tables.html")
13
+ end
14
+
15
+ describe "#exists" do
16
+ it "should return true if the table theader exists (page context)" do
17
+ @browser.thead(:id, 'tax_headers').should exist
18
+ @browser.thead(:id, /tax_headers/).should exist
19
+ @browser.thead(:index, 1).should exist
20
+ @browser.thead(:xpath, "//thead[@id='tax_headers']").should exist
21
+ end
22
+ it "should return true if the table theader exists (table context)" do
23
+ @browser.table(:index, 1).thead(:id, 'tax_headers').should exist
24
+ @browser.table(:index, 1).thead(:id, /tax_headers/).should exist
25
+ @browser.table(:index, 1).thead(:index, 1).should exist
26
+ @browser.table(:index, 1).thead(:xpath, "//thead[@id='tax_headers']").should exist
27
+ end
28
+ it "should return true if the element exists (default how = :id)" do
29
+ @browser.thead("tax_headers").should exist
30
+ @browser.table(:index, 1).thead("tax_headers").should exist
31
+ end
32
+ it "should return false if the table theader exists (page context)" do
33
+ @browser.thead(:id, 'no_such_id').should_not exist
34
+ @browser.thead(:id, /no_such_id/).should_not exist
35
+ @browser.thead(:index, 1337).should_not exist
36
+ @browser.thead(:xpath, "//thead[@id='no_such_id']").should_not exist
37
+ end
38
+ it "should return false if the table theader exists (table context)" do
39
+ @browser.table(:index, 1).thead(:id, 'no_such_id').should_not exist
40
+ @browser.table(:index, 1).thead(:id, /no_such_id/).should_not exist
41
+ @browser.table(:index, 1).thead(:index, 1337).should_not exist
42
+ @browser.table(:index, 1).thead(:xpath, "//thead[@id='no_such_id']").should_not exist
43
+ end
44
+ it "should raise ArgumentError when 'what' argument is invalid" do
45
+ lambda { @browser.thead(:id, 3.14).exists? }.should raise_error(ArgumentError)
46
+ lambda { @browser.table(:index, 1).thead(:id, 3.14).exists? }.should raise_error(ArgumentError)
47
+ end
48
+ it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
49
+ lambda { @browser.thead(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
50
+ lambda { @browser.table(:index, 1).thead(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
51
+ end
52
+ end
53
+
54
+ describe "#length" do
55
+ it "should return the correct number of table bodies (page context)" do
56
+ @browser.thead(:id, 'tax_headers').length.should == 1
57
+ end
58
+ it "should return the correct number of table bodies (table context)" do
59
+ @browser.table(:index, 1).thead(:id, 'tax_headers').length.should == 1
60
+ end
61
+ end
62
+
63
+ describe "#[]" do
64
+ it "should return the row at the given index (page context)" do
65
+ @browser.thead(:id, 'tax_headers')[1].text.should == 'Before income tax Income tax After income tax'
66
+ @browser.thead(:id, 'tax_headers')[1][2].text.should == 'Before income tax'
67
+ @browser.thead(:id, 'tax_headers')[1][3].text.should == 'Income tax'
68
+ end
69
+ it "should return the row at the given index (table context)" do
70
+ @browser.table(:index, 1).thead(:id, 'tax_headers')[1].text.should == 'Before income tax Income tax After income tax'
71
+ @browser.table(:index, 1).thead(:id, 'tax_headers')[1][2].text.should == 'Before income tax'
72
+ @browser.table(:index, 1).thead(:id, 'tax_headers')[1][3].text.should == 'Income tax'
73
+ end
74
+ end
75
+
76
+ describe "#each" do
77
+ it "should iterate through rows correctly" do
78
+ theader = @browser.table(:index, 1).thead(:id, 'tax_headers')
79
+ index = 1
80
+ theader.each do |r|
81
+ r.name.should == @browser.row(:index, index).name
82
+ r.id.should == @browser.row(:index, index).id
83
+ r.value.should == @browser.row(:index, index).value
84
+ index += 1
85
+ end
86
+ index.should_not == 1
87
+ end
88
+ end
89
+
90
+ after :all do
91
+ @browser.close
92
+ end
93
+
94
+ end
@@ -0,0 +1,53 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe TableHeaders do
4
+
5
+ before :all do
6
+ @browser = IE.new
7
+ add_spec_checker(@browser)
8
+ end
9
+
10
+ before :each do
11
+ @browser = IE.new
12
+ @browser.goto(TEST_HOST + "/tables.html")
13
+ end
14
+
15
+ describe "#length" do
16
+ it "should return the correct number of table theads (page context)" do
17
+ @browser.theads.length.should == 1
18
+ end
19
+ it "should return the correct number of table theads (table context)" do
20
+ @browser.table(:index, 1).theads.length.should == 1
21
+ end
22
+ end
23
+
24
+ describe "#[]" do
25
+ it "should return the row at the given index (page context)" do
26
+ @browser.theads[1].id.should == "tax_headers"
27
+ end
28
+ it "should return the row at the given index (table context)" do
29
+ @browser.table(:index, 1).theads[1].id.should == "tax_headers"
30
+ end
31
+ end
32
+
33
+ describe "#each" do
34
+ it "should iterate through table theads correctly (page context)" do
35
+ @browser.theads.each_with_index do |thead, index|
36
+ thead.name.should == @browser.thead(:index, index+1).name
37
+ thead.id.should == @browser.thead(:index, index+1).id
38
+ end
39
+ end
40
+ it "should iterate through table theads correctly (table context)" do
41
+ table = @browser.table(:index, 1)
42
+ table.theads.each_with_index do |thead, index|
43
+ thead.name.should == table.thead(:index, index+1).name
44
+ thead.id.should == table.thead(:index, index+1).id
45
+ end
46
+ end
47
+ end
48
+
49
+ after :all do
50
+ @browser.close
51
+ end
52
+
53
+ end
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe "TableRow" do
3
+ describe TableRow do
4
4
 
5
5
  before :all do
6
6
  @browser = IE.new
@@ -12,6 +12,27 @@ describe "TableRow" do
12
12
  @browser.goto(TEST_HOST + "/tables.html")
13
13
  end
14
14
 
15
+ describe "#exists?" do
16
+ it "should return true if the table row exists" do
17
+ @browser.row(:id, "outer_first").should exist
18
+ @browser.row(:id, /outer_first/).should exist
19
+ @browser.row(:index, 1).should exist
20
+ @browser.row(:xpath, "//tr[@id='outer_first']")
21
+ end
22
+ it "should return true if the element exists (default how = :id)" do
23
+ @browser.row("outer_last").should exist
24
+ end
25
+ it "should return false if the table row exists" do
26
+
27
+ end
28
+ it "should raise ArgumentError when 'what' argument is invalid" do
29
+ lambda { @browser.row(:id, 3.14).exists? }.should raise_error(ArgumentError)
30
+ end
31
+ it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
32
+ lambda { @browser.row(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
33
+ end
34
+ end
35
+
15
36
  describe "#column_count" do
16
37
  it "should return the number of columns (cells) in the row" do
17
38
  @browser.table(:id, 'outer').rows[1].column_count.should == 2
@@ -29,8 +50,8 @@ describe "TableRow" do
29
50
  end
30
51
  end
31
52
 
32
- describe "#[]n" do
33
- it "should " do
53
+ describe "#[]" do
54
+ it "should " do # FIXME: description
34
55
  @browser.table(:id, 'outer').row(:index, 1)[1].text.should == "Table 1, Row 1, Cell 1"
35
56
  @browser.table(:id, 'outer')[1][1].text.should == "Table 1, Row 1, Cell 1"
36
57
  @browser.table(:id, 'outer')[3][1].text.should == "Table 1, Row 3, Cell 1"
@@ -38,7 +59,7 @@ describe "TableRow" do
38
59
  end
39
60
 
40
61
  describe "#each" do
41
- it "should " do
62
+ it "should " do # FIXME: description
42
63
  index = 1
43
64
  @browser.table(:id, 'outer')[2].each do |c|
44
65
  case index
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe "TableRows" do
3
+ describe TableRows do
4
4
 
5
5
  before :all do
6
6
  @browser = IE.new
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe "Table" do
3
+ describe Table do
4
4
 
5
5
  before :all do
6
6
  @browser = IE.new
@@ -20,6 +20,9 @@ describe "Table" do
20
20
  @browser.table(:index, 1).should exist
21
21
  @browser.table(:xpath, "//table[@id='axis_example']").should exist
22
22
  end
23
+ it "should return true if the element exists (default how = :id)" do
24
+ @browser.table("axis_example").should exist
25
+ end
23
26
  it "should return false if the table does not exist" do
24
27
  @browser.table(:id, 'no_such_id').should_not exist
25
28
  @browser.table(:id, /no_such_id/).should_not exist
@@ -88,7 +91,7 @@ describe "Table" do
88
91
  @browser.table(:id, 'outer')[3].id.should == "outer_last"
89
92
  end
90
93
  end
91
-
94
+
92
95
  describe "#each" do
93
96
  it "should iterate through the table's rows" do
94
97
  index = 1
@@ -104,6 +107,23 @@ describe "Table" do
104
107
  end
105
108
  end
106
109
 
110
+ describe "#body" do
111
+ it "should return the correct instance of TableBody" do
112
+ body = @browser.table(:index, 1).body(:id, 'first')
113
+ body.instance_of?(TableBody).should be_true
114
+ body[1][1].text.should == "March 2008"
115
+ end
116
+ end
117
+
118
+ describe "#bodies" do
119
+ it "should return the correct instance of TableBodies" do
120
+ bodies = @browser.table(:index, 1).bodies
121
+ bodies.instance_of?(TableBodies).should be_true
122
+ bodies[1].id.should == "first"
123
+ bodies[2].id.should == "second"
124
+ end
125
+ end
126
+
107
127
  after :all do
108
128
  @browser.close
109
129
  end
@@ -1,6 +1,7 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe "Tables" do
3
+ describe Tables do
4
+
4
5
  before :all do
5
6
  @browser = IE.new
6
7
  add_spec_checker(@browser)
@@ -1,8 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- # TODO: specs for exceptions
4
-
5
- describe "TextField" do
3
+ describe TextField do
6
4
 
7
5
  before :all do
8
6
  @browser = IE.new
@@ -13,7 +11,7 @@ describe "TextField" do
13
11
  @browser.goto(TEST_HOST + "/forms_with_input_elements.html")
14
12
  end
15
13
 
16
- # Exist method
14
+ # Exists method
17
15
  describe "#exists?" do
18
16
  it "should return true if the element exists" do
19
17
  @browser.text_field(:id, 'new_user_email').should exist
@@ -29,15 +27,15 @@ describe "TextField" do
29
27
  @browser.text_field(:index, 1).should exist
30
28
  @browser.text_field(:xpath, "//input[@id='new_user_email']").should exist
31
29
  end
32
-
30
+ it "should return true if the element exists (default how = :name)" do
31
+ @browser.text_field("new_user_email").should exist
32
+ end
33
33
  it "should return true if the element exists (no type attribute)" do
34
34
  @browser.text_field(:id, 'new_user_first_name').should exist
35
35
  end
36
-
37
36
  it "should return true if the element exists (invalid type attribute)" do
38
37
  @browser.text_field(:id, 'new_user_last_name').should exist
39
38
  end
40
-
41
39
  it "should return false if the element does not exist" do
42
40
  @browser.text_field(:id, 'no_such_id').should_not exist
43
41
  @browser.text_field(:id, /no_such_id/).should_not exist
@@ -52,17 +50,14 @@ describe "TextField" do
52
50
  @browser.text_field(:index, 1337).should_not exist
53
51
  @browser.text_field(:xpath, "//input[@id='no_such_id']").should_not exist
54
52
  end
55
-
56
53
  it "should raise ArgumentError when 'what' argument is invalid" do
57
54
  lambda { @browser.text_field(:id, 3.14).exists? }.should raise_error(ArgumentError)
58
55
  end
59
-
60
56
  it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
61
57
  lambda { @browser.text_field(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
62
58
  end
63
59
  end
64
60
 
65
-
66
61
  # Attribute methods
67
62
  describe "#id" do
68
63
  it "should return the id attribute if the text field exists" do
@@ -92,10 +87,15 @@ describe "TextField" do
92
87
  end
93
88
 
94
89
  describe "#type" do
95
- #TODO: What if the type attribute is non-existent or invalid?
96
90
  it "should return the type attribute if the text field exists" do
97
91
  @browser.text_field(:index, 4).type.should == "text"
98
92
  end
93
+ it "should return 'text' if the type attribute is invalid" do
94
+ @browser.text_field(:id, 'new_user_last_name').type.should == "text"
95
+ end
96
+ it "should return 'text' if the type attribute does not exist" do
97
+ @browser.text_field(:id, 'new_user_first_name').type.should == "text"
98
+ end
99
99
  it "should raise UnknownObjectException if the text field doesn't exist" do
100
100
  lambda { @browser.text_field(:index, 1337).type }.should raise_error(UnknownObjectException)
101
101
  end
@@ -121,6 +121,9 @@ describe "TextField" do
121
121
  it "should return false for disabled text fields" do
122
122
  @browser.text_field(:name, "new_user_species").should_not be_enabled
123
123
  end
124
+ it "should raise UnknownObjectException if the text field doesn't exist" do
125
+ lambda { @browser.text_field(:id, "no_such_id").enabled? }.should raise_error(UnknownObjectException)
126
+ end
124
127
  end
125
128
 
126
129
  describe "#disabled?" do
@@ -131,7 +134,7 @@ describe "TextField" do
131
134
  @browser.text_field(:index, 1).should_not be_disabled
132
135
  end
133
136
  it "should raise UnknownObjectException if the text field doesn't exist" do
134
- lambda { @browser.text_field(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
137
+ lambda { @browser.text_field(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
135
138
  end
136
139
  end
137
140
 
@@ -143,11 +146,13 @@ describe "TextField" do
143
146
  it "should return false for writeable text fields" do
144
147
  @browser.text_field(:name, "new_user_email").should_not be_readonly
145
148
  end
149
+ it "should raise UnknownObjectException if the text field doesn't exist" do
150
+ lambda { @browser.text_field(:id, 'no_such_id').readonly? }.should raise_error(UnknownObjectException)
151
+ end
146
152
  end
147
153
 
148
154
 
149
155
  # Manipulation methods
150
-
151
156
  describe "#append" do
152
157
  it "should append the text to the text field" do
153
158
  @browser.text_field(:name, "new_user_occupation").append(" Append This")
@@ -175,6 +180,9 @@ describe "TextField" do
175
180
  @browser.text_field(:id, "delete_user_comment").clear
176
181
  @browser.text_field(:id, "delete_user_comment").get_contents.should be_empty
177
182
  end
183
+ it "should raise UnknownObjectException if the text field doesn't exist" do
184
+ lambda { @browser.text_field(:id, "no_such_id").clear }.should raise_error(UnknownObjectException)
185
+ end
178
186
  end
179
187
 
180
188
  describe "#drag_contents_to" do
@@ -184,12 +192,22 @@ describe "TextField" do
184
192
  @browser.text_field(:name, "new_user_first_name").value.should be_empty
185
193
  @browser.text_field(:id, "new_user_last_name").value.should == "Smith"
186
194
  end
195
+ it "should raise UnknownObjectException if either of the text fields doesn't exist" do
196
+ lambda { @browser.text_field(:id, "no_such_id").drag_contents_to(:name, "new_user_last_name") }.should raise_error(UnknownObjectException)
197
+ lambda { @browser.text_field(:name, "new_user_first_name").drag_contents_to(:id, "no_such_id") }.should raise_error(UnknownObjectException)
198
+ end
187
199
  end
188
200
 
189
201
  describe "#get_contents" do
202
+ it "should return the contents of the text field" do
203
+ @browser.text_field(:name, "new_user_occupation").get_contents.should == "Developer"
204
+ end
190
205
  it "should raise UnknownObjectException when accessing a non-existing element" do
191
206
  lambda { @browser.text_field(:name, "no_such_name").get_contents }.should raise_error(UnknownObjectException)
192
207
  end
208
+ it "should raise UnknownObjectException if the text field doesn't exist" do
209
+ lambda { @browser.text_field(:id, "no_such_id").get_contents }.should raise_error(UnknownObjectException)
210
+ end
193
211
  end
194
212
 
195
213
  describe "#value=" do
@@ -197,16 +215,22 @@ describe "TextField" do
197
215
  @browser.text_field(:id, 'new_user_email').value = 'Hello Cruel World'
198
216
  @browser.text_field(:id, "new_user_email").value.should == 'Hello Cruel World'
199
217
  end
200
-
201
218
  it "should be able to set multi-byte characters" do
202
219
  @browser.text_field(:name, "new_user_occupation").value = "ijij"
203
220
  @browser.text_field(:name, "new_user_occupation").get_contents.should == "ijij"
204
221
  end
205
-
222
+ it "should be able to set Latin 1 characters" do
223
+ @browser.goto(TEST_HOST + "/latin1_text.html")
224
+ @browser.text_field(:id, "charset").value = "B\370rsmegler"
225
+ @browser.text_field(:id, "charset").value.should == "B\370rsmegler"
226
+ end
206
227
  it "should set the value of a textarea element" do
207
228
  @browser.text_field(:id, 'delete_user_comment').value = 'Hello Cruel World'
208
229
  @browser.text_field(:id, "delete_user_comment").value.should == 'Hello Cruel World'
209
230
  end
231
+ it "should raise UnknownObjectException if the text field doesn't exist" do
232
+ lambda { @browser.text_field(:name, "no_such_name").value = 'yo' }.should raise_error(UnknownObjectException)
233
+ end
210
234
  end
211
235
 
212
236
  describe "#set" do
@@ -214,17 +238,14 @@ describe "TextField" do
214
238
  @browser.text_field(:id, 'new_user_email').set('Bye Cruel World')
215
239
  @browser.text_field(:id, "new_user_email").value.should == 'Bye Cruel World'
216
240
  end
217
-
218
241
  it "should set the value of a textarea element" do
219
242
  @browser.text_field(:id, 'delete_user_comment').set('Hello Cruel World')
220
243
  @browser.text_field(:id, "delete_user_comment").value.should == 'Hello Cruel World'
221
244
  end
222
-
223
245
  it "should fire events" do
224
246
  @browser.text_field(:id, "new_user_username").set("Hello World")
225
247
  @browser.span(:id, "current_length").text.should == "11"
226
248
  end
227
-
228
249
  it "should be able to set the value of a password field" do
229
250
  @browser.text_field(:name , 'new_user_password').set('secret')
230
251
  @browser.text_field(:name , 'new_user_password').value.should == 'secret'
@@ -233,6 +254,14 @@ describe "TextField" do
233
254
  @browser.text_field(:name, "new_user_occupation").set("ijij")
234
255
  @browser.text_field(:name, "new_user_occupation").get_contents.should == "ijij"
235
256
  end
257
+ it "should be able to set Latin 1 characters" do
258
+ @browser.goto(TEST_HOST + "/latin1_text.html")
259
+ @browser.text_field(:id, "charset").set("B\370rsmegler")
260
+ @browser.text_field(:id, "charset").get_contents.should == "B\370rsmegler"
261
+ end
262
+ it "should raise UnknownObjectException if the text field doesn't exist" do
263
+ lambda { @browser.text_field(:id, "no_such_id").set('secret') }.should raise_error(UnknownObjectException)
264
+ end
236
265
  end
237
266
 
238
267
  describe "#verify_contains" do
@@ -244,10 +273,13 @@ describe "TextField" do
244
273
  @browser.text_field(:name, "new_user_email").verify_contains("no_such_text").should be_false
245
274
  @browser.text_field(:name, "new_user_email").verify_contains(/no_such_text/).should be_false
246
275
  end
276
+ it "should raise UnknownObjectException if the text field doesn't exist" do
277
+ lambda { @browser.text_field(:id, "no_such_id").verify_contains("Developer") }.should raise_error(UnknownObjectException)
278
+ end
247
279
  end
248
280
 
249
281
  after :all do
250
282
  @browser.close
251
283
  end
252
- end
253
-
284
+
285
+ end