celerity 0.0.3 → 0.0.4

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 (136) hide show
  1. data.tar.gz.sig +0 -0
  2. data/History.txt +14 -0
  3. data/Manifest.txt +127 -151
  4. data/README.txt +15 -20
  5. data/lib/celerity.rb +13 -5
  6. data/lib/celerity/browser.rb +296 -0
  7. data/lib/celerity/clickable_element.rb +1 -0
  8. data/lib/celerity/collections.rb +4 -0
  9. data/lib/celerity/container.rb +69 -2
  10. data/lib/celerity/disabled_element.rb +1 -0
  11. data/lib/celerity/element.rb +103 -38
  12. data/lib/celerity/element_collections.rb +14 -8
  13. data/lib/celerity/element_locator.rb +61 -50
  14. data/lib/celerity/element_map.rb +51 -0
  15. data/lib/celerity/elements/button.rb +1 -0
  16. data/lib/celerity/elements/file_field.rb +3 -2
  17. data/lib/celerity/elements/form.rb +1 -0
  18. data/lib/celerity/elements/frame.rb +16 -1
  19. data/lib/celerity/elements/image.rb +15 -13
  20. data/lib/celerity/elements/link.rb +4 -1
  21. data/lib/celerity/elements/option.rb +1 -0
  22. data/lib/celerity/elements/radio_check.rb +19 -7
  23. data/lib/celerity/elements/select_list.rb +17 -2
  24. data/lib/celerity/elements/table.rb +34 -20
  25. data/lib/celerity/elements/table_body.rb +2 -2
  26. data/lib/celerity/elements/table_cell.rb +3 -1
  27. data/lib/celerity/elements/table_footer.rb +2 -2
  28. data/lib/celerity/elements/table_header.rb +2 -2
  29. data/lib/celerity/elements/table_row.rb +4 -2
  30. data/lib/celerity/elements/text_field.rb +20 -9
  31. data/lib/celerity/exception.rb +11 -18
  32. data/lib/celerity/extra/method_generator.rb +13 -8
  33. data/lib/celerity/htmlunit/download.sh +23 -0
  34. data/lib/celerity/htmlunit/htmlunit-2.2.jar +0 -0
  35. data/lib/celerity/htmlunit/htmlunit-core-js-2.2.jar +0 -0
  36. data/lib/celerity/htmlunit/{nekohtml-1.9.7.jar → nekohtml-1.9.8.jar} +0 -0
  37. data/lib/celerity/input_element.rb +1 -1
  38. data/lib/celerity/version.rb +1 -1
  39. data/lib/celerity/watir_compatibility.rb +37 -23
  40. data/spec/area_spec.rb +19 -4
  41. data/spec/areas_spec.rb +2 -3
  42. data/spec/{ie_spec.rb → browser_spec.rb} +66 -15
  43. data/spec/button_spec.rb +36 -3
  44. data/spec/buttons_spec.rb +2 -3
  45. data/spec/checkbox_spec.rb +43 -8
  46. data/spec/checkboxes_spec.rb +2 -3
  47. data/spec/div_spec.rb +31 -4
  48. data/spec/divs_spec.rb +2 -3
  49. data/spec/element_spec.rb +36 -6
  50. data/spec/filefield_spec.rb +28 -13
  51. data/spec/filefields_spec.rb +2 -3
  52. data/spec/form_spec.rb +6 -3
  53. data/spec/forms_spec.rb +2 -3
  54. data/spec/frame_spec.rb +14 -5
  55. data/spec/frames_spec.rb +71 -0
  56. data/spec/hidden_spec.rb +21 -3
  57. data/spec/hiddens_spec.rb +2 -3
  58. data/spec/hn_spec.rb +30 -12
  59. data/spec/hns_spec.rb +14 -10
  60. data/spec/html/form_js_bug.html +11 -0
  61. data/spec/html/forms_with_input_elements.html +2 -1
  62. data/spec/html/invalid_js.html +11 -0
  63. data/spec/html/latin1_text.html +1 -0
  64. data/spec/html/non_control_elements.html +8 -4
  65. data/spec/html/simple_ajax.html +22 -0
  66. data/spec/htmlunit_spec.rb +4 -5
  67. data/spec/image_spec.rb +33 -3
  68. data/spec/images_spec.rb +2 -3
  69. data/spec/label_spec.rb +16 -3
  70. data/spec/labels_spec.rb +2 -3
  71. data/spec/li_spec.rb +25 -3
  72. data/spec/link_spec.rb +35 -3
  73. data/spec/links_spec.rb +2 -3
  74. data/spec/lis_spec.rb +2 -3
  75. data/spec/map_spec.rb +19 -3
  76. data/spec/maps_spec.rb +2 -3
  77. data/spec/meta_spec.rb +3 -1
  78. data/spec/ol_spec.rb +17 -3
  79. data/spec/ols_spec.rb +2 -3
  80. data/spec/option_spec.rb +28 -3
  81. data/spec/p_spec.rb +30 -2
  82. data/spec/pre_spec.rb +25 -3
  83. data/spec/pres_spec.rb +2 -3
  84. data/spec/ps_spec.rb +2 -3
  85. data/spec/radio_spec.rb +47 -3
  86. data/spec/radios_spec.rb +2 -3
  87. data/spec/select_list_spec.rb +42 -3
  88. data/spec/select_lists_spec.rb +2 -3
  89. data/spec/span_spec.rb +32 -7
  90. data/spec/spans_spec.rb +2 -4
  91. data/spec/spec_helper.rb +5 -25
  92. data/spec/table_bodies_spec.rb +7 -5
  93. data/spec/table_body_spec.rb +11 -4
  94. data/spec/table_cell_spec.rb +15 -4
  95. data/spec/table_cells_spec.rb +3 -4
  96. data/spec/table_footer_spec.rb +11 -4
  97. data/spec/table_footers_spec.rb +7 -5
  98. data/spec/table_header_spec.rb +11 -4
  99. data/spec/table_headers_spec.rb +7 -5
  100. data/spec/table_row_spec.rb +31 -7
  101. data/spec/table_rows_spec.rb +5 -4
  102. data/spec/table_spec.rb +36 -7
  103. data/spec/tables_spec.rb +2 -3
  104. data/spec/text_field_spec.rb +51 -13
  105. data/spec/text_fields_spec.rb +2 -3
  106. data/spec/ul_spec.rb +18 -3
  107. data/spec/uls_spec.rb +2 -3
  108. data/spec/{watir_compatability_spec.rb → watir_compatibility_spec.rb} +42 -35
  109. data/support/spec_server.rb +9 -0
  110. metadata +167 -161
  111. metadata.gz.sig +0 -0
  112. data/benchmark/bm_2000_spans.rb +0 -48
  113. data/benchmark/bm_digg.rb +0 -26
  114. data/benchmark/bm_google_images.rb +0 -36
  115. data/benchmark/bm_input_locator.rb +0 -69
  116. data/benchmark/loader.rb +0 -9
  117. data/config/hoe.rb +0 -68
  118. data/config/requirements.rb +0 -15
  119. data/lib/celerity/htmlunit/htmlunit-2.2-SNAPSHOT.jar +0 -0
  120. data/lib/celerity/htmlunit/js-1.7R1.jar +0 -0
  121. data/lib/celerity/ie.rb +0 -195
  122. data/setup.rb +0 -1583
  123. data/support/celerity_viewer/rubycocoa/CelerityViewer.icns +0 -0
  124. data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/classes.nib +0 -37
  125. data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/info.nib +0 -19
  126. data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/keyedobjects.nib +0 -0
  127. data/support/celerity_viewer/rubycocoa/Info.plist.erb +0 -28
  128. data/support/celerity_viewer/rubycocoa/MainController.rb +0 -23
  129. data/support/celerity_viewer/rubycocoa/README +0 -94
  130. data/support/celerity_viewer/rubycocoa/Rakefile +0 -100
  131. data/support/celerity_viewer/rubycocoa/distributed_viewer.rb +0 -86
  132. data/support/celerity_viewer/rubycocoa/main.m +0 -7
  133. data/support/celerity_viewer/rubycocoa/main.rb +0 -27
  134. data/tasks/benchmark.rake +0 -4
  135. data/tasks/environment.rake +0 -7
  136. data/tasks/simple_ci.rake +0 -94
@@ -1,15 +1,14 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe FileField do
3
+ describe "FileField" do
4
4
  before :all do
5
- @browser = IE.new
6
- add_spec_checker(@browser)
5
+ @browser = Browser.new
7
6
  end
8
7
 
9
8
  before :each do
10
9
  @browser.goto(TEST_HOST + "/forms_with_input_elements.html")
11
10
  end
12
-
11
+
13
12
  describe "#exist?" do
14
13
  it "should return true if the file field exists" do
15
14
  @browser.file_field(:id, 'new_user_portrait').should exist
@@ -21,9 +20,11 @@ describe FileField do
21
20
  @browser.file_field(:index, 1).should exist
22
21
  @browser.file_field(:xpath, "//input[@id='new_user_portrait']").should exist
23
22
  end
23
+
24
24
  it "should return true if the element exists (default how = :name)" do
25
25
  @browser.file_field("new_user_portrait").should exist
26
26
  end
27
+
27
28
  it "should return false if the file field doesn't exist" do
28
29
  @browser.file_field(:id, 'no_such_id').should_not exist
29
30
  @browser.file_field(:id, /no_such_id/).should_not exist
@@ -34,7 +35,7 @@ describe FileField do
34
35
  @browser.file_field(:index, 1337).should_not exist
35
36
  @browser.file_field(:xpath, "//input[@id='no_such_id']").should_not exist
36
37
  end
37
-
38
+
38
39
  it "should raise ArgumentError when 'what' argument is invalid" do
39
40
  lambda { @browser.file_field(:id, 3.14).exists? }.should raise_error(ArgumentError)
40
41
  end
@@ -43,54 +44,68 @@ describe FileField do
43
44
  lambda { @browser.file_field(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
44
45
  end
45
46
  end
46
-
47
+
47
48
  # Attribute methods
48
49
 
49
50
  describe "#class_name" do
50
51
  it "should return the class attribute if the text field exists" do
51
52
  @browser.file_field(:index, 1).class_name.should == "portrait"
52
53
  end
54
+
53
55
  it "should raise UnknownObjectException if the text field doesn't exist" do
54
56
  lambda { @browser.file_field(:index, 1337).class_name }.should raise_error(UnknownObjectException)
55
57
  end
56
58
  end
57
-
59
+
58
60
  describe "#id" do
59
61
  it "should return the id attribute if the text field exists" do
60
62
  @browser.file_field(:index, 1).id.should == "new_user_portrait"
61
63
  end
64
+
62
65
  it "should raise UnknownObjectException if the text field doesn't exist" do
63
66
  lambda { @browser.file_field(:index, 1337).id }.should raise_error(UnknownObjectException)
64
67
  end
65
68
  end
66
-
69
+
67
70
  describe "#name" do
68
71
  it "should return the name attribute if the text field exists" do
69
72
  @browser.file_field(:index, 1).name.should == "new_user_portrait"
70
73
  end
74
+
71
75
  it "should raise UnknownObjectException if the text field doesn't exist" do
72
76
  lambda { @browser.file_field(:index, 1337).name }.should raise_error(UnknownObjectException)
73
77
  end
74
78
  end
75
-
79
+
76
80
  describe "#title" do
77
81
  it "should return the title attribute if the text field exists" do
78
82
  @browser.file_field(:id, "new_user_portrait").title.should == "Smile!"
79
83
  end
80
84
  end
81
-
85
+
82
86
  describe "#type" do
83
87
  it "should return the type attribute if the text field exists" do
84
88
  @browser.file_field(:index, 1).type.should == "file"
85
89
  end
90
+
86
91
  it "should raise UnknownObjectException if the text field doesn't exist" do
87
92
  lambda { @browser.file_field(:index, 1337).type }.should raise_error(UnknownObjectException)
88
93
  end
89
94
  end
90
-
91
-
95
+
96
+ describe "#respond_to?" do
97
+ it "should return true for all attribute methods" do
98
+ @browser.file_field(:index, 1).should respond_to(:class_name)
99
+ @browser.file_field(:index, 1).should respond_to(:id)
100
+ @browser.file_field(:index, 1).should respond_to(:name)
101
+ @browser.file_field(:index, 1).should respond_to(:title)
102
+ @browser.file_field(:index, 1).should respond_to(:type)
103
+ @browser.file_field(:index, 1).should respond_to(:value)
104
+ end
105
+ end
106
+
92
107
  # Manipulation methods
93
-
108
+
94
109
  describe "#set" do
95
110
  it "should be able to set a file path in the field and click the upload button and fire the onchange event" do
96
111
  @browser.file_field(:name, "new_user_portrait").set(__FILE__)
@@ -1,10 +1,9 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe FileFields do
3
+ describe "FileFields" do
4
4
 
5
5
  before :all do
6
- @browser = IE.new
7
- add_spec_checker(@browser)
6
+ @browser = Browser.new
8
7
  end
9
8
 
10
9
  before :each do
@@ -1,9 +1,8 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe Form do
3
+ describe "Form" do
4
4
  before :all do
5
- @browser = IE.new
6
- add_spec_checker(@browser)
5
+ @browser = Browser.new
7
6
  end
8
7
 
9
8
  before :each do
@@ -23,9 +22,11 @@ describe Form do
23
22
  @browser.form(:index, 1).should exist
24
23
  @browser.form(:xpath, "//form[@id='new_user']").should exist
25
24
  end
25
+
26
26
  it "should return true if the element exists (default how = :name)" do
27
27
  @browser.form("user_new").should exist
28
28
  end
29
+
29
30
  it "should return false if the form doesn't exist" do
30
31
  @browser.form(:id, 'no_such_id').should_not exist
31
32
  @browser.form(:id, /no_such_id/).should_not exist
@@ -38,9 +39,11 @@ describe Form do
38
39
  @browser.form(:index, 1337).should_not exist
39
40
  @browser.form(:xpath, "//form[@id='no_such_id']").should_not exist
40
41
  end
42
+
41
43
  it "should raise ArgumentError when 'what' argument is invalid" do
42
44
  lambda { @browser.form(:id, 3.14).exists? }.should raise_error(ArgumentError)
43
45
  end
46
+
44
47
  it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
45
48
  lambda { @browser.form(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
46
49
  end
@@ -1,10 +1,9 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe Forms do
3
+ describe "Forms" do
4
4
 
5
5
  before :all do
6
- @browser = IE.new
7
- add_spec_checker(@browser)
6
+ @browser = Browser.new
8
7
  end
9
8
 
10
9
  before :each do
@@ -1,15 +1,14 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe Frame do
3
+ describe "Frame" do
4
4
  before :all do
5
- @browser = IE.new
6
- add_spec_checker(@browser)
5
+ @browser = Browser.new
7
6
  end
8
7
 
9
8
  before :each do
10
9
  @browser.goto(TEST_HOST + "/frames.html")
11
10
  end
12
-
11
+
13
12
  it "should handle crossframe javascript" do
14
13
  @browser.frame(:id, "frame_1").text_field(:name, 'senderElement').value.should == 'send_this_value'
15
14
  @browser.frame(:id, "frame_2").text_field(:name, 'recieverElement').value.should == 'old_value'
@@ -31,6 +30,7 @@ describe Frame do
31
30
  @browser.frame(:index, 1).should exist
32
31
  @browser.frame(:xpath, "//frame[@id='frame_1']").should exist
33
32
  end
33
+
34
34
  it "should return true if the iframe exists" do
35
35
  @browser.goto(TEST_HOST + "/iframes.html")
36
36
  @browser.frame(:id, "frame_1").should exist
@@ -44,11 +44,13 @@ describe Frame do
44
44
  @browser.frame(:index, 1).should exist
45
45
  @browser.frame(:xpath, "//iframe[@id='frame_1']").should exist
46
46
  end
47
+
47
48
  it "should return true if the element exists (default how = :name)" do
48
49
  @browser.frame("frame1").should exist
49
50
  @browser.goto(TEST_HOST + "/iframes.html")
50
51
  @browser.frame("frame1").should exist
51
52
  end
53
+
52
54
  it "should return false if the frame doesn't exist" do
53
55
  @browser.frame(:id, "no_such_id").should_not exist
54
56
  @browser.frame(:id, /no_such_id/).should_not exist
@@ -61,26 +63,32 @@ describe Frame do
61
63
  @browser.frame(:index, 1337).should_not exist
62
64
  @browser.frame(:xpath, "//frame[@id='no_such_id']").should_not exist
63
65
  end
66
+
64
67
  it "should raise ArgumentError when 'what' argument is invalid" do
65
68
  lambda { @browser.frame(:id, 3.14).exists? }.should raise_error(ArgumentError)
66
69
  end
70
+
67
71
  it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
68
72
  lambda { @browser.frame(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
69
73
  end
70
74
  end
71
-
75
+
72
76
  it "should raise UnknownFrameException when accessing elements inside non-existing frame" do
73
77
  lambda { @browser.frame(:name, "no_such_name").p(:index, 1).id }.should raise_error(UnknownFrameException)
74
78
  end
79
+
75
80
  it "should raise UnknownFrameException when accessing a non-existing frame" do
76
81
  lambda { @browser.frame(:name, "no_such_name").p(:index, 1).id }.should raise_error(UnknownFrameException)
77
82
  end
83
+
78
84
  it "should raise UnknownFrameException when accessing a non-existing subframe" do
79
85
  lambda { @browser.frame(:name, "frame1").frame(:name, "no_such_name").p(:index, 1).id }.should raise_error(UnknownFrameException)
80
86
  end
87
+
81
88
  it "should raise UnknownObjectException when accessing a non-existing element inside an existing frame" do
82
89
  lambda { @browser.frame(:index, 1).p(:index, 1337).id }.should raise_error(UnknownObjectException)
83
90
  end
91
+
84
92
  it "should be able to send a value to another frame by using Javascript" do
85
93
  frame1, frame2 = @browser.frame(:index, 1), @browser.frame(:index, 2)
86
94
  frame1.text_field(:index, 1).value.should == "send_this_value"
@@ -93,6 +101,7 @@ describe Frame do
93
101
  it "should find text in a frame" do
94
102
  @browser.frame(:name, 'frame1').contains_text('Suspendisse sit amet nisi.').should be_instance_of(Fixnum)
95
103
  end
104
+
96
105
  it "should raise ArgumentError when given an invalid argument" do
97
106
  lambda { @browser.frame(:name, 'frame1').contains_text(3.14) }.should raise_error(ArgumentError)
98
107
  end
@@ -0,0 +1,71 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "Frames" do
4
+
5
+ before :all do
6
+ @browser = Browser.new
7
+ end
8
+
9
+ describe "<frame> elements" do
10
+
11
+ before :each do
12
+ @browser.goto(TEST_HOST + "/frames.html")
13
+ end
14
+
15
+ describe "#length" do
16
+ it "should return the correct number of frames" do
17
+ @browser.frames.length.should == 2
18
+ end
19
+ end
20
+
21
+ describe "#[]" do
22
+ it "should return the frame at the given index" do
23
+ @browser.frames[1].id.should == "frame_1"
24
+ end
25
+ end
26
+
27
+ describe "#each" do
28
+ it "should iterate through frames correctly" do
29
+ @browser.frames.each_with_index do |f, index|
30
+ f.name.should == @browser.frame(:index, index+1).name
31
+ f.id.should == @browser.frame(:index, index+1).id
32
+ f.value.should == @browser.frame(:index, index+1).value
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ describe "<iframe> elements" do
39
+
40
+ before :each do
41
+ @browser.goto(TEST_HOST + "/iframes.html")
42
+ end
43
+
44
+ describe "#length" do
45
+ it "should return the correct number of frames" do
46
+ @browser.frames.length.should == 2
47
+ end
48
+ end
49
+
50
+ describe "#[]" do
51
+ it "should return the frame at the given index" do
52
+ @browser.frames[1].id.should == "frame_1"
53
+ end
54
+ end
55
+
56
+ describe "#each" do
57
+ it "should iterate through frames correctly" do
58
+ @browser.frames.each_with_index do |f, index|
59
+ f.name.should == @browser.frame(:index, index+1).name
60
+ f.id.should == @browser.frame(:index, index+1).id
61
+ f.value.should == @browser.frame(:index, index+1).value
62
+ end
63
+ end
64
+ end
65
+ end
66
+
67
+ after :all do
68
+ @browser.close
69
+ end
70
+
71
+ end
@@ -1,10 +1,9 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe Hidden do
3
+ describe "Hidden" do
4
4
 
5
5
  before :all do
6
- @browser = IE.new
7
- add_spec_checker(@browser)
6
+ @browser = Browser.new
8
7
  end
9
8
 
10
9
  before :each do
@@ -28,9 +27,11 @@ describe Hidden do
28
27
  @browser.hidden(:index, 1).should exist
29
28
  @browser.hidden(:xpath, "//input[@id='new_user_interests_dolls']").should exist
30
29
  end
30
+
31
31
  it "should return true if the element exists (default how = :name)" do
32
32
  @browser.hidden("new_user_interests").should exist
33
33
  end
34
+
34
35
  it "should return false if the element does not exist" do
35
36
  @browser.hidden(:id, 'no_such_id').should_not exist
36
37
  @browser.hidden(:id, /no_such_id/).should_not exist
@@ -45,9 +46,11 @@ describe Hidden do
45
46
  @browser.hidden(:index, 1337).should_not exist
46
47
  @browser.hidden(:xpath, "//input[@id='no_such_id']").should_not exist
47
48
  end
49
+
48
50
  it "should raise ArgumentError when 'what' argument is invalid" do
49
51
  lambda { @browser.hidden(:id, 3.14).exists? }.should raise_error(ArgumentError)
50
52
  end
53
+
51
54
  it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
52
55
  lambda { @browser.hidden(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
53
56
  end
@@ -59,6 +62,7 @@ describe Hidden do
59
62
  it "should return the id attribute if the text field exists" do
60
63
  @browser.hidden(:index, 1).id.should == "new_user_interests_dolls"
61
64
  end
65
+
62
66
  it "should raise UnknownObjectException if the text field doesn't exist" do
63
67
  lambda { @browser.hidden(:index, 1337).id }.should raise_error(UnknownObjectException)
64
68
  end
@@ -68,6 +72,7 @@ describe Hidden do
68
72
  it "should return the name attribute if the text field exists" do
69
73
  @browser.hidden(:index, 1).name.should == "new_user_interests"
70
74
  end
75
+
71
76
  it "should raise UnknownObjectException if the text field doesn't exist" do
72
77
  lambda { @browser.hidden(:index, 1337).name }.should raise_error(UnknownObjectException)
73
78
  end
@@ -77,6 +82,7 @@ describe Hidden do
77
82
  it "should return the type attribute if the text field exists" do
78
83
  @browser.hidden(:index, 1).type.should == "hidden"
79
84
  end
85
+
80
86
  it "should raise UnknownObjectException if the text field doesn't exist" do
81
87
  lambda { @browser.hidden(:index, 1337).type }.should raise_error(UnknownObjectException)
82
88
  end
@@ -86,17 +92,29 @@ describe Hidden do
86
92
  it "should return the value attribute if the text field exists" do
87
93
  @browser.hidden(:index, 1).value.should == "dolls"
88
94
  end
95
+
89
96
  it "should raise UnknownObjectException if the text field doesn't exist" do
90
97
  lambda { @browser.hidden(:index, 1337).value }.should raise_error(UnknownObjectException)
91
98
  end
92
99
  end
93
100
 
101
+ describe "#respond_to?" do
102
+ it "should return true for all attribute methods" do
103
+ @browser.hidden(:index, 1).should respond_to(:id)
104
+ @browser.hidden(:index, 1).should respond_to(:name)
105
+ @browser.hidden(:index, 1).should respond_to(:type)
106
+ @browser.hidden(:index, 1).should respond_to(:value)
107
+ end
108
+ end
109
+
110
+
94
111
  # Manipulation methods
95
112
  describe "#value=" do
96
113
  it "should set the value of the element" do
97
114
  @browser.hidden(:id, 'new_user_interests_dolls').value = 'guns'
98
115
  @browser.hidden(:id, "new_user_interests_dolls").value.should == 'guns'
99
116
  end
117
+
100
118
  it "should raise UnknownObjectException if the text field doesn't exist" do
101
119
  lambda { @browser.hidden(:id, 'no_such_id').value = 'guns' }.should raise_error(UnknownObjectException)
102
120
  end
@@ -1,9 +1,8 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe Hiddens do
3
+ describe "Hiddens" do
4
4
  before :all do
5
- @browser = IE.new
6
- add_spec_checker(@browser)
5
+ @browser = Browser.new
7
6
  end
8
7
 
9
8
  before :each do
@@ -1,10 +1,9 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe H1, H2, H3, H4, H5, H6 do
3
+ describe "H1", "H2", "H3", "H4", "H5", "H6" do
4
4
 
5
5
  before :all do
6
- @browser = IE.new
7
- add_spec_checker(@browser)
6
+ @browser = Browser.new
8
7
  end
9
8
 
10
9
  before :each do
@@ -14,16 +13,19 @@ describe H1, H2, H3, H4, H5, H6 do
14
13
  # Exists method
15
14
  describe "#exist?" do
16
15
  it "should return true if the element exists" do
17
- @browser.h1(:id, "first_header").should exist
18
- @browser.h1(:id, /first_header/).should exist
19
- @browser.h1(:text, "Header 1").should exist
20
- @browser.h1(:text, /Header 1/).should exist
21
- @browser.h1(:index, 1).should exist
16
+ @browser.h1(:id, "header1").should exist
17
+ @browser.h2(:id, /header2/).should exist
18
+ @browser.h3(:text, "Header 3").should exist
19
+ @browser.h4(:text, /Header 4/).should exist
20
+ @browser.h5(:index, 1).should exist
21
+ @browser.h6(:index, 1).should exist
22
22
  @browser.h1(:xpath, "//h1[@id='first_header']").should exist
23
23
  end
24
+
24
25
  it "should return true if the element exists (default how = :id)" do
25
26
  @browser.h1("first_header").should exist
26
27
  end
28
+
27
29
  it "should return true if the element exists" do
28
30
  @browser.h1(:id, "no_such_id").should_not exist
29
31
  @browser.h1(:id, /no_such_id/).should_not exist
@@ -32,9 +34,11 @@ describe H1, H2, H3, H4, H5, H6 do
32
34
  @browser.h1(:index, 1337).should_not exist
33
35
  @browser.h1(:xpath, "//p[@id='no_such_id']").should_not exist
34
36
  end
37
+
35
38
  it "should raise ArgumentError when 'what' argument is invalid" do
36
39
  lambda { @browser.h1(:id, 3.14).exists? }.should raise_error(ArgumentError)
37
40
  end
41
+
38
42
  it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
39
43
  lambda { @browser.h1(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
40
44
  end
@@ -45,9 +49,11 @@ describe H1, H2, H3, H4, H5, H6 do
45
49
  it "should return the class attribute" do
46
50
  @browser.h1(:index, 1).class_name.should == 'primary'
47
51
  end
52
+
48
53
  it "should return an empty string if the element exists and the attribute doesn't" do
49
54
  @browser.h2(:index, 1).class_name.should == ''
50
55
  end
56
+
51
57
  it "should raise UnknownObjectException if the p doesn't exist" do
52
58
  lambda { @browser.h2(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
53
59
  end
@@ -57,9 +63,11 @@ describe H1, H2, H3, H4, H5, H6 do
57
63
  it "should return the id attribute" do
58
64
  @browser.h1(:index, 1).id.should == "first_header"
59
65
  end
66
+
60
67
  it "should return an empty string if the element exists and the attribute doesn't" do
61
- @browser.h2(:index, 1).id.should == ''
68
+ @browser.h3(:index, 1).id.should == ''
62
69
  end
70
+
63
71
  it "should raise UnknownObjectException if the p doesn't exist" do
64
72
  lambda { @browser.h1(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
65
73
  lambda { @browser.h1(:index, 1337).id }.should raise_error(UnknownObjectException)
@@ -70,12 +78,22 @@ describe H1, H2, H3, H4, H5, H6 do
70
78
  it "should return the text of the element" do
71
79
  @browser.h1(:index, 1).text.should == 'Header 1'
72
80
  end
81
+
73
82
  it "should return an empty string if the element doesn't contain any text" do
74
- @browser.h6(:index, 1).text.should == ''
83
+ @browser.h6(:id, "empty_header").text.should == ''
75
84
  end
85
+
76
86
  it "should raise UnknownObjectException if the p doesn't exist" do
77
- lambda { @browser.h1(:id, 'no_such_id').text }.should raise_error( UnknownObjectException)
78
- lambda { @browser.h1(:xpath , "//h1[@id='no_such_id']").text }.should raise_error( UnknownObjectException)
87
+ lambda { @browser.h1(:id, 'no_such_id').text }.should raise_error(UnknownObjectException)
88
+ lambda { @browser.h1(:xpath , "//h1[@id='no_such_id']").text }.should raise_error(UnknownObjectException)
89
+ end
90
+ end
91
+
92
+ describe "#respond_to?" do
93
+ it "should return true for all attribute methods" do
94
+ @browser.h1(:index, 1).should respond_to(:class_name)
95
+ @browser.h1(:index, 1).should respond_to(:id)
96
+ @browser.h1(:index, 1).should respond_to(:text)
79
97
  end
80
98
  end
81
99