watir-webdriver 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +53 -31
- data/VERSION +1 -1
- data/lib/watir-webdriver.rb +6 -8
- data/lib/watir-webdriver/attribute_helper.rb +121 -0
- data/lib/watir-webdriver/browser.rb +13 -6
- data/lib/watir-webdriver/collections/element_collection.rb +21 -15
- data/lib/watir-webdriver/collections/table_row_collection.rb +11 -0
- data/lib/watir-webdriver/container.rb +17 -11
- data/lib/watir-webdriver/element.rb +201 -0
- data/lib/watir-webdriver/elements/button.rb +19 -2
- data/lib/watir-webdriver/elements/checkbox.rb +24 -4
- data/lib/watir-webdriver/elements/file_field.rb +24 -4
- data/lib/watir-webdriver/elements/font.rb +10 -11
- data/lib/watir-webdriver/elements/frame.rb +11 -3
- data/lib/watir-webdriver/elements/generated.rb +2491 -1313
- data/lib/watir-webdriver/elements/hidden.rb +16 -5
- data/lib/watir-webdriver/elements/input.rb +44 -5
- data/lib/watir-webdriver/elements/link.rb +6 -8
- data/lib/watir-webdriver/elements/radio.rb +25 -6
- data/lib/watir-webdriver/elements/{select_list.rb → select.rb} +8 -9
- data/lib/watir-webdriver/elements/text_field.rb +32 -3
- data/lib/watir-webdriver/html.rb +18 -0
- data/lib/watir-webdriver/html/generator.rb +112 -0
- data/lib/watir-webdriver/html/idl_sorter.rb +49 -0
- data/lib/watir-webdriver/html/spec_extractor.rb +111 -0
- data/lib/watir-webdriver/html/util.rb +31 -0
- data/lib/watir-webdriver/html/visitor.rb +186 -0
- data/lib/watir-webdriver/locators/element_locator.rb +4 -0
- data/lib/watir-webdriver/locators/text_field_locator.rb +2 -2
- data/lib/watir-webdriver/xpath_support.rb +3 -5
- data/lib/yard/handlers/watir.rb +57 -0
- data/spec/{base_element_spec.rb → element_spec.rb} +3 -2
- data/spec/input_spec.rb +65 -0
- data/spec/spec_helper.rb +9 -2
- data/spec/watirspec/area_spec.rb +9 -13
- data/spec/watirspec/areas_spec.rb +7 -1
- data/spec/watirspec/browser_spec.rb +68 -72
- data/spec/watirspec/button_spec.rb +16 -9
- data/spec/watirspec/buttons_spec.rb +11 -9
- data/spec/watirspec/checkbox_spec.rb +1 -1
- data/spec/watirspec/checkboxes_spec.rb +7 -1
- data/spec/watirspec/collections_spec.rb +18 -0
- data/spec/watirspec/dd_spec.rb +1 -1
- data/spec/watirspec/dds_spec.rb +7 -1
- data/spec/watirspec/del_spec.rb +141 -0
- data/spec/watirspec/dels_spec.rb +37 -0
- data/spec/watirspec/div_spec.rb +6 -22
- data/spec/watirspec/divs_spec.rb +8 -2
- data/spec/watirspec/dl_spec.rb +1 -1
- data/spec/watirspec/dls_spec.rb +7 -1
- data/spec/watirspec/dt_spec.rb +1 -1
- data/spec/watirspec/dts_spec.rb +7 -1
- data/spec/watirspec/element_spec.rb +11 -20
- data/spec/watirspec/em_spec.rb +1 -1
- data/spec/watirspec/ems_spec.rb +7 -1
- data/spec/watirspec/filefield_spec.rb +8 -11
- data/spec/watirspec/filefields_spec.rb +7 -1
- data/spec/watirspec/font_spec.rb +2 -2
- data/spec/watirspec/form_spec.rb +10 -18
- data/spec/watirspec/forms_spec.rb +7 -1
- data/spec/watirspec/frame_spec.rb +69 -73
- data/spec/watirspec/frames_spec.rb +15 -2
- data/spec/watirspec/hidden_spec.rb +1 -1
- data/spec/watirspec/hiddens_spec.rb +7 -1
- data/spec/watirspec/hn_spec.rb +1 -1
- data/spec/watirspec/hns_spec.rb +23 -27
- data/spec/watirspec/image_spec.rb +9 -15
- data/spec/watirspec/images_spec.rb +7 -1
- data/spec/watirspec/ins_spec.rb +142 -0
- data/spec/watirspec/inses_spec.rb +37 -0
- data/spec/watirspec/label_spec.rb +1 -1
- data/spec/watirspec/labels_spec.rb +7 -1
- data/spec/watirspec/li_spec.rb +1 -1
- data/spec/watirspec/lib/guards.rb +12 -12
- data/spec/watirspec/lib/implementation.rb +48 -0
- data/spec/watirspec/lib/watirspec.rb +17 -12
- data/spec/watirspec/link_spec.rb +6 -11
- data/spec/watirspec/links_spec.rb +1 -1
- data/spec/watirspec/lis_spec.rb +7 -1
- data/spec/watirspec/map_spec.rb +1 -1
- data/spec/watirspec/maps_spec.rb +7 -1
- data/spec/watirspec/meta_spec.rb +13 -15
- data/spec/watirspec/metas_spec.rb +6 -1
- data/spec/watirspec/ol_spec.rb +57 -59
- data/spec/watirspec/ols_spec.rb +10 -4
- data/spec/watirspec/option_spec.rb +50 -83
- data/spec/watirspec/p_spec.rb +1 -1
- data/spec/watirspec/pre_spec.rb +1 -1
- data/spec/watirspec/pres_spec.rb +7 -1
- data/spec/watirspec/ps_spec.rb +7 -1
- data/spec/watirspec/radio_spec.rb +9 -11
- data/spec/watirspec/radios_spec.rb +1 -1
- data/spec/watirspec/select_list_spec.rb +27 -40
- data/spec/watirspec/select_lists_spec.rb +1 -1
- data/spec/watirspec/span_spec.rb +1 -1
- data/spec/watirspec/spans_spec.rb +7 -1
- data/spec/watirspec/spec_helper.rb +1 -0
- data/spec/watirspec/strong_spec.rb +1 -1
- data/spec/watirspec/strongs_spec.rb +7 -1
- data/spec/watirspec/table_bodies_spec.rb +22 -10
- data/spec/watirspec/table_body_spec.rb +33 -40
- data/spec/watirspec/table_cell_spec.rb +1 -1
- data/spec/watirspec/table_cells_spec.rb +36 -15
- data/spec/watirspec/table_footer_spec.rb +43 -40
- data/spec/watirspec/table_footers_spec.rb +35 -19
- data/spec/watirspec/table_header_spec.rb +44 -39
- data/spec/watirspec/table_headers_spec.rb +37 -19
- data/spec/watirspec/table_row_spec.rb +13 -9
- data/spec/watirspec/table_rows_spec.rb +16 -6
- data/spec/watirspec/table_spec.rb +83 -62
- data/spec/watirspec/tables_spec.rb +7 -1
- data/spec/watirspec/text_field_spec.rb +4 -6
- data/spec/watirspec/text_fields_spec.rb +1 -1
- data/spec/watirspec/ul_spec.rb +1 -1
- data/spec/watirspec/uls_spec.rb +25 -22
- data/support/html5.html +89235 -0
- data/watir-webdriver.gemspec +31 -21
- metadata +52 -23
- data/TODO +0 -15
- data/lib/watir-webdriver/base_element.rb +0 -361
- data/lib/watir-webdriver/collections/buttons_collection.rb +0 -15
- data/lib/watir-webdriver/collections/table_rows_collection.rb +0 -16
- data/lib/watir-webdriver/collections/text_fields_collection.rb +0 -15
- data/lib/watir-webdriver/elements/headings.rb +0 -48
- data/support/html5/html5.idl +0 -1274
- data/support/html5/old/html5.idl +0 -962
- data/support/html5/old/html5_extras.idl +0 -145
- data/support/html5/watir_visitor.rb +0 -173
- data/support/yard_handlers.rb +0 -87
@@ -35,21 +35,26 @@ module WatirSpec
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def implementation
|
38
|
-
@implementation ||=
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
38
|
+
@implementation ||= (
|
39
|
+
imp = WatirSpec::Implementation.new
|
40
|
+
yield imp if block_given?
|
41
|
+
|
42
|
+
imp
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
def implementation=(imp)
|
47
|
+
unless imp.kind_of? WatirSpec::Implementation
|
48
|
+
raise TypeError, "expected WatirSpec::Implementation, got #{imp.class}"
|
49
|
+
end
|
50
|
+
|
51
|
+
@implementation = imp
|
48
52
|
end
|
49
53
|
|
50
54
|
def new_browser
|
51
|
-
|
52
|
-
args
|
55
|
+
klass = WatirSpec.implementation.browser_class
|
56
|
+
args = WatirSpec.implementation.browser_args
|
57
|
+
args ? klass.new(*args) : klass.new
|
53
58
|
end
|
54
59
|
|
55
60
|
def ruby
|
data/spec/watirspec/link_spec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require File.dirname(__FILE__)
|
2
|
+
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
3
3
|
|
4
4
|
describe "Link" do
|
5
5
|
|
@@ -22,11 +22,8 @@ describe "Link" do
|
|
22
22
|
browser.link(:xpath, "//a[@id='link_2']").should exist
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
it "strips spaces from URL attributes when locating elements" do
|
28
|
-
browser.link(:url, /strip_space$/).should exist
|
29
|
-
end
|
25
|
+
it "strips spaces from URL attributes when locating elements" do
|
26
|
+
browser.link(:url, /strip_space$/).should exist
|
30
27
|
end
|
31
28
|
|
32
29
|
it "returns false if the link doesn't exist" do
|
@@ -80,11 +77,9 @@ describe "Link" do
|
|
80
77
|
end
|
81
78
|
end
|
82
79
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
browser.link(:index, 1).url.should =~ /non_control_elements/
|
87
|
-
end
|
80
|
+
describe "#url" do
|
81
|
+
it "returns the href attribute" do
|
82
|
+
browser.link(:index, 1).url.should =~ /non_control_elements/
|
88
83
|
end
|
89
84
|
end
|
90
85
|
|
data/spec/watirspec/lis_spec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require File.dirname(__FILE__)
|
2
|
+
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
3
3
|
|
4
4
|
describe "Lis" do
|
5
5
|
|
@@ -21,10 +21,16 @@ describe "Lis" do
|
|
21
21
|
|
22
22
|
describe "#each" do
|
23
23
|
it "iterates through lis correctly" do
|
24
|
+
count = 0
|
25
|
+
|
24
26
|
browser.lis.each_with_index do |l, index|
|
25
27
|
l.id.should == browser.li(:index, index).id
|
26
28
|
l.value.should == browser.li(:index, index).value
|
29
|
+
|
30
|
+
count += 1
|
27
31
|
end
|
32
|
+
|
33
|
+
count.should > 0
|
28
34
|
end
|
29
35
|
end
|
30
36
|
|
data/spec/watirspec/map_spec.rb
CHANGED
data/spec/watirspec/maps_spec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require File.dirname(__FILE__)
|
2
|
+
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
3
3
|
|
4
4
|
describe "Maps" do
|
5
5
|
|
@@ -21,11 +21,17 @@ describe "Maps" do
|
|
21
21
|
|
22
22
|
describe "#each" do
|
23
23
|
it "iterates through maps correctly" do
|
24
|
+
count = 0
|
25
|
+
|
24
26
|
browser.maps.each_with_index do |m, index|
|
25
27
|
m.name.should == browser.map(:index, index).name
|
26
28
|
m.id.should == browser.map(:index, index).id
|
27
29
|
m.value.should == browser.map(:index, index).value
|
30
|
+
|
31
|
+
count += 1
|
28
32
|
end
|
33
|
+
|
34
|
+
count.should > 0
|
29
35
|
end
|
30
36
|
end
|
31
37
|
|
data/spec/watirspec/meta_spec.rb
CHANGED
@@ -1,22 +1,20 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require File.dirname(__FILE__)
|
2
|
+
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
4
|
+
describe "Meta" do
|
5
|
+
before :each do
|
6
|
+
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
|
7
|
+
end
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
9
|
+
describe "#exist?" do
|
10
|
+
it "returns true if the meta tag exists" do
|
11
|
+
browser.meta(:http_equiv, "Content-Type").should exist
|
14
12
|
end
|
13
|
+
end
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
15
|
+
describe "content" do
|
16
|
+
it "returns the content attribute of the tag" do
|
17
|
+
browser.meta(:http_equiv, "Content-Type").content.should == "text/html; charset=utf-8"
|
20
18
|
end
|
21
19
|
end
|
22
|
-
end
|
20
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require File.dirname(__FILE__)
|
2
|
+
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
3
3
|
|
4
4
|
describe "Metas" do
|
5
5
|
|
@@ -21,9 +21,14 @@ describe "Metas" do
|
|
21
21
|
|
22
22
|
describe "#each" do
|
23
23
|
it "iterates through meta elements correctly" do
|
24
|
+
count = 0
|
25
|
+
|
24
26
|
browser.metas.each_with_index do |m, index|
|
25
27
|
m.content.should == browser.meta(:index, index).content
|
28
|
+
count += 1
|
26
29
|
end
|
30
|
+
|
31
|
+
count.should > 0
|
27
32
|
end
|
28
33
|
end
|
29
34
|
|
data/spec/watirspec/ol_spec.rb
CHANGED
@@ -1,78 +1,76 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require File.dirname(__FILE__)
|
2
|
+
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
3
3
|
|
4
|
-
|
5
|
-
describe "Ol" do
|
4
|
+
describe "Ol" do
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
# Exists method
|
12
|
-
describe "#exist?" do
|
13
|
-
it "returns true if the 'ol' exists" do
|
14
|
-
browser.ol(:id, "favorite_compounds").should exist
|
15
|
-
browser.ol(:id, /favorite_compounds/).should exist
|
16
|
-
browser.ol(:index, 0).should exist
|
17
|
-
browser.ol(:xpath, "//ol[@id='favorite_compounds']").should exist
|
18
|
-
end
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
8
|
+
end
|
19
9
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
browser.ol(:xpath, "//ol[@id='no_such_id']").should_not exist
|
29
|
-
end
|
10
|
+
# Exists method
|
11
|
+
describe "#exist?" do
|
12
|
+
it "returns true if the 'ol' exists" do
|
13
|
+
browser.ol(:id, "favorite_compounds").should exist
|
14
|
+
browser.ol(:id, /favorite_compounds/).should exist
|
15
|
+
browser.ol(:index, 0).should exist
|
16
|
+
browser.ol(:xpath, "//ol[@id='favorite_compounds']").should exist
|
17
|
+
end
|
30
18
|
|
31
|
-
|
32
|
-
|
33
|
-
|
19
|
+
it "returns false if the 'ol' doesn't exist" do
|
20
|
+
browser.ol(:id, "no_such_id").should_not exist
|
21
|
+
browser.ol(:id, /no_such_id/).should_not exist
|
22
|
+
browser.ol(:text, "no_such_text").should_not exist
|
23
|
+
browser.ol(:text, /no_such_text/).should_not exist
|
24
|
+
browser.ol(:class, "no_such_class").should_not exist
|
25
|
+
browser.ol(:class, /no_such_class/).should_not exist
|
26
|
+
browser.ol(:index, 1337).should_not exist
|
27
|
+
browser.ol(:xpath, "//ol[@id='no_such_id']").should_not exist
|
28
|
+
end
|
34
29
|
|
35
|
-
|
36
|
-
|
37
|
-
end
|
30
|
+
it "raises TypeError when 'what' argument is invalid" do
|
31
|
+
lambda { browser.ol(:id, 3.14).exists? }.should raise_error(TypeError)
|
38
32
|
end
|
39
33
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
34
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
35
|
+
lambda { browser.ol(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
36
|
+
end
|
37
|
+
end
|
45
38
|
|
46
|
-
|
47
|
-
|
48
|
-
|
39
|
+
# Attribute methods
|
40
|
+
describe "#class_name" do
|
41
|
+
it "returns the class attribute" do
|
42
|
+
browser.ol(:id, 'favorite_compounds').class_name.should == 'chemistry'
|
43
|
+
end
|
49
44
|
|
50
|
-
|
51
|
-
|
52
|
-
end
|
45
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
46
|
+
browser.ol(:index, 1).class_name.should == ''
|
53
47
|
end
|
54
48
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
49
|
+
it "raises UnknownObjectException if the ol doesn't exist" do
|
50
|
+
lambda { browser.ol(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
|
51
|
+
end
|
52
|
+
end
|
59
53
|
|
60
|
-
|
61
|
-
|
62
|
-
|
54
|
+
describe "#id" do
|
55
|
+
it "returns the id attribute" do
|
56
|
+
browser.ol(:class, 'chemistry').id.should == "favorite_compounds"
|
57
|
+
end
|
63
58
|
|
64
|
-
|
65
|
-
|
66
|
-
lambda { browser.ol(:index, 1337).id }.should raise_error(UnknownObjectException)
|
67
|
-
end
|
59
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
60
|
+
browser.ol(:index, 1).id.should == ''
|
68
61
|
end
|
69
62
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
browser.ol(:index, 0).should respond_to(:id)
|
74
|
-
end
|
63
|
+
it "raises UnknownObjectException if the ol doesn't exist" do
|
64
|
+
lambda { browser.ol(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
65
|
+
lambda { browser.ol(:index, 1337).id }.should raise_error(UnknownObjectException)
|
75
66
|
end
|
67
|
+
end
|
76
68
|
|
69
|
+
describe "#respond_to?" do
|
70
|
+
it "returns true for all attribute methods" do
|
71
|
+
browser.ol(:index, 0).should respond_to(:class_name)
|
72
|
+
browser.ol(:index, 0).should respond_to(:id)
|
73
|
+
end
|
77
74
|
end
|
78
|
-
|
75
|
+
|
76
|
+
end
|
data/spec/watirspec/ols_spec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require File.dirname(__FILE__)
|
2
|
+
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
3
3
|
|
4
4
|
describe "Ols" do
|
5
5
|
|
@@ -21,10 +21,16 @@ describe "Ols" do
|
|
21
21
|
|
22
22
|
describe "#each" do
|
23
23
|
it "iterates through ols correctly" do
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
count = 0
|
25
|
+
|
26
|
+
browser.ols.each_with_index do |ul, index|
|
27
|
+
ul.id.should == browser.ol(:index, index).id
|
28
|
+
ul.value.should == browser.ol(:index, index).value
|
29
|
+
|
30
|
+
count += 1
|
27
31
|
end
|
32
|
+
|
33
|
+
count.should > 0
|
28
34
|
end
|
29
35
|
end
|
30
36
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require File.dirname(__FILE__)
|
2
|
+
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
3
3
|
|
4
4
|
describe "Option" do
|
5
5
|
|
@@ -8,28 +8,21 @@ describe "Option" do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
describe "#exists?" do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
browser.option(:class, "scandinavia").should exist
|
22
|
-
browser.option(:index, 1).should exist
|
23
|
-
browser.option(:xpath, "//option[@id='nor']").should exist
|
24
|
-
end
|
11
|
+
it "returns true if the element exists (page context)" do
|
12
|
+
browser.option(:id, "nor").should exist
|
13
|
+
browser.option(:id, /nor/).should exist
|
14
|
+
browser.option(:value, "2").should exist
|
15
|
+
browser.option(:value, /2/).should exist
|
16
|
+
browser.option(:text, "Norway").should exist
|
17
|
+
browser.option(:text, /Norway/).should exist
|
18
|
+
browser.option(:class, "scandinavia").should exist
|
19
|
+
browser.option(:index, 1).should exist
|
20
|
+
browser.option(:xpath, "//option[@id='nor']").should exist
|
25
21
|
end
|
26
22
|
|
27
23
|
it "returns true if the element exists (select_list context)" do
|
28
|
-
|
29
|
-
|
30
|
-
browser.select_list(:name, "new_user_country").option(:id, /nor/).should exist
|
31
|
-
end
|
32
|
-
|
24
|
+
browser.select_list(:name, "new_user_country").option(:id, "nor").should exist
|
25
|
+
browser.select_list(:name, "new_user_country").option(:id, /nor/).should exist
|
33
26
|
browser.select_list(:name, "new_user_country").option(:value, "2").should exist
|
34
27
|
browser.select_list(:name, "new_user_country").option(:value, /2/).should exist
|
35
28
|
browser.select_list(:name, "new_user_country").option(:text, "Norway").should exist
|
@@ -41,28 +34,21 @@ describe "Option" do
|
|
41
34
|
browser.select_list(:name, "new_user_country").option(:label, "Germany").should exist
|
42
35
|
end
|
43
36
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
browser.option(:class, "no_such_class").should_not exist
|
55
|
-
browser.option(:index, 1337).should_not exist
|
56
|
-
browser.option(:xpath, "//option[@id='no_such_id']").should_not exist
|
57
|
-
end
|
37
|
+
it "returns false if the element does not exist (page context)" do
|
38
|
+
browser.option(:id, "no_such_id").should_not exist
|
39
|
+
browser.option(:id, /no_such_id/).should_not exist
|
40
|
+
browser.option(:value, "no_such_value").should_not exist
|
41
|
+
browser.option(:value, /no_such_value/).should_not exist
|
42
|
+
browser.option(:text, "no_such_text").should_not exist
|
43
|
+
browser.option(:text, /no_such_text/).should_not exist
|
44
|
+
browser.option(:class, "no_such_class").should_not exist
|
45
|
+
browser.option(:index, 1337).should_not exist
|
46
|
+
browser.option(:xpath, "//option[@id='no_such_id']").should_not exist
|
58
47
|
end
|
59
48
|
|
60
49
|
it "returns false if the element does not exist (select_list context)" do
|
61
|
-
|
62
|
-
|
63
|
-
browser.select_list(:name, "new_user_country").option(:id, /no_such_id/).should_not exist
|
64
|
-
end
|
65
|
-
|
50
|
+
browser.select_list(:name, "new_user_country").option(:id, "no_such_id").should_not exist
|
51
|
+
browser.select_list(:name, "new_user_country").option(:id, /no_such_id/).should_not exist
|
66
52
|
browser.select_list(:name, "new_user_country").option(:value, "no_such_value").should_not exist
|
67
53
|
browser.select_list(:name, "new_user_country").option(:value, /no_such_value/).should_not exist
|
68
54
|
browser.select_list(:name, "new_user_country").option(:text, "no_such_text").should_not exist
|
@@ -73,27 +59,20 @@ describe "Option" do
|
|
73
59
|
end
|
74
60
|
|
75
61
|
it "raises TypeError when 'what' argument is invalid" do
|
76
|
-
|
77
|
-
lambda { browser.option(:id, 3.14).exists? }.should raise_error(TypeError)
|
78
|
-
end
|
79
|
-
|
62
|
+
lambda { browser.option(:id, 3.14).exists? }.should raise_error(TypeError)
|
80
63
|
lambda { browser.select_list(:name, "new_user_country").option(:id, 3.14).exists? }.should raise_error(TypeError)
|
81
64
|
end
|
82
65
|
|
83
66
|
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
84
|
-
|
85
|
-
lambda { browser.option(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
86
|
-
end
|
67
|
+
lambda { browser.option(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
87
68
|
lambda { browser.select_list(:name, "new_user_country").option(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
88
69
|
end
|
89
70
|
end
|
90
71
|
|
91
72
|
describe "#select" do
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
browser.select_list(:name, "new_user_country").selected_options.should == ["Denmark"]
|
96
|
-
end
|
73
|
+
it "selects the chosen option (page context)" do
|
74
|
+
browser.option(:text, "Denmark").select
|
75
|
+
browser.select_list(:name, "new_user_country").selected_options.should == ["Denmark"]
|
97
76
|
end
|
98
77
|
|
99
78
|
it "selects the chosen option (select_list context)" do
|
@@ -101,22 +80,18 @@ describe "Option" do
|
|
101
80
|
browser.select_list(:name, "new_user_country").selected_options.should == ["Denmark"]
|
102
81
|
end
|
103
82
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
end
|
83
|
+
it "selects the option when found by text (page context)" do
|
84
|
+
browser.option(:text, 'Sweden').select
|
85
|
+
browser.option(:text, 'Sweden').should be_selected
|
86
|
+
end
|
109
87
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
end
|
88
|
+
it "selects the option when found by text (select_list context)" do
|
89
|
+
browser.select_list(:name, 'new_user_country').option(:text, 'Sweden').select
|
90
|
+
browser.select_list(:name, 'new_user_country').option(:text, 'Sweden').should be_selected
|
114
91
|
end
|
115
92
|
|
116
93
|
it "fires the onclick event (page context)" do
|
117
|
-
|
118
|
-
browser.option(:text, "Username 3").select
|
119
|
-
end
|
94
|
+
browser.option(:text, "Username 3").select
|
120
95
|
browser.text_field(:id, 'delete_user_comment').value.should == 'Don\'t do it!'
|
121
96
|
end
|
122
97
|
|
@@ -125,11 +100,9 @@ describe "Option" do
|
|
125
100
|
browser.text_field(:id, 'delete_user_comment').value.should == 'Don\'t do it!'
|
126
101
|
end
|
127
102
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
lambda { browser.option(:text, /missing/).select }.should raise_error(UnknownObjectException)
|
132
|
-
end
|
103
|
+
it "raises UnknownObjectException if the option does not exist (page context)" do
|
104
|
+
lambda { browser.option(:text, "no_such_text").select }.should raise_error(UnknownObjectException)
|
105
|
+
lambda { browser.option(:text, /missing/).select }.should raise_error(UnknownObjectException)
|
133
106
|
end
|
134
107
|
|
135
108
|
it "raises UnknownObjectException if the option does not exist (select_list context)" do
|
@@ -137,10 +110,8 @@ describe "Option" do
|
|
137
110
|
lambda { browser.select_list(:name, "new_user_country").option(:text, /missing/).select }.should raise_error(UnknownObjectException)
|
138
111
|
end
|
139
112
|
|
140
|
-
|
141
|
-
|
142
|
-
lambda { browser.option(:missing, "Denmark").select }.should raise_error(MissingWayOfFindingObjectException)
|
143
|
-
end
|
113
|
+
it "raises MissingWayOfFindingObjectException when given a bad 'how' (page context)" do
|
114
|
+
lambda { browser.option(:missing, "Denmark").select }.should raise_error(MissingWayOfFindingObjectException)
|
144
115
|
end
|
145
116
|
|
146
117
|
it "raises MissingWayOfFindingObjectException when given a bad 'how' (select_list context)" do
|
@@ -148,17 +119,13 @@ describe "Option" do
|
|
148
119
|
end
|
149
120
|
end
|
150
121
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
it "is able to get attributes (select_list context)" do
|
160
|
-
browser.select_list(:name, "new_user_country").option(:text , 'Sweden').class_name.should == "scandinavia"
|
161
|
-
end
|
122
|
+
describe "#class_name" do
|
123
|
+
it "is able to get attributes (page context)" do
|
124
|
+
browser.option(:text, 'Sweden').class_name.should == "scandinavia"
|
125
|
+
end
|
126
|
+
|
127
|
+
it "is able to get attributes (select_list context)" do
|
128
|
+
browser.select_list(:name, "new_user_country").option(:text , 'Sweden').class_name.should == "scandinavia"
|
162
129
|
end
|
163
130
|
end
|
164
131
|
|