watir-webdriver 0.0.1.dev5 → 0.0.1.dev6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/Rakefile +13 -19
  2. data/VERSION +1 -1
  3. data/lib/watir-webdriver.rb +3 -1
  4. data/lib/watir-webdriver/base_element.rb +33 -27
  5. data/lib/watir-webdriver/browser.rb +2 -6
  6. data/lib/watir-webdriver/elements/font.rb +12 -0
  7. data/lib/watir-webdriver/elements/generated.rb +1027 -622
  8. data/lib/watir-webdriver/elements/select_list.rb +3 -3
  9. data/lib/watir-webdriver/locators/element_locator.rb +2 -2
  10. data/lib/watir-webdriver/xpath_support.rb +2 -2
  11. data/support/html5/html5.idl +942 -483
  12. data/support/html5/old/html5.idl +962 -0
  13. data/support/html5/{html5_extras.idl → old/html5_extras.idl} +0 -2
  14. data/support/html5/watir_visitor.rb +23 -19
  15. metadata +74 -100
  16. data/spec/watirspec/area_spec.rb +0 -78
  17. data/spec/watirspec/areas_spec.rb +0 -31
  18. data/spec/watirspec/browser_spec.rb +0 -274
  19. data/spec/watirspec/button_spec.rb +0 -242
  20. data/spec/watirspec/buttons_spec.rb +0 -48
  21. data/spec/watirspec/checkbox_spec.rb +0 -272
  22. data/spec/watirspec/checkboxes_spec.rb +0 -32
  23. data/spec/watirspec/dd_spec.rb +0 -123
  24. data/spec/watirspec/dds_spec.rb +0 -31
  25. data/spec/watirspec/div_spec.rb +0 -211
  26. data/spec/watirspec/divs_spec.rb +0 -31
  27. data/spec/watirspec/dl_spec.rb +0 -123
  28. data/spec/watirspec/dls_spec.rb +0 -32
  29. data/spec/watirspec/dt_spec.rb +0 -123
  30. data/spec/watirspec/dts_spec.rb +0 -31
  31. data/spec/watirspec/element_spec.rb +0 -89
  32. data/spec/watirspec/em_spec.rb +0 -97
  33. data/spec/watirspec/ems_spec.rb +0 -32
  34. data/spec/watirspec/filefield_spec.rb +0 -119
  35. data/spec/watirspec/filefields_spec.rb +0 -32
  36. data/spec/watirspec/form_spec.rb +0 -63
  37. data/spec/watirspec/forms_spec.rb +0 -33
  38. data/spec/watirspec/frame_spec.rb +0 -129
  39. data/spec/watirspec/frames_spec.rb +0 -62
  40. data/spec/watirspec/hidden_spec.rb +0 -102
  41. data/spec/watirspec/hiddens_spec.rb +0 -32
  42. data/spec/watirspec/hn_spec.rb +0 -93
  43. data/spec/watirspec/hns_spec.rb +0 -38
  44. data/spec/watirspec/image_spec.rb +0 -207
  45. data/spec/watirspec/images_spec.rb +0 -31
  46. data/spec/watirspec/label_spec.rb +0 -75
  47. data/spec/watirspec/labels_spec.rb +0 -31
  48. data/spec/watirspec/li_spec.rb +0 -112
  49. data/spec/watirspec/lib/guards.rb +0 -59
  50. data/spec/watirspec/lib/server.rb +0 -127
  51. data/spec/watirspec/lib/spec_helper.rb +0 -79
  52. data/spec/watirspec/lib/watirspec.rb +0 -72
  53. data/spec/watirspec/link_spec.rb +0 -168
  54. data/spec/watirspec/links_spec.rb +0 -35
  55. data/spec/watirspec/lis_spec.rb +0 -31
  56. data/spec/watirspec/map_spec.rb +0 -76
  57. data/spec/watirspec/maps_spec.rb +0 -32
  58. data/spec/watirspec/meta_spec.rb +0 -22
  59. data/spec/watirspec/metas_spec.rb +0 -30
  60. data/spec/watirspec/ol_spec.rb +0 -78
  61. data/spec/watirspec/ols_spec.rb +0 -31
  62. data/spec/watirspec/option_spec.rb +0 -173
  63. data/spec/watirspec/p_spec.rb +0 -128
  64. data/spec/watirspec/pre_spec.rb +0 -112
  65. data/spec/watirspec/pres_spec.rb +0 -31
  66. data/spec/watirspec/ps_spec.rb +0 -31
  67. data/spec/watirspec/radio_spec.rb +0 -255
  68. data/spec/watirspec/radios_spec.rb +0 -32
  69. data/spec/watirspec/select_list_spec.rb +0 -318
  70. data/spec/watirspec/select_lists_spec.rb +0 -35
  71. data/spec/watirspec/span_spec.rb +0 -142
  72. data/spec/watirspec/spans_spec.rb +0 -31
  73. data/spec/watirspec/spec_helper.rb +0 -17
  74. data/spec/watirspec/strong_spec.rb +0 -89
  75. data/spec/watirspec/strongs_spec.rb +0 -32
  76. data/spec/watirspec/table_bodies_spec.rb +0 -45
  77. data/spec/watirspec/table_body_spec.rb +0 -98
  78. data/spec/watirspec/table_cell_spec.rb +0 -68
  79. data/spec/watirspec/table_cells_spec.rb +0 -47
  80. data/spec/watirspec/table_footer_spec.rb +0 -85
  81. data/spec/watirspec/table_footers_spec.rb +0 -47
  82. data/spec/watirspec/table_header_spec.rb +0 -85
  83. data/spec/watirspec/table_headers_spec.rb +0 -45
  84. data/spec/watirspec/table_row_spec.rb +0 -87
  85. data/spec/watirspec/table_rows_spec.rb +0 -50
  86. data/spec/watirspec/table_spec.rb +0 -160
  87. data/spec/watirspec/tables_spec.rb +0 -33
  88. data/spec/watirspec/text_field_spec.rb +0 -276
  89. data/spec/watirspec/text_fields_spec.rb +0 -35
  90. data/spec/watirspec/ul_spec.rb +0 -76
  91. data/spec/watirspec/uls_spec.rb +0 -33
  92. data/support/html5/idl_extractor.rb +0 -73
@@ -1,128 +0,0 @@
1
- # encoding: utf-8
2
- require File.dirname(__FILE__) + '/spec_helper'
3
-
4
- describe "P" do
5
-
6
- before :each do
7
- browser.goto(WatirSpec.files + "/non_control_elements.html")
8
- end
9
-
10
- # Exists method
11
- describe "#exist?" do
12
- it "returns true if the 'p' exists" do
13
- browser.p(:id, "lead").should exist
14
- browser.p(:id, /lead/).should exist
15
- browser.p(:text, "Dubito, ergo cogito, ergo sum.").should exist
16
- browser.p(:text, /Dubito, ergo cogito, ergo sum/).should exist
17
- browser.p(:class, "lead").should exist
18
- browser.p(:class, /lead/).should exist
19
- browser.p(:index, 0).should exist
20
- browser.p(:xpath, "//p[@id='lead']").should exist
21
- end
22
-
23
- it "returns false if the 'p' doesn't exist" do
24
- browser.p(:id, "no_such_id").should_not exist
25
- browser.p(:id, /no_such_id/).should_not exist
26
- browser.p(:text, "no_such_text").should_not exist
27
- browser.p(:text, /no_such_text/).should_not exist
28
- browser.p(:class, "no_such_class").should_not exist
29
- browser.p(:class, /no_such_class/).should_not exist
30
- browser.p(:index, 1337).should_not exist
31
- browser.p(:xpath, "//p[@id='no_such_id']").should_not exist
32
- end
33
-
34
- it "raises TypeError when 'what' argument is invalid" do
35
- lambda { browser.p(:id, 3.14).exists? }.should raise_error(TypeError)
36
- end
37
-
38
- it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
39
- lambda { browser.p(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
40
- end
41
- end
42
-
43
- # Attribute methods
44
- describe "#class_name" do
45
- it "returns the class attribute" do
46
- browser.p(:index, 0).class_name.should == 'lead'
47
- end
48
-
49
- it "returns an empty string if the element exists and the attribute doesn't" do
50
- browser.p(:index, 2).class_name.should == ''
51
- end
52
-
53
- it "raises UnknownObjectException if the p doesn't exist" do
54
- lambda { browser.p(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
55
- end
56
- end
57
-
58
- describe "#id" do
59
- it "returns the id attribute" do
60
- browser.p(:index, 0).id.should == "lead"
61
- end
62
-
63
- it "returns an empty string if the element exists and the attribute doesn't" do
64
- browser.p(:index, 2).id.should == ''
65
- end
66
-
67
- it "raises UnknownObjectException if the p doesn't exist" do
68
- lambda { browser.p(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
69
- lambda { browser.p(:index, 1337).id }.should raise_error(UnknownObjectException)
70
- end
71
- end
72
-
73
- describe "#title" do
74
- it "returns the title attribute" do
75
- browser.p(:index, 0).title.should == 'Lorem ipsum'
76
- end
77
-
78
- it "returns an empty string if the element exists and the attribute doesn't" do
79
- browser.p(:index, 2).title.should == ''
80
- end
81
-
82
- it "raises UnknownObjectException if the p doesn't exist" do
83
- lambda { browser.p(:id, 'no_such_id').title }.should raise_error( UnknownObjectException)
84
- lambda { browser.p(:xpath, "//p[@id='no_such_id']").title }.should raise_error( UnknownObjectException)
85
- end
86
- end
87
-
88
- describe "#text" do
89
- it "returns the text of the p" do
90
- browser.p(:index, 1).text.should == 'Sed pretium metus et quam. Nullam odio dolor, vestibulum non, tempor ut, vehicula sed, sapien. Vestibulum placerat ligula at quam. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.'
91
- end
92
-
93
- it "returns an empty string if the element doesn't contain any text" do
94
- browser.p(:index, 4).text.should == ''
95
- end
96
-
97
- it "raises UnknownObjectException if the p doesn't exist" do
98
- lambda { browser.p(:id, 'no_such_id').text }.should raise_error( UnknownObjectException)
99
- lambda { browser.p(:xpath , "//p[@id='no_such_id']").text }.should raise_error( UnknownObjectException)
100
- end
101
- end
102
-
103
- describe "#value" do
104
- it "returns the value attribute" do
105
- browser.p(:index, 1).value.should == "invalid_attribute"
106
- end
107
-
108
- it "returns an empty string if the element exists and the attribute doesn't" do
109
- browser.p(:index, 2).value.should == ''
110
- end
111
-
112
- it "raises UnknownObjectException if the p doesn't exist" do
113
- lambda { browser.p(:id , "no_such_id").value }.should raise_error(UnknownObjectException)
114
- lambda { browser.p(:index , 1337).value }.should raise_error(UnknownObjectException)
115
- end
116
- end
117
-
118
- describe "#respond_to?" do
119
- it "returns true for all attribute methods" do
120
- browser.p(:index, 0).should respond_to(:class_name)
121
- browser.p(:index, 0).should respond_to(:id)
122
- browser.p(:index, 0).should respond_to(:title)
123
- browser.p(:index, 0).should respond_to(:text)
124
- browser.p(:index, 0).should respond_to(:value)
125
- end
126
- end
127
-
128
- end
@@ -1,112 +0,0 @@
1
- # encoding: utf-8
2
- require File.dirname(__FILE__) + '/spec_helper'
3
-
4
- describe "Pre" do
5
-
6
- before :each do
7
- browser.goto(WatirSpec.files + "/non_control_elements.html")
8
- end
9
-
10
- # Exists method
11
- describe "#exist?" do
12
- it "returns true if the 'p' exists" do
13
- browser.pre(:id, "rspec").should exist
14
- browser.pre(:id, /rspec/).should exist
15
- browser.pre(:text, 'browser.pre(:id, "rspec").should exist').should exist
16
- browser.pre(:text, /browser\.pre/).should exist
17
- browser.pre(:class, "ruby").should exist
18
- browser.pre(:class, /ruby/).should exist
19
- browser.pre(:index, 0).should exist
20
- browser.pre(:xpath, "//pre[@id='rspec']").should exist
21
- end
22
-
23
- it "returns false if the 'p' doesn't exist" do
24
- browser.pre(:id, "no_such_id").should_not exist
25
- browser.pre(:id, /no_such_id/).should_not exist
26
- browser.pre(:text, "no_such_text").should_not exist
27
- browser.pre(:text, /no_such_text/).should_not exist
28
- browser.pre(:class, "no_such_class").should_not exist
29
- browser.pre(:class, /no_such_class/).should_not exist
30
- browser.pre(:index, 1337).should_not exist
31
- browser.pre(:xpath, "//pre[@id='no_such_id']").should_not exist
32
- end
33
-
34
- it "raises TypeError when 'what' argument is invalid" do
35
- lambda { browser.pre(:id, 3.14).exists? }.should raise_error(TypeError)
36
- end
37
-
38
- it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
39
- lambda { browser.pre(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
40
- end
41
- end
42
-
43
- # Attribute methods
44
- describe "#class_name" do
45
- it "returns the class attribute" do
46
- browser.pre(:id, 'rspec').class_name.should == 'ruby'
47
- end
48
-
49
- it "returns an empty string if the element exists and the attribute doesn't" do
50
- browser.pre(:index, 0).class_name.should == ''
51
- end
52
-
53
- it "raises UnknownObjectException if the p doesn't exist" do
54
- lambda { browser.pre(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
55
- end
56
- end
57
-
58
- describe "#id" do
59
- it "returns the id attribute" do
60
- browser.pre(:class, 'ruby').id.should == "rspec"
61
- end
62
-
63
- it "returns an empty string if the element exists and the attribute doesn't" do
64
- browser.pre(:index, 0).id.should == ''
65
- end
66
-
67
- it "raises UnknownObjectException if the pre doesn't exist" do
68
- lambda { browser.pre(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
69
- lambda { browser.pre(:index, 1337).id }.should raise_error(UnknownObjectException)
70
- end
71
- end
72
-
73
- describe "#title" do
74
- it "returns the title attribute" do
75
- browser.pre(:class, 'brainfuck').title.should == 'The brainfuck language is an esoteric programming language noted for its extreme minimalism'
76
- end
77
-
78
- it "returns an empty string if the element exists and the attribute doesn't" do
79
- browser.pre(:index, 0).title.should == ''
80
- end
81
-
82
- it "raises UnknownObjectException if the pre doesn't exist" do
83
- lambda { browser.pre(:id, 'no_such_id').title }.should raise_error( UnknownObjectException)
84
- lambda { browser.pre(:xpath, "//pre[@id='no_such_id']").title }.should raise_error( UnknownObjectException)
85
- end
86
- end
87
-
88
- describe "#text" do
89
- it "returns the text of the pre" do
90
- browser.pre(:class, 'haskell').text.should == 'main = putStrLn "Hello World"'
91
- end
92
-
93
- it "returns an empty string if the element doesn't contain any text" do
94
- browser.pre(:index, 0).text.should == ''
95
- end
96
-
97
- it "raises UnknownObjectException if the pre doesn't exist" do
98
- lambda { browser.pre(:id, 'no_such_id').text }.should raise_error( UnknownObjectException)
99
- lambda { browser.pre(:xpath , "//pre[@id='no_such_id']").text }.should raise_error( UnknownObjectException)
100
- end
101
- end
102
-
103
- describe "#respond_to?" do
104
- it "returns true for all attribute methods" do
105
- browser.image(:index, 0).should respond_to(:class_name)
106
- browser.image(:index, 0).should respond_to(:id)
107
- browser.image(:index, 0).should respond_to(:title)
108
- browser.image(:index, 0).should respond_to(:text)
109
- end
110
- end
111
-
112
- end
@@ -1,31 +0,0 @@
1
- # encoding: utf-8
2
- require File.dirname(__FILE__) + '/spec_helper'
3
-
4
- describe "Pres" do
5
-
6
- before :each do
7
- browser.goto(WatirSpec.files + "/non_control_elements.html")
8
- end
9
-
10
- describe "#length" do
11
- it "returns the number of pres" do
12
- browser.pres.length.should == 7
13
- end
14
- end
15
-
16
- describe "#[]" do
17
- it "returns the pre at the given index" do
18
- browser.pres[1].id.should == "rspec"
19
- end
20
- end
21
-
22
- describe "#each" do
23
- it "iterates through pres correctly" do
24
- browser.pres.each_with_index do |p, index|
25
- p.id.should == browser.pre(:index, index).id
26
- p.value.should == browser.pre(:index, index).value
27
- end
28
- end
29
- end
30
-
31
- end
@@ -1,31 +0,0 @@
1
- # encoding: utf-8
2
- require File.dirname(__FILE__) + '/spec_helper'
3
-
4
- describe "Ps" do
5
-
6
- before :each do
7
- browser.goto(WatirSpec.files + "/non_control_elements.html")
8
- end
9
-
10
- describe "#length" do
11
- it "returns the number of ps" do
12
- browser.ps.length.should == 5
13
- end
14
- end
15
-
16
- describe "#[]" do
17
- it "returns the p at the given index" do
18
- browser.ps[0].id.should == "lead"
19
- end
20
- end
21
-
22
- describe "#each" do
23
- it "iterates through ps correctly" do
24
- browser.ps.each_with_index do |p, index|
25
- p.id.should == browser.p(:index, index).id
26
- p.value.should == browser.p(:index, index).value
27
- end
28
- end
29
- end
30
-
31
- end
@@ -1,255 +0,0 @@
1
- # encoding: utf-8
2
- require File.dirname(__FILE__) + '/spec_helper'
3
-
4
- describe "Radio" do
5
-
6
- before :each do
7
- browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
8
- end
9
-
10
- # Exists method
11
- describe "#exists?" do
12
- it "returns true if the radio button exists" do
13
- browser.radio(:id, "new_user_newsletter_yes").should exist
14
- browser.radio(:id, /new_user_newsletter_yes/).should exist
15
- browser.radio(:name, "new_user_newsletter").should exist
16
- browser.radio(:name, /new_user_newsletter/).should exist
17
- browser.radio(:value, "yes").should exist
18
- browser.radio(:value, /yes/).should exist
19
- # TODO: figure out what :text means for a radio button
20
- # browser.radio(:text, "yes").should exist
21
- # browser.radio(:text, /yes/).should exist
22
- browser.radio(:class, "huge").should exist
23
- browser.radio(:class, /huge/).should exist
24
- browser.radio(:index, 0).should exist
25
- browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").should exist
26
- end
27
-
28
- it "returns true if the radio button exists (search by name and value)" do
29
- browser.radio(:name => "new_user_newsletter", :value => 'yes').should exist
30
- browser.radio(:xpath, "//input[@name='new_user_newsletter' and @value='yes']").set
31
- end
32
-
33
- it "returns false if the radio button does not exist" do
34
- browser.radio(:id, "no_such_id").should_not exist
35
- browser.radio(:id, /no_such_id/).should_not exist
36
- browser.radio(:name, "no_such_name").should_not exist
37
- browser.radio(:name, /no_such_name/).should_not exist
38
- browser.radio(:value, "no_such_value").should_not exist
39
- browser.radio(:value, /no_such_value/).should_not exist
40
- browser.radio(:text, "no_such_text").should_not exist
41
- browser.radio(:text, /no_such_text/).should_not exist
42
- browser.radio(:class, "no_such_class").should_not exist
43
- browser.radio(:class, /no_such_class/).should_not exist
44
- browser.radio(:index, 1337).should_not exist
45
- browser.radio(:xpath, "input[@id='no_such_id']").should_not exist
46
- end
47
-
48
- it "returns false if the radio button does not exist (search by name and value)" do
49
- browser.radio(:name => "new_user_newsletter", :value => 'no_such_value').should_not exist
50
- browser.radio(:xpath, "//input[@name='new_user_newsletter' and @value='no_such_value']").should_not exist
51
- browser.radio(:name => "no_such_name", :value => 'yes').should_not exist
52
- browser.radio(:xpath, "//input[@name='no_such_name' and @value='yes']").should_not exist
53
- end
54
-
55
- it "returns true for radios with a string value" do
56
- browser.radio(:name => 'new_user_newsletter', :value => 'yes').should exist
57
- browser.radio(:name => 'new_user_newsletter', :value => 'no').should exist
58
- end
59
-
60
- it "raises TypeError when 'what' argument is invalid" do
61
- lambda { browser.radio(:id, 3.14).exists? }.should raise_error(TypeError)
62
- end
63
-
64
- it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
65
- lambda { browser.radio(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
66
- end
67
- end
68
-
69
- # Attribute methods
70
- describe "#class_name" do
71
- it "returns the class name if the radio exists and has an attribute" do
72
- browser.radio(:id, "new_user_newsletter_yes").class_name.should == "huge"
73
- end
74
-
75
- it "returns an emptry string if the radio exists and the attribute doesn't" do
76
- browser.radio(:id, "new_user_newsletter_no").class_name.should == ""
77
- end
78
-
79
- it "raises UnknownObjectException if the radio doesn't exist" do
80
- lambda { browser.radio(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
81
- end
82
- end
83
-
84
- describe "#id" do
85
- it "returns the id attribute if the radio exists and has an attribute" do
86
- browser.radio(:index, 0).id.should == "new_user_newsletter_yes"
87
- end
88
-
89
- it "returns an emptry string if the radio exists and the attribute doesn't" do
90
- browser.radio(:index, 2).id.should == ""
91
- end
92
-
93
- it "raises UnknownObjectException if the radio doesn't exist" do
94
- lambda { browser.radio(:index, 1337).id }.should raise_error(UnknownObjectException)
95
- end
96
- end
97
-
98
- describe "#name" do
99
- it "returns the name attribute if the radio exists" do
100
- browser.radio(:id, 'new_user_newsletter_yes').name.should == "new_user_newsletter"
101
- end
102
-
103
- it "returns an empty string if the radio exists and the attribute doesn't" do
104
- browser.radio(:id, 'new_user_newsletter_absolutely').name.should == ""
105
- end
106
-
107
- it "raises UnknownObjectException if the radio doesn't exist" do
108
- lambda { browser.radio(:index, 1337).name }.should raise_error(UnknownObjectException)
109
- end
110
- end
111
-
112
- describe "#title" do
113
- it "returns the title attribute if the radio exists" do
114
- browser.radio(:id, "new_user_newsletter_no").title.should == "Traitor!"
115
- end
116
-
117
- it "returns an emptry string if the radio exists and the attribute doesn't" do
118
- browser.radio(:id, "new_user_newsletter_yes").title.should == ""
119
- end
120
-
121
- it "raises UnknownObjectException if the radio doesn't exist" do
122
- lambda { browser.radio(:index, 1337).title }.should raise_error(UnknownObjectException)
123
- end
124
- end
125
-
126
- describe "#type" do
127
- it "returns the type attribute if the radio exists" do
128
- browser.radio(:index, 0).type.should == "radio"
129
- end
130
-
131
- it "raises UnknownObjectException if the radio doesn't exist" do
132
- lambda { browser.radio(:index, 1337).type }.should raise_error(UnknownObjectException)
133
- end
134
- end
135
-
136
- describe "#value" do
137
- it "returns the value attribute if the radio exists" do
138
- browser.radio(:id, 'new_user_newsletter_yes').value.should == 'yes'
139
- end
140
-
141
- it "raises UnknownObjectException if the radio doesn't exist" do
142
- lambda { browser.radio(:index, 1337).value}.should raise_error(UnknownObjectException)
143
- end
144
- end
145
-
146
- describe "#respond_to?" do
147
- it "returns true for all attribute methods" do
148
- browser.radio(:index, 0).should respond_to(:class_name)
149
- browser.radio(:index, 0).should respond_to(:id)
150
- browser.radio(:index, 0).should respond_to(:name)
151
- browser.radio(:index, 0).should respond_to(:title)
152
- browser.radio(:index, 0).should respond_to(:type)
153
- browser.radio(:index, 0).should respond_to(:value)
154
- end
155
- end
156
-
157
- # Access methods
158
- describe "#enabled?" do
159
- it "returns true if the radio button is enabled" do
160
- browser.radio(:id, "new_user_newsletter_yes").should be_enabled
161
- browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").should be_enabled
162
- end
163
-
164
- it "returns false if the radio button is disabled" do
165
- browser.radio(:id, "new_user_newsletter_nah").should_not be_enabled
166
- browser.radio(:xpath,"//input[@id='new_user_newsletter_nah']").should_not be_enabled
167
- end
168
-
169
- it "raises UnknownObjectException if the radio button doesn't exist" do
170
- lambda { browser.radio(:id, "no_such_id").enabled? }.should raise_error(UnknownObjectException)
171
- lambda { browser.radio(:xpath, "//input[@id='no_such_id']").enabled? }.should raise_error(UnknownObjectException)
172
- end
173
- end
174
-
175
- describe "#disabled?" do
176
- it "returns true if the radio is disabled" do
177
- browser.radio(:id, 'new_user_newsletter_nah').should be_disabled
178
- end
179
-
180
- it "returns false if the radio is enabled" do
181
- browser.radio(:id, 'new_user_newsletter_yes').should_not be_disabled
182
- end
183
-
184
- it "raises UnknownObjectException if the radio doesn't exist" do
185
- lambda { browser.radio(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
186
- end
187
- end
188
-
189
- describe "#set" do
190
- it "sets the radio button" do
191
- browser.radio(:id, "new_user_newsletter_no").set
192
- browser.radio(:id, "new_user_newsletter_no").should be_set
193
- end
194
-
195
- it "sets the radio button when found by :xpath" do
196
- browser.radio(:xpath, "//input[@id='new_user_newsletter_no']").set
197
- browser.radio(:xpath, "//input[@id='new_user_newsletter_no']").should be_set
198
- end
199
-
200
- it "fires the onclick event" do
201
- browser.radio(:id, "new_user_newsletter_no").set
202
- browser.radio(:id, "new_user_newsletter_yes").set
203
- messages.should == ["clicked: new_user_newsletter_no", "clicked: new_user_newsletter_yes"]
204
- end
205
-
206
- bug "WTR-337", :watir do
207
- it "fires the onchange event" do
208
- browser.radio(:value, 'certainly').set
209
- messages.should == ["changed: new_user_newsletter"]
210
-
211
- browser.radio(:value, 'certainly').set
212
- messages.should == ["changed: new_user_newsletter"] # no event fired here - didn't change
213
-
214
- browser.radio(:value, 'yes').set
215
- browser.radio(:value, 'certainly').set
216
- messages.should == ["changed: new_user_newsletter", "clicked: new_user_newsletter_yes", "changed: new_user_newsletter"]
217
- end
218
- end
219
-
220
- it "raises UnknownObjectException if the radio button doesn't exist" do
221
- lambda { browser.radio(:name, "no_such_name").set }.should raise_error(UnknownObjectException)
222
- lambda { browser.radio(:xpath, "//input[@name='no_such_name']").set }.should raise_error(UnknownObjectException)
223
- end
224
-
225
- it "raises ObjectDisabledException if the radio is disabled" do
226
- lambda { browser.radio(:id, "new_user_newsletter_nah").set }.should raise_error(ObjectDisabledException)
227
- lambda { browser.radio(:xpath, "//input[@id='new_user_newsletter_nah']").set }.should raise_error(ObjectDisabledException )
228
- end
229
- end
230
-
231
- # Other
232
- describe '#set?' do
233
- it "returns true if the radio button is set" do
234
- browser.radio(:id, "new_user_newsletter_yes").should be_set
235
- end
236
-
237
- it "returns false if the radio button unset" do
238
- browser.radio(:id, "new_user_newsletter_no").should_not be_set
239
- end
240
-
241
- it "returns the state for radios with string values" do
242
- browser.radio(:name => "new_user_newsletter", :value => 'no').should_not be_set
243
- browser.radio(:name => "new_user_newsletter", :value => 'no').set
244
- browser.radio(:name => "new_user_newsletter", :value => 'no').should be_set
245
- browser.radio(:name => "new_user_newsletter", :value => 'yes').set
246
- browser.radio(:name => "new_user_newsletter", :value => 'no').should_not be_set
247
- end
248
-
249
- it "raises UnknownObjectException if the radio button doesn't exist" do
250
- lambda { browser.radio(:id, "no_such_id").set? }.should raise_error(UnknownObjectException)
251
- lambda { browser.radio(:xpath, "//input[@id='no_such_id']").set? }.should raise_error(UnknownObjectException)
252
- end
253
- end
254
-
255
- end