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,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "TextFields" 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 text fields" do
|
12
|
+
browser.text_fields.length.should == 9
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#[]" do
|
17
|
+
it "returns the text field at the given index" do
|
18
|
+
browser.text_fields[1].id.should == "new_user_first_name"
|
19
|
+
browser.text_fields[2].id.should == "new_user_last_name"
|
20
|
+
browser.text_fields[3].id.should == "new_user_email"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#each" do
|
25
|
+
it "iterates through text fields correctly" do
|
26
|
+
index = 1
|
27
|
+
browser.text_fields.each do |r|
|
28
|
+
r.name.should == browser.text_field(:index, index).name
|
29
|
+
r.id.should == browser.text_field(:index, index).id
|
30
|
+
r.value.should == browser.text_field(:index, index).value
|
31
|
+
index += 1
|
32
|
+
end
|
33
|
+
browser.text_fields.length.should == index - 1
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Ul" 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 'ul' exists" do
|
13
|
+
browser.ul(:id, "navbar").should exist
|
14
|
+
browser.ul(:id, /navbar/).should exist
|
15
|
+
browser.ul(:index, 1).should exist
|
16
|
+
browser.ul(:xpath, "//ul[@id='navbar']").should exist
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns true if the element exists (default how = :id)" do
|
20
|
+
browser.ul("navbar").should exist
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns the first ul if given no args" do
|
24
|
+
browser.ul.should exist
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns false if the 'ul' doesn't exist" do
|
28
|
+
browser.ul(:id, "no_such_id").should_not exist
|
29
|
+
browser.ul(:id, /no_such_id/).should_not exist
|
30
|
+
browser.ul(:text, "no_such_text").should_not exist
|
31
|
+
browser.ul(:text, /no_such_text/).should_not exist
|
32
|
+
browser.ul(:class, "no_such_class").should_not exist
|
33
|
+
browser.ul(:class, /no_such_class/).should_not exist
|
34
|
+
browser.ul(:index, 1337).should_not exist
|
35
|
+
browser.ul(:xpath, "//ul[@id='no_such_id']").should_not exist
|
36
|
+
end
|
37
|
+
|
38
|
+
it "raises TypeError when 'what' argument is invalid" do
|
39
|
+
lambda { browser.ul(:id, 3.14).exists? }.should raise_error(TypeError)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
43
|
+
lambda { browser.ul(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Attribute methods
|
48
|
+
describe "#class_name" do
|
49
|
+
it "returns the class attribute" do
|
50
|
+
browser.ul(:id, 'navbar').class_name.should == 'navigation'
|
51
|
+
end
|
52
|
+
|
53
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
54
|
+
browser.ul(:index, 2).class_name.should == ''
|
55
|
+
end
|
56
|
+
|
57
|
+
it "raises UnknownObjectException if the ul doesn't exist" do
|
58
|
+
lambda { browser.ul(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "#id" do
|
63
|
+
it "returns the id attribute" do
|
64
|
+
browser.ul(:class, 'navigation').id.should == "navbar"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
68
|
+
browser.ul(:index, 2).id.should == ''
|
69
|
+
end
|
70
|
+
|
71
|
+
it "raises UnknownObjectException if the ul doesn't exist" do
|
72
|
+
lambda { browser.ul(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
73
|
+
lambda { browser.ul(:index, 1337).id }.should raise_error(UnknownObjectException)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "#respond_to?" do
|
78
|
+
it "returns true for all attribute methods" do
|
79
|
+
browser.ul(:index, 1).should respond_to(:class_name)
|
80
|
+
browser.ul(:index, 1).should respond_to(:id)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
bug "WTR-332", :watir do
|
5
|
+
describe "Uls" do
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#length" do
|
12
|
+
it "returns the number of uls" do
|
13
|
+
browser.uls.length.should == 2
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#[]" do
|
18
|
+
it "returns the ul at the given index" do
|
19
|
+
browser.uls[1].id.should == "navbar"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#each" do
|
24
|
+
it "iterates through uls correctly" do
|
25
|
+
count = 0
|
26
|
+
|
27
|
+
browser.uls.each_with_index do |ul, index|
|
28
|
+
ul.name.should == browser.ul(:index, index+1).name
|
29
|
+
ul.id.should == browser.ul(:index, index+1).id
|
30
|
+
ul.value.should == browser.ul(:index, index+1).value
|
31
|
+
|
32
|
+
count += 1
|
33
|
+
end
|
34
|
+
|
35
|
+
count.should > 0
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,176 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "IE" do
|
5
|
+
|
6
|
+
# Class methods
|
7
|
+
it "responds to .speed" do
|
8
|
+
WatirSpec.implementation.browser_class.should respond_to("speed")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "responds to .speed=" do
|
12
|
+
WatirSpec.implementation.browser_class.should respond_to("speed=")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "responds to .attach_timeout" do
|
16
|
+
WatirSpec.implementation.browser_class.should respond_to("attach_timeout")
|
17
|
+
end
|
18
|
+
|
19
|
+
it "responds to .attach_timeout=" do
|
20
|
+
WatirSpec.implementation.browser_class.should respond_to("attach_timeout=")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "responds to .visible" do
|
24
|
+
WatirSpec.implementation.browser_class.should respond_to("visible")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "responds to .each" do
|
28
|
+
WatirSpec.implementation.browser_class.should respond_to("each")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "responds to .start" do
|
32
|
+
WatirSpec.implementation.browser_class.should respond_to("start")
|
33
|
+
end
|
34
|
+
|
35
|
+
# Instance methods
|
36
|
+
it "responds to #visible" do
|
37
|
+
browser.should respond_to("visible")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "responds to #visible=" do
|
41
|
+
browser.should respond_to("visible=")
|
42
|
+
end
|
43
|
+
|
44
|
+
it "responds to #wait" do
|
45
|
+
browser.should respond_to("wait")
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#bring_to_front" do
|
49
|
+
it "returns true" do
|
50
|
+
browser.bring_to_front.should be_true
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#checkBox" do
|
55
|
+
it "behaves like #checkbox" do
|
56
|
+
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
|
57
|
+
browser.checkbox(:id, "new_user_interests_books").should exist
|
58
|
+
browser.checkbox(:id, "new_user_interests_cars").should_not be_set
|
59
|
+
browser.checkbox(:id, "new_user_interests_cars").set
|
60
|
+
browser.checkbox(:id, "new_user_interests_cars").should be_set
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "Image" do
|
67
|
+
|
68
|
+
before :each do
|
69
|
+
browser.goto(WatirSpec.files + "/images.html")
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "#hasLoaded?" do
|
73
|
+
it "behaves like #loaded?" do
|
74
|
+
browser.image(:name, 'circle').hasLoaded?.should be_true
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "#fileSize" do
|
79
|
+
bug "WTR-346", :watir do
|
80
|
+
it "behaves like #file_size" do
|
81
|
+
browser.image(:id, 'square').fileSize.should == 788
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "#fileCreatedDate" do
|
87
|
+
bug "WTR-347", :watir do
|
88
|
+
it "behaves like #file_created_date" do
|
89
|
+
browser.goto(WatirSpec.host + "/images.html")
|
90
|
+
image = browser.image(:index, 2)
|
91
|
+
path = File.dirname(__FILE__) + "/html/#{image.src}"
|
92
|
+
image.file_created_date.to_i.should == File.mtime(path).to_i
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
describe "RadioCheckCommon" do
|
100
|
+
|
101
|
+
before :each do
|
102
|
+
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "#isSet?" do
|
106
|
+
it "behaves like #set?" do
|
107
|
+
browser.radio(:id, "new_user_newsletter_yes").isSet?.should be_true
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "#getState" do
|
112
|
+
it "behaves like #set?" do
|
113
|
+
browser.checkbox(:id, "new_user_interests_books").getState.should be_true
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "SelectList" do
|
120
|
+
|
121
|
+
before :each do
|
122
|
+
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
|
123
|
+
end
|
124
|
+
|
125
|
+
describe "#getSelectedItems" do
|
126
|
+
it "behaves like #selected_options" do
|
127
|
+
browser.select_list(:name, "new_user_country").getSelectedItems.should == ["Norway"]
|
128
|
+
browser.select_list(:name, "new_user_languages").getSelectedItems.should == ["English", "Norwegian"]
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe "#getAllContents" do
|
133
|
+
it "behaves like #options" do
|
134
|
+
expected = ["Denmark" ,"Norway" , "Sweden" , "United Kingdom", "USA", "Germany"]
|
135
|
+
sl = browser.select_list(:name, "new_user_country")
|
136
|
+
sl.getAllContents.should == sl.options
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe "#clearSelection" do
|
141
|
+
it "behaves like #clear" do
|
142
|
+
browser.select_list(:name, "new_user_languages").clearSelection
|
143
|
+
browser.select_list(:name, "new_user_languages").getSelectedItems.should be_empty
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
148
|
+
|
149
|
+
describe "TextField" do
|
150
|
+
|
151
|
+
before :each do
|
152
|
+
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
|
153
|
+
end
|
154
|
+
|
155
|
+
describe "#dragContentsTo" do
|
156
|
+
it "behaves like #drag_contents_to" do
|
157
|
+
browser.text_field(:name, "new_user_first_name").set("Smith")
|
158
|
+
browser.text_field(:name, "new_user_first_name").dragContentsTo(:name, "new_user_last_name")
|
159
|
+
browser.text_field(:name, "new_user_first_name").value.should be_empty
|
160
|
+
browser.text_field(:id, "new_user_last_name").value.should == "Smith"
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
describe "#getContents" do
|
165
|
+
it "behaves like #get_contents" do
|
166
|
+
browser.text_field(:name, "new_user_occupation").getContents.should == "Developer"
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
describe "#requires_typing" do
|
171
|
+
it "responds to the method" do
|
172
|
+
browser.text_field(:name, "new_user_occupation").should respond_to(:requires_typing)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
$LOAD_PATH.unshift File.dirname(__FILE__)
|
3
|
+
$LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__)
|
4
|
+
require 'rspec'
|
5
|
+
|
6
|
+
require 'guards'
|
7
|
+
require 'server'
|
8
|
+
|
9
|
+
require 'operawatir/helper'
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.mock_with :rr
|
13
|
+
end
|
14
|
+
|
15
|
+
module WatirSpec
|
16
|
+
extend self
|
17
|
+
|
18
|
+
attr_accessor :args, :guarded
|
19
|
+
|
20
|
+
def host
|
21
|
+
"http://#{Server.bind}:#{Server.port}"
|
22
|
+
end
|
23
|
+
alias_method :files, :host
|
24
|
+
|
25
|
+
def guards
|
26
|
+
@guards ||= []
|
27
|
+
end
|
28
|
+
|
29
|
+
def guarded?
|
30
|
+
!!@guarded
|
31
|
+
end
|
32
|
+
|
33
|
+
def new_browser
|
34
|
+
OperaWatir::Helper.browser
|
35
|
+
end
|
36
|
+
|
37
|
+
module Helpers
|
38
|
+
def fixture(*paths)
|
39
|
+
[WatirSpec.host, *paths].join('/')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
include OperaWatir::Exceptions
|
46
|
+
|
47
|
+
include WatirSpec::Guard::Helpers
|
48
|
+
|
49
|
+
RSpec.configure do |config|
|
50
|
+
config.include WatirSpec::Helpers
|
51
|
+
config.include OperaWatir::Helper::SpecHelpers
|
52
|
+
|
53
|
+
config.before(:suite) do
|
54
|
+
Thread.new { WatirSpec::Server.run! }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
data/utils/Rakefile
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "spec"
|
3
|
+
require "spec/rake/spectask"
|
4
|
+
require "pathname"
|
5
|
+
|
6
|
+
all_tests = {}
|
7
|
+
all_files = Dir["**/*.rb"]
|
8
|
+
|
9
|
+
all_files.each do |filename|
|
10
|
+
if filename =~ /\//
|
11
|
+
sub = filename.split("/")
|
12
|
+
subfilename = sub[1]
|
13
|
+
|
14
|
+
unless all_tests.has_key?(sub[0])
|
15
|
+
all_tests.merge!({sub[0] => {}})
|
16
|
+
end
|
17
|
+
|
18
|
+
test = {subfilename[0..-4] => subfilename}
|
19
|
+
all_tests[sub[0]].merge!(test)
|
20
|
+
elsif filename =~ /helper.rb/
|
21
|
+
next
|
22
|
+
else
|
23
|
+
test = {filename[0..-4] => filename}
|
24
|
+
all_tests.merge!(test)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
spec_opts = ["--color", "--require rubygems"] #, "--format OperaHelperFormatter"]
|
29
|
+
spec_files = []
|
30
|
+
|
31
|
+
# All tests
|
32
|
+
desc "All tests"
|
33
|
+
Spec::Rake::SpecTask.new("test") do |t|
|
34
|
+
all_tests.each do |testname, testfile|
|
35
|
+
if testfile.kind_of?(Hash)
|
36
|
+
testfile.each do |subtestname, subtestfile|
|
37
|
+
spec_files.push testname + "/" + subtestfile
|
38
|
+
end
|
39
|
+
else
|
40
|
+
spec_files.push testfile
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
t.spec_opts = spec_opts
|
45
|
+
t.spec_files = [spec_files]
|
46
|
+
end
|
47
|
+
|
48
|
+
namespace :test do
|
49
|
+
all_tests.each_pair do |testname, testfile|
|
50
|
+
if testfile.kind_of?(Hash)
|
51
|
+
testfile.each_pair do |subtestname, subtestfile|
|
52
|
+
testfile[subtestname] = testname + "/" + subtestfile
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "All " + testname + " tests"
|
56
|
+
Spec::Rake::SpecTask.new(testname) do |t|
|
57
|
+
t.spec_opts = spec_opts
|
58
|
+
t.spec_files = testfile.values
|
59
|
+
end
|
60
|
+
|
61
|
+
namespace testname do
|
62
|
+
testfile.each_pair do |subtestname, subtestfile|
|
63
|
+
desc subtestname + " tests"
|
64
|
+
Spec::Rake::SpecTask.new(subtestname) do |t|
|
65
|
+
t.spec_opts = spec_opts
|
66
|
+
t.spec_files = [subtestfile]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
else
|
71
|
+
desc testname + " tests"
|
72
|
+
Spec::Rake::SpecTask.new(testname) do |t|
|
73
|
+
t.spec_opts = spec_opts
|
74
|
+
t.spec_files = [testfile]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|