operawatir 0.3-jruby
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.
- data/.gitmodules +3 -0
- data/.yardopts +5 -0
- data/AUTHORS +7 -0
- data/Gemfile +9 -0
- data/LICENSE +30 -0
- data/README.md +158 -0
- data/Rakefile +59 -0
- data/VERSION +1 -0
- data/bin/desktopwatir +106 -0
- data/bin/operawatir +95 -0
- data/lib/operadriver/APACHE_2.0_LICENSE.txt +204 -0
- data/lib/operadriver/NEW_BSD_LICENSE.txt +36 -0
- data/lib/operadriver/commons-jxpath-1.3.jar +0 -0
- data/lib/operadriver/protobuf-java-2.3.0.jar +0 -0
- data/lib/operadriver/selenium-common.jar +0 -0
- data/lib/operadriver/webdriver-opera.jar +0 -0
- data/lib/operawatir.rb +46 -0
- data/lib/operawatir/browser.rb +181 -0
- data/lib/operawatir/collection.rb +133 -0
- data/lib/operawatir/compat.rb +25 -0
- data/lib/operawatir/compat/browser.rb +20 -0
- data/lib/operawatir/compat/collection.rb +99 -0
- data/lib/operawatir/compat/deprecation.rb +46 -0
- data/lib/operawatir/compat/element.rb +165 -0
- data/lib/operawatir/compat/element_finders.rb +159 -0
- data/lib/operawatir/compat/window.rb +27 -0
- data/lib/operawatir/element.rb +228 -0
- data/lib/operawatir/exceptions.rb +38 -0
- data/lib/operawatir/helper.rb +53 -0
- data/lib/operawatir/selector.rb +111 -0
- data/lib/operawatir/version.rb +15 -0
- data/lib/operawatir/window.rb +174 -0
- data/spec/fire_event/fire_event.rb +268 -0
- data/spec/fire_event/interactive/onBlur.html +45 -0
- data/spec/fire_event/interactive/onChange.html +47 -0
- data/spec/fire_event/interactive/onClick.html +45 -0
- data/spec/fire_event/interactive/onDblClick.html +45 -0
- data/spec/fire_event/interactive/onFocus.html +45 -0
- data/spec/fire_event/interactive/onMouseDown.html +45 -0
- data/spec/fire_event/interactive/onMouseMove.html +45 -0
- data/spec/fire_event/interactive/onMouseOut.html +45 -0
- data/spec/fire_event/interactive/onMouseOver.html +45 -0
- data/spec/fire_event/interactive/onMouseUp.html +45 -0
- data/spec/fire_event/interactive/onScroll.html +14 -0
- data/spec/legacy_watirspec/area_spec.rb +106 -0
- data/spec/legacy_watirspec/areas_spec.rb +38 -0
- data/spec/legacy_watirspec/browser_spec.rb +297 -0
- data/spec/legacy_watirspec/button_spec.rb +260 -0
- data/spec/legacy_watirspec/buttons_spec.rb +54 -0
- data/spec/legacy_watirspec/checkbox_spec.rb +280 -0
- data/spec/legacy_watirspec/checkboxes_spec.rb +38 -0
- data/spec/legacy_watirspec/collections_spec.rb +18 -0
- data/spec/legacy_watirspec/dd_spec.rb +140 -0
- data/spec/legacy_watirspec/dds_spec.rb +38 -0
- data/spec/legacy_watirspec/del_spec.rb +181 -0
- data/spec/legacy_watirspec/dels_spec.rb +62 -0
- data/spec/legacy_watirspec/div_spec.rb +244 -0
- data/spec/legacy_watirspec/divs_spec.rb +38 -0
- data/spec/legacy_watirspec/dl_spec.rb +140 -0
- data/spec/legacy_watirspec/dls_spec.rb +38 -0
- data/spec/legacy_watirspec/dt_spec.rb +140 -0
- data/spec/legacy_watirspec/dts_spec.rb +38 -0
- data/spec/legacy_watirspec/element_spec.rb +86 -0
- data/spec/legacy_watirspec/em_spec.rb +114 -0
- data/spec/legacy_watirspec/ems_spec.rb +38 -0
- data/spec/legacy_watirspec/filefield_spec.rb +127 -0
- data/spec/legacy_watirspec/filefields_spec.rb +38 -0
- data/spec/legacy_watirspec/fixtures/2000_spans.html +2009 -0
- data/spec/legacy_watirspec/fixtures/bug_duplicate_attributes.html +14 -0
- data/spec/legacy_watirspec/fixtures/bug_javascript_001.html +11 -0
- data/spec/legacy_watirspec/fixtures/buttons_with_duplicate_ids.html +18 -0
- data/spec/legacy_watirspec/fixtures/collections.html +15 -0
- data/spec/legacy_watirspec/fixtures/definition_lists.html +48 -0
- data/spec/legacy_watirspec/fixtures/euc-jp_text.html +17 -0
- data/spec/legacy_watirspec/fixtures/forms_with_input_elements.html +126 -0
- data/spec/legacy_watirspec/fixtures/frame_1.html +18 -0
- data/spec/legacy_watirspec/fixtures/frame_2.html +16 -0
- data/spec/legacy_watirspec/fixtures/frames.html +11 -0
- data/spec/legacy_watirspec/fixtures/iframes.html +12 -0
- data/spec/legacy_watirspec/fixtures/images.html +27 -0
- data/spec/legacy_watirspec/fixtures/images/1.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/2.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/3.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/button.jpg +0 -0
- data/spec/legacy_watirspec/fixtures/images/circle.jpg +0 -0
- data/spec/legacy_watirspec/fixtures/images/map.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/map2.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/minus.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/originaltriangle.jpg +0 -0
- data/spec/legacy_watirspec/fixtures/images/plus.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/square.jpg +0 -0
- data/spec/legacy_watirspec/fixtures/images/triangle.jpg +0 -0
- data/spec/legacy_watirspec/fixtures/iso-2022-jp_text.html +17 -0
- data/spec/legacy_watirspec/fixtures/javascript/helpers.js +16 -0
- data/spec/legacy_watirspec/fixtures/jquery.html +28 -0
- data/spec/legacy_watirspec/fixtures/latin1_text.html +17 -0
- data/spec/legacy_watirspec/fixtures/multiple_ids.html +14 -0
- data/spec/legacy_watirspec/fixtures/non_control_elements.html +135 -0
- data/spec/legacy_watirspec/fixtures/parser_bug_001.html +12 -0
- data/spec/legacy_watirspec/fixtures/prevent_form_submit.html +20 -0
- data/spec/legacy_watirspec/fixtures/right_click.html +11 -0
- data/spec/legacy_watirspec/fixtures/shift_jis_text.html +17 -0
- data/spec/legacy_watirspec/fixtures/tables.html +121 -0
- data/spec/legacy_watirspec/fixtures/timeout.html +16 -0
- data/spec/legacy_watirspec/fixtures/timeout_window_location.html +19 -0
- data/spec/legacy_watirspec/fixtures/tiny_mce.html +27 -0
- data/spec/legacy_watirspec/fixtures/utf8_text.html +15 -0
- data/spec/legacy_watirspec/fixtures/watirspec.css +0 -0
- data/spec/legacy_watirspec/form_spec.rb +73 -0
- data/spec/legacy_watirspec/forms_spec.rb +39 -0
- data/spec/legacy_watirspec/frame_spec.rb +161 -0
- data/spec/legacy_watirspec/frames_spec.rb +75 -0
- data/spec/legacy_watirspec/guards.rb +38 -0
- data/spec/legacy_watirspec/hidden_spec.rb +120 -0
- data/spec/legacy_watirspec/hiddens_spec.rb +38 -0
- data/spec/legacy_watirspec/hn_spec.rb +101 -0
- data/spec/legacy_watirspec/hns_spec.rb +39 -0
- data/spec/legacy_watirspec/image_spec.rb +237 -0
- data/spec/legacy_watirspec/images_spec.rb +38 -0
- data/spec/legacy_watirspec/ins_spec.rb +181 -0
- data/spec/legacy_watirspec/inses_spec.rb +62 -0
- data/spec/legacy_watirspec/label_spec.rb +85 -0
- data/spec/legacy_watirspec/labels_spec.rb +38 -0
- data/spec/legacy_watirspec/li_spec.rb +135 -0
- data/spec/legacy_watirspec/link_spec.rb +194 -0
- data/spec/legacy_watirspec/links_spec.rb +39 -0
- data/spec/legacy_watirspec/lis_spec.rb +38 -0
- data/spec/legacy_watirspec/map_spec.rb +100 -0
- data/spec/legacy_watirspec/maps_spec.rb +38 -0
- data/spec/legacy_watirspec/meta_spec.rb +26 -0
- data/spec/legacy_watirspec/metas_spec.rb +36 -0
- data/spec/legacy_watirspec/ol_spec.rb +86 -0
- data/spec/legacy_watirspec/ols_spec.rb +38 -0
- data/spec/legacy_watirspec/option_spec.rb +187 -0
- data/spec/legacy_watirspec/p_spec.rb +167 -0
- data/spec/legacy_watirspec/pre_spec.rb +133 -0
- data/spec/legacy_watirspec/pres_spec.rb +38 -0
- data/spec/legacy_watirspec/ps_spec.rb +38 -0
- data/spec/legacy_watirspec/radio_spec.rb +286 -0
- data/spec/legacy_watirspec/radios_spec.rb +35 -0
- data/spec/legacy_watirspec/select_list_spec.rb +326 -0
- data/spec/legacy_watirspec/select_lists_spec.rb +39 -0
- data/spec/legacy_watirspec/server.rb +91 -0
- data/spec/legacy_watirspec/span_spec.rb +181 -0
- data/spec/legacy_watirspec/spans_spec.rb +64 -0
- data/spec/legacy_watirspec/spec_helper.rb +12 -0
- data/spec/legacy_watirspec/strong_spec.rb +97 -0
- data/spec/legacy_watirspec/strongs_spec.rb +39 -0
- data/spec/legacy_watirspec/table_bodies_spec.rb +61 -0
- data/spec/legacy_watirspec/table_body_spec.rb +119 -0
- data/spec/legacy_watirspec/table_cell_spec.rb +76 -0
- data/spec/legacy_watirspec/table_cells_spec.rb +71 -0
- data/spec/legacy_watirspec/table_footer_spec.rb +94 -0
- data/spec/legacy_watirspec/table_footers_spec.rb +61 -0
- data/spec/legacy_watirspec/table_header_spec.rb +98 -0
- data/spec/legacy_watirspec/table_headers_spec.rb +59 -0
- data/spec/legacy_watirspec/table_row_spec.rb +104 -0
- data/spec/legacy_watirspec/table_rows_spec.rb +64 -0
- data/spec/legacy_watirspec/table_spec.rb +170 -0
- data/spec/legacy_watirspec/tables_spec.rb +40 -0
- data/spec/legacy_watirspec/text_field_spec.rb +315 -0
- data/spec/legacy_watirspec/text_fields_spec.rb +38 -0
- data/spec/legacy_watirspec/ul_spec.rb +84 -0
- data/spec/legacy_watirspec/uls_spec.rb +40 -0
- data/spec/legacy_watirspec/watir_compatibility_spec.rb +176 -0
- data/spec/legacy_watirspec/watirspec_helper.rb +57 -0
- data/utils/Rakefile +79 -0
- data/utils/launchers/launcher-linux-i686 +0 -0
- data/utils/launchers/launcher-linux-x86_64 +0 -0
- data/utils/launchers/launcher-win32-i86pc.exe +0 -0
- metadata +404 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Links" 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 links" do
|
12
|
+
browser.links.length.should == 4
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#[]" do
|
17
|
+
it "returns the link at the given index" do
|
18
|
+
browser.links[3].id.should == "link_3"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns a Link object also when the index is out of bounds" do
|
22
|
+
browser.links[2000].should_not be_nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#each" do
|
27
|
+
it "iterates through links correctly" do
|
28
|
+
index = 0
|
29
|
+
browser.links.each do |c|
|
30
|
+
index += 1
|
31
|
+
c.name.should == browser.link(:index, index).name
|
32
|
+
c.id.should == browser.link(:index, index).id
|
33
|
+
c.value.should == browser.link(:index, index).value
|
34
|
+
end
|
35
|
+
browser.links.length.should == index
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Lis" 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 lis" do
|
12
|
+
browser.lis.length.should == 18
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#[]" do
|
17
|
+
it "returns the p at the given index" do
|
18
|
+
browser.lis[5].id.should == "non_link_1"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#each" do
|
23
|
+
it "iterates through lis correctly" do
|
24
|
+
count = 0
|
25
|
+
|
26
|
+
browser.lis.each_with_index do |l, index|
|
27
|
+
l.name.should == browser.li(:index, index+1).name
|
28
|
+
l.id.should == browser.li(:index, index+1).id
|
29
|
+
l.value.should == browser.li(:index, index+1).value
|
30
|
+
|
31
|
+
count += 1
|
32
|
+
end
|
33
|
+
|
34
|
+
count.should > 0
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Map" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/images.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
# Exists method
|
11
|
+
describe "#exist?" do
|
12
|
+
it "returns true if the 'map' exists" do
|
13
|
+
browser.map(:id, "triangle_map").should exist
|
14
|
+
browser.map(:id, /triangle_map/).should exist
|
15
|
+
browser.map(:name, "triangle_map").should exist
|
16
|
+
browser.map(:name, /triangle_map/).should exist
|
17
|
+
browser.map(:index, 1).should exist
|
18
|
+
browser.map(:xpath, "//map[@id='triangle_map']").should exist
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns true if the element exists (default how = :id)" do
|
22
|
+
browser.map("triangle_map").should exist
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns the first map if given no args" do
|
26
|
+
browser.map.should exist
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns false if the 'map' doesn't exist" do
|
30
|
+
browser.map(:id, "no_such_id").should_not exist
|
31
|
+
browser.map(:id, /no_such_id/).should_not exist
|
32
|
+
browser.map(:name, "no_such_id").should_not exist
|
33
|
+
browser.map(:name, /no_such_id/).should_not exist
|
34
|
+
browser.map(:index, 1337).should_not exist
|
35
|
+
browser.map(:xpath, "//map[@id='no_such_id']").should_not exist
|
36
|
+
end
|
37
|
+
|
38
|
+
it "raises TypeError when 'what' argument is invalid" do
|
39
|
+
lambda { browser.map(:id, 3.14).exists? }.should raise_error(TypeError)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
43
|
+
lambda { browser.map(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Attribute methods
|
48
|
+
describe "#id" do
|
49
|
+
it "returns the id attribute" do
|
50
|
+
browser.map(:index, 1).id.should == "triangle_map"
|
51
|
+
end
|
52
|
+
|
53
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
54
|
+
browser.map(:index, 2).id.should == ''
|
55
|
+
end
|
56
|
+
|
57
|
+
it "raises UnknownObjectException if the p doesn't exist" do
|
58
|
+
lambda { browser.map(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
59
|
+
lambda { browser.map(:index, 1337).id }.should raise_error(UnknownObjectException)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#name" do
|
64
|
+
it "returns the name attribute" do
|
65
|
+
browser.map(:index, 1).name.should == "triangle_map"
|
66
|
+
end
|
67
|
+
|
68
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
69
|
+
browser.map(:index, 2).name.should == ''
|
70
|
+
end
|
71
|
+
|
72
|
+
it "raises UnknownObjectException if the p doesn't exist" do
|
73
|
+
lambda { browser.map(:id, "no_such_id").name }.should raise_error(UnknownObjectException)
|
74
|
+
lambda { browser.map(:index, 1337).name }.should raise_error(UnknownObjectException)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "#respond_to?" do
|
79
|
+
it "returns true for all attribute methods" do
|
80
|
+
browser.map(:index, 1).should respond_to(:id)
|
81
|
+
browser.map(:index, 1).should respond_to(:name)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Other
|
86
|
+
describe "#to_s" do
|
87
|
+
bug "WTR-350", :watir do
|
88
|
+
it "returns a human readable representation of the element" do
|
89
|
+
browser.map(:index, 1).to_s.should == "tag: map\n" +
|
90
|
+
" id: triangle_map\n" +
|
91
|
+
" name: triangle_map"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
it "raises UnknownObjectException if the p doesn't exist" do
|
96
|
+
lambda { browser.map(:xpath, "//map[@id='no_such_id']").to_s }.should raise_error( UnknownObjectException)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Maps" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/images.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#length" do
|
11
|
+
it "returns the number of maps" do
|
12
|
+
browser.maps.length.should == 2
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#[]" do
|
17
|
+
it "returns the p at the given index" do
|
18
|
+
browser.maps[1].id.should == "triangle_map"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#each" do
|
23
|
+
it "iterates through maps correctly" do
|
24
|
+
count = 0
|
25
|
+
|
26
|
+
browser.maps.each_with_index do |m, index|
|
27
|
+
m.name.should == browser.map(:index, index+1).name
|
28
|
+
m.id.should == browser.map(:index, index+1).id
|
29
|
+
m.value.should == browser.map(:index, index+1).value
|
30
|
+
|
31
|
+
count += 1
|
32
|
+
end
|
33
|
+
|
34
|
+
count.should > 0
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
bug "WTR-334", :watir do
|
5
|
+
describe "Meta" do
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#exist?" do
|
11
|
+
it "returns true if the meta tag exists" do
|
12
|
+
browser.meta('http-equiv', "Content-Type").should exist
|
13
|
+
end
|
14
|
+
|
15
|
+
it "returns the first meta if given no args" do
|
16
|
+
browser.meta.should exist
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "content" do
|
21
|
+
it "returns the content attribute of the tag" do
|
22
|
+
browser.meta('http-equiv', "Content-Type").content.should == "text/html; charset=utf-8"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Metas" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#length" do
|
11
|
+
it "returns the number of meta elements" do
|
12
|
+
browser.metas.length.should == 2
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#[]" do
|
17
|
+
it "returns the meta element at the given index" do
|
18
|
+
browser.metas[2].name.should == "description"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#each" do
|
23
|
+
it "iterates through meta elements correctly" do
|
24
|
+
count = 0
|
25
|
+
|
26
|
+
browser.metas.each_with_index do |m, index|
|
27
|
+
m.content.should == browser.meta(:index, index+1).content
|
28
|
+
|
29
|
+
count += 1
|
30
|
+
end
|
31
|
+
|
32
|
+
count.should > 0
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
bug "WTR-333", :watir do
|
5
|
+
describe "Ol" do
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
9
|
+
end
|
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, 1).should exist
|
17
|
+
browser.ol(:xpath, "//ol[@id='favorite_compounds']").should exist
|
18
|
+
end
|
19
|
+
|
20
|
+
it "returns true if the element exists (default how = :id)" do
|
21
|
+
browser.ol("favorite_compounds").should exist
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns the first ol if given no args" do
|
25
|
+
browser.ol.should exist
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns false if the 'ol' doesn't exist" do
|
29
|
+
browser.ol(:id, "no_such_id").should_not exist
|
30
|
+
browser.ol(:id, /no_such_id/).should_not exist
|
31
|
+
browser.ol(:text, "no_such_text").should_not exist
|
32
|
+
browser.ol(:text, /no_such_text/).should_not exist
|
33
|
+
browser.ol(:class, "no_such_class").should_not exist
|
34
|
+
browser.ol(:class, /no_such_class/).should_not exist
|
35
|
+
browser.ol(:index, 1337).should_not exist
|
36
|
+
browser.ol(:xpath, "//ol[@id='no_such_id']").should_not exist
|
37
|
+
end
|
38
|
+
|
39
|
+
it "raises TypeError when 'what' argument is invalid" do
|
40
|
+
lambda { browser.ol(:id, 3.14).exists? }.should raise_error(TypeError)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
44
|
+
lambda { browser.ol(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Attribute methods
|
49
|
+
describe "#class_name" do
|
50
|
+
it "returns the class attribute" do
|
51
|
+
browser.ol(:id, 'favorite_compounds').class_name.should == 'chemistry'
|
52
|
+
end
|
53
|
+
|
54
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
55
|
+
browser.ol(:index, 2).class_name.should == ''
|
56
|
+
end
|
57
|
+
|
58
|
+
it "raises UnknownObjectException if the ol doesn't exist" do
|
59
|
+
lambda { browser.ol(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#id" do
|
64
|
+
it "returns the id attribute" do
|
65
|
+
browser.ol(:class, 'chemistry').id.should == "favorite_compounds"
|
66
|
+
end
|
67
|
+
|
68
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
69
|
+
browser.ol(:index, 2).id.should == ''
|
70
|
+
end
|
71
|
+
|
72
|
+
it "raises UnknownObjectException if the ol doesn't exist" do
|
73
|
+
lambda { browser.ol(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
74
|
+
lambda { browser.ol(:index, 1337).id }.should raise_error(UnknownObjectException)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "#respond_to?" do
|
79
|
+
it "returns true for all attribute methods" do
|
80
|
+
browser.ol(:index, 1).should respond_to(:class_name)
|
81
|
+
browser.ol(:index, 1).should respond_to(:id)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Ols" 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 ols" do
|
12
|
+
browser.ols.length.should == 2
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#[]" do
|
17
|
+
it "returns the ol at the given index" do
|
18
|
+
browser.ols[1].id.should == "favorite_compounds"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#each" do
|
23
|
+
it "iterates through ols correctly" do
|
24
|
+
count = 0
|
25
|
+
|
26
|
+
browser.ols.each_with_index do |ul, index|
|
27
|
+
ul.name.should == browser.ol(:index, index+1).name
|
28
|
+
ul.id.should == browser.ol(:index, index+1).id
|
29
|
+
ul.value.should == browser.ol(:index, index+1).value
|
30
|
+
|
31
|
+
count += 1
|
32
|
+
end
|
33
|
+
|
34
|
+
count.should > 0
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,187 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Option" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#exists?" do
|
11
|
+
bug "WTR-367", :watir do
|
12
|
+
it "returns true if the element exists (page context)" do
|
13
|
+
bug "WTR-330", :watir do
|
14
|
+
browser.option(:id, "nor").should exist
|
15
|
+
browser.option(:id, /nor/).should exist
|
16
|
+
end
|
17
|
+
browser.option(:value, "2").should exist
|
18
|
+
browser.option(:value, /2/).should exist
|
19
|
+
browser.option(:text, "Norway").should exist
|
20
|
+
browser.option(:text, /Norway/).should exist
|
21
|
+
browser.option(:class, "scandinavia").should exist
|
22
|
+
browser.option(:index, 2).should exist
|
23
|
+
browser.option(:xpath, "//option[@id='nor']").should exist
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns the first option if given no args" do
|
27
|
+
browser.option.should exist
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it "returns true if the element exists (select_list context)" do
|
32
|
+
bug "WTR-330", :watir do
|
33
|
+
browser.select_list(:name, "new_user_country").option(:id, "nor").should exist
|
34
|
+
browser.select_list(:name, "new_user_country").option(:id, /nor/).should exist
|
35
|
+
end
|
36
|
+
|
37
|
+
browser.select_list(:name, "new_user_country").option(:value, "2").should exist
|
38
|
+
browser.select_list(:name, "new_user_country").option(:value, /2/).should exist
|
39
|
+
browser.select_list(:name, "new_user_country").option(:text, "Norway").should exist
|
40
|
+
browser.select_list(:name, "new_user_country").option(:text, /Norway/).should exist
|
41
|
+
browser.select_list(:name, "new_user_country").option(:class, "scandinavia").should exist
|
42
|
+
browser.select_list(:name, "new_user_country").option(:index, 2).should exist
|
43
|
+
browser.select_list(:name, "new_user_country").option(:xpath, "//option[@id='nor']").should exist
|
44
|
+
browser.select_list(:name, "new_user_country").option(:xpath, "//option[@id='nor']").should exist
|
45
|
+
browser.select_list(:name, "new_user_country").option(:label, "Germany").should exist
|
46
|
+
end
|
47
|
+
|
48
|
+
it "returns true if the element exists (default how = :text)" do
|
49
|
+
bug "WTR-367", :watir do
|
50
|
+
browser.option("Swedish").should exist
|
51
|
+
end
|
52
|
+
browser.select_list(:name, "new_user_languages").option("Swedish").should exist
|
53
|
+
end
|
54
|
+
|
55
|
+
bug "WTR-367", :watir do
|
56
|
+
it "returns false if the element does not exist (page context)" do
|
57
|
+
bug "WTR-330", :watir do
|
58
|
+
browser.option(:id, "no_such_id").should_not exist
|
59
|
+
browser.option(:id, /no_such_id/).should_not exist
|
60
|
+
end
|
61
|
+
browser.option(:value, "no_such_value").should_not exist
|
62
|
+
browser.option(:value, /no_such_value/).should_not exist
|
63
|
+
browser.option(:text, "no_such_text").should_not exist
|
64
|
+
browser.option(:text, /no_such_text/).should_not exist
|
65
|
+
browser.option(:class, "no_such_class").should_not exist
|
66
|
+
browser.option(:index, 1337).should_not exist
|
67
|
+
browser.option(:xpath, "//option[@id='no_such_id']").should_not exist
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
it "returns false if the element does not exist (select_list context)" do
|
72
|
+
bug "WTR-330", :watir do
|
73
|
+
browser.select_list(:name, "new_user_country").option(:id, "no_such_id").should_not exist
|
74
|
+
browser.select_list(:name, "new_user_country").option(:id, /no_such_id/).should_not exist
|
75
|
+
end
|
76
|
+
|
77
|
+
browser.select_list(:name, "new_user_country").option(:value, "no_such_value").should_not exist
|
78
|
+
browser.select_list(:name, "new_user_country").option(:value, /no_such_value/).should_not exist
|
79
|
+
browser.select_list(:name, "new_user_country").option(:text, "no_such_text").should_not exist
|
80
|
+
browser.select_list(:name, "new_user_country").option(:text, /no_such_text/).should_not exist
|
81
|
+
browser.select_list(:name, "new_user_country").option(:class, "no_such_class").should_not exist
|
82
|
+
browser.select_list(:name, "new_user_country").option(:index, 1337).should_not exist
|
83
|
+
browser.select_list(:name, "new_user_country").option(:xpath, "//option[@id='no_such_id']").should_not exist
|
84
|
+
end
|
85
|
+
|
86
|
+
it "raises TypeError when 'what' argument is invalid" do
|
87
|
+
bug "WTR-367", :watir do
|
88
|
+
lambda { browser.option(:id, 3.14).exists? }.should raise_error(TypeError)
|
89
|
+
end
|
90
|
+
|
91
|
+
lambda { browser.select_list(:name, "new_user_country").option(:id, 3.14).exists? }.should raise_error(TypeError)
|
92
|
+
end
|
93
|
+
|
94
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
95
|
+
bug "WTR-367", :watir do
|
96
|
+
lambda { browser.option(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
97
|
+
end
|
98
|
+
lambda { browser.select_list(:name, "new_user_country").option(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "#select" do
|
103
|
+
bug "WTR-367", :watir do
|
104
|
+
it "selects the chosen option (page context)" do
|
105
|
+
browser.select_list(:name, "new_user_country").clear
|
106
|
+
browser.option(:text, "Denmark").select
|
107
|
+
browser.select_list(:name, "new_user_country").selected_options.should == ["Denmark"]
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
it "selects the chosen option (select_list context)" do
|
112
|
+
browser.select_list(:name, "new_user_country").clear
|
113
|
+
browser.select_list(:name, "new_user_country").option(:text, "Denmark").select
|
114
|
+
browser.select_list(:name, "new_user_country").selected_options.should == ["Denmark"]
|
115
|
+
end
|
116
|
+
|
117
|
+
bug "WTR-367, WTR-329", :watir do
|
118
|
+
it "selects the option when found by text (page context)" do
|
119
|
+
browser.option(:text, 'Sweden').select
|
120
|
+
browser.option(:text, 'Sweden').should be_selected
|
121
|
+
end
|
122
|
+
|
123
|
+
it "selects the option when found by text (select_list context)" do
|
124
|
+
browser.select_list(:name, 'new_user_country').option(:text, 'Sweden').select
|
125
|
+
browser.select_list(:name, 'new_user_country').option(:text, 'Sweden').should be_selected
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
it "fires the onclick event (page context)" do
|
130
|
+
bug "WTR-367, WTR-335", :watir do
|
131
|
+
browser.option(:text, "Username 3").select
|
132
|
+
end
|
133
|
+
browser.text_field(:id, 'delete_user_comment').value.should == 'Don\'t do it!'
|
134
|
+
end
|
135
|
+
|
136
|
+
it "fires onclick event (select_list context)" do
|
137
|
+
browser.select_list(:id, 'delete_user_username').option(:text, "Username 3").select
|
138
|
+
browser.text_field(:id, 'delete_user_comment').value.should == 'Don\'t do it!'
|
139
|
+
end
|
140
|
+
|
141
|
+
bug "WTR-367", :watir do
|
142
|
+
it "raises UnknownObjectException if the option does not exist (page context)" do
|
143
|
+
lambda { browser.option(:text, "no_such_text").select }.should raise_error(UnknownObjectException)
|
144
|
+
lambda { browser.option(:text, /missing/).select }.should raise_error(UnknownObjectException)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
it "raises UnknownObjectException if the option does not exist (select_list context)" do
|
149
|
+
lambda { browser.select_list(:name, "new_user_country").option(:text, "no_such_text").select }.should raise_error(UnknownObjectException)
|
150
|
+
lambda { browser.select_list(:name, "new_user_country").option(:text, /missing/).select }.should raise_error(UnknownObjectException)
|
151
|
+
end
|
152
|
+
|
153
|
+
bug "WTR-367", :watir do
|
154
|
+
it "raises MissingWayOfFindingObjectException when given a bad 'how' (page context)" do
|
155
|
+
lambda { browser.option(:missing, "Denmark").select }.should raise_error(MissingWayOfFindingObjectException)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
it "raises MissingWayOfFindingObjectException when given a bad 'how' (select_list context)" do
|
160
|
+
lambda { browser.select_list(:name, "new_user_country").option(:missing, "Denmark").select }.should raise_error(MissingWayOfFindingObjectException)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
bug "WTR-331", :watir do
|
165
|
+
describe "#class_name" do
|
166
|
+
bug "WTR-367", :watir do
|
167
|
+
it "is able to get attributes (page context)" do
|
168
|
+
browser.option(:text, 'Sweden').class_name.should == "scandinavia"
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
it "is able to get attributes (select_list context)" do
|
173
|
+
browser.select_list(:name, "new_user_country").option(:text , 'Sweden').class_name.should == "scandinavia"
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
describe "#respond_to?" do
|
179
|
+
it "returns true for all attribute methods" do
|
180
|
+
browser.select_list(:name, "new_user_country").option(:text, 'Sweden').should respond_to(:class_name)
|
181
|
+
browser.select_list(:name, "new_user_country").option(:text, 'Sweden').should respond_to(:id)
|
182
|
+
browser.select_list(:name, "new_user_country").option(:text, 'Sweden').should respond_to(:text)
|
183
|
+
browser.select_list(:name, "new_user_country").option(:text, 'Sweden').should respond_to(:name)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
end
|