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,101 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "H1", "H2", "H3", "H4", "H5", "H6" 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 element exists" do
|
13
|
+
browser.h1(:id, "header1").should exist
|
14
|
+
browser.h2(:id, /header2/).should exist
|
15
|
+
browser.h3(:text, "Header 3").should exist
|
16
|
+
browser.h4(:text, /Header 4/).should exist
|
17
|
+
browser.h5(:index, 1).should exist
|
18
|
+
browser.h6(:index, 1).should exist
|
19
|
+
browser.h1(:xpath, "//h1[@id='first_header']").should exist
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns true if the element exists (default how = :id)" do
|
23
|
+
browser.h1("first_header").should exist
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns the first h1 if given no args" do
|
27
|
+
browser.h1.should exist
|
28
|
+
end
|
29
|
+
|
30
|
+
it "returns true if the element exists" do
|
31
|
+
browser.h1(:id, "no_such_id").should_not exist
|
32
|
+
browser.h1(:id, /no_such_id/).should_not exist
|
33
|
+
browser.h1(:text, "no_such_text").should_not exist
|
34
|
+
browser.h1(:text, /no_such_text 1/).should_not exist
|
35
|
+
browser.h1(:index, 1337).should_not exist
|
36
|
+
browser.h1(:xpath, "//p[@id='no_such_id']").should_not exist
|
37
|
+
end
|
38
|
+
|
39
|
+
it "raises TypeError when 'what' argument is invalid" do
|
40
|
+
lambda { browser.h1(:id, 3.14).exists? }.should raise_error(TypeError)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
44
|
+
lambda { browser.h1(: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.h1(:index, 1).class_name.should == 'primary'
|
52
|
+
end
|
53
|
+
|
54
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
55
|
+
browser.h2(:index, 1).class_name.should == ''
|
56
|
+
end
|
57
|
+
|
58
|
+
it "raises UnknownObjectException if the p doesn't exist" do
|
59
|
+
lambda { browser.h2(: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.h1(:index, 1).id.should == "first_header"
|
66
|
+
end
|
67
|
+
|
68
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
69
|
+
browser.h3(:index, 1).id.should == ''
|
70
|
+
end
|
71
|
+
|
72
|
+
it "raises UnknownObjectException if the p doesn't exist" do
|
73
|
+
lambda { browser.h1(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
74
|
+
lambda { browser.h1(:index, 1337).id }.should raise_error(UnknownObjectException)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "#text" do
|
79
|
+
it "returns the text of the element" do
|
80
|
+
browser.h1(:index, 1).text.should == 'Header 1'
|
81
|
+
end
|
82
|
+
|
83
|
+
it "returns an empty string if the element doesn't contain any text" do
|
84
|
+
browser.h6(:id, "empty_header").text.should == ''
|
85
|
+
end
|
86
|
+
|
87
|
+
it "raises UnknownObjectException if the p doesn't exist" do
|
88
|
+
lambda { browser.h1(:id, 'no_such_id').text }.should raise_error(UnknownObjectException)
|
89
|
+
lambda { browser.h1(:xpath , "//h1[@id='no_such_id']").text }.should raise_error(UnknownObjectException)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "#respond_to?" do
|
94
|
+
it "returns true for all attribute methods" do
|
95
|
+
browser.h1(:index, 1).should respond_to(:class_name)
|
96
|
+
browser.h1(:index, 1).should respond_to(:id)
|
97
|
+
browser.h1(:index, 1).should respond_to(:text)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
bug "WTR-345", :watir do
|
5
|
+
|
6
|
+
describe "H1s", "H2s", "H3s", "H4s", "H5s", "H6s" do
|
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 h1s" do
|
13
|
+
browser.h2s.length.should == 9
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#[]" do
|
18
|
+
it "returns the h1 at the given index" do
|
19
|
+
browser.h1s[1].id.should == "first_header"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#each" do
|
24
|
+
it "iterates through header collections correctly" do
|
25
|
+
lengths = (1..6).collect do |i|
|
26
|
+
collection = browser.send(:"h#{i}s")
|
27
|
+
collection.each_with_index do |h, index|
|
28
|
+
h.name.should == browser.send(:"h#{i}", :index, index+1).name
|
29
|
+
h.id.should == browser.send(:"h#{i}", :index, index+1).id
|
30
|
+
h.value.should == browser.send(:"h#{i}", :index, index+1).value
|
31
|
+
end
|
32
|
+
collection.length
|
33
|
+
end
|
34
|
+
lengths.should == [2, 9, 2, 1, 1, 2]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,237 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Image" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/images.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
# Exists method
|
11
|
+
describe "#exists?" do
|
12
|
+
it "returns true when the image exists" do
|
13
|
+
browser.image(:id, 'square').should exist
|
14
|
+
browser.image(:id, /square/).should exist
|
15
|
+
browser.image(:name, 'circle').should exist
|
16
|
+
browser.image(:name, /circle/).should exist
|
17
|
+
|
18
|
+
bug "WTR-347", :watir do
|
19
|
+
browser.image(:src, 'images/circle.jpg').should exist
|
20
|
+
end
|
21
|
+
|
22
|
+
browser.image(:src, /circle/).should exist
|
23
|
+
browser.image(:alt, 'circle').should exist
|
24
|
+
browser.image(:alt, /cir/).should exist
|
25
|
+
browser.image(:title, 'Circle').should exist
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns the first image if given no args" do
|
29
|
+
browser.image.should exist
|
30
|
+
end
|
31
|
+
|
32
|
+
bug "WTR-347", :watir do
|
33
|
+
it "returns true if the element exists (default how = :src)" do
|
34
|
+
browser.image("images/circle.jpg").should exist
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns false when the image doesn't exist" do
|
39
|
+
browser.image(:id, 'no_such_id').should_not exist
|
40
|
+
browser.image(:id, /no_such_id/).should_not exist
|
41
|
+
browser.image(:name, 'no_such_name').should_not exist
|
42
|
+
browser.image(:name, /no_such_name/).should_not exist
|
43
|
+
browser.image(:src, 'no_such_src').should_not exist
|
44
|
+
browser.image(:src, /no_such_src/).should_not exist
|
45
|
+
browser.image(:alt, 'no_such_alt').should_not exist
|
46
|
+
browser.image(:alt, /no_such_alt/).should_not exist
|
47
|
+
browser.image(:title, 'no_such_title').should_not exist
|
48
|
+
browser.image(:title, /no_such_title/).should_not exist
|
49
|
+
end
|
50
|
+
|
51
|
+
it "raises TypeError when 'what' argument is invalid" do
|
52
|
+
lambda { browser.image(:id, 3.14).exists? }.should raise_error(TypeError)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
56
|
+
lambda { browser.image(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Attribute methods
|
61
|
+
describe "#alt" do
|
62
|
+
it "returns the alt attribute of the image if the image exists" do
|
63
|
+
browser.image(:name, 'square').alt.should == "square"
|
64
|
+
browser.image(:name, 'circle').alt.should == 'circle'
|
65
|
+
end
|
66
|
+
|
67
|
+
it "returns an empty string if the image exists and the attribute doesn't" do
|
68
|
+
browser.image(:index, 1).alt.should == ""
|
69
|
+
end
|
70
|
+
|
71
|
+
it "raises UnknownObjectException if the image doesn't exist" do
|
72
|
+
lambda { browser.image(:index, 1337).alt }.should raise_error(UnknownObjectException)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#id" do
|
77
|
+
it "returns the id attribute of the image if the image exists" do
|
78
|
+
browser.image(:name, 'square').id.should == 'square'
|
79
|
+
end
|
80
|
+
|
81
|
+
it "returns an empty string if the image exists and the attribute doesn't" do
|
82
|
+
browser.image(:index, 1).id.should == ""
|
83
|
+
end
|
84
|
+
|
85
|
+
it "raises UnknownObjectException if the image doesn't exist" do
|
86
|
+
lambda { browser.image(:index, 1337).id }.should raise_error(UnknownObjectException)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "#name" do
|
91
|
+
it "returns the name attribute of the image if the image exists" do
|
92
|
+
browser.image(:name, 'square').name.should == 'square'
|
93
|
+
end
|
94
|
+
|
95
|
+
it "returns an empty string if the image exists and the attribute doesn't" do
|
96
|
+
browser.image(:index, 1).name.should == ""
|
97
|
+
end
|
98
|
+
|
99
|
+
it "raises UnknownObjectException if the image doesn't exist" do
|
100
|
+
lambda { browser.image(:index, 1337).name }.should raise_error(UnknownObjectException)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "#src" do
|
105
|
+
it "returns the src attribute of the image if the image exists" do
|
106
|
+
browser.image(:name, 'square').src.should match(/square\.jpg/i)
|
107
|
+
end
|
108
|
+
|
109
|
+
it "returns an empty string if the image exists and the attribute doesn't" do
|
110
|
+
browser.image(:index, 1).src.should == ""
|
111
|
+
end
|
112
|
+
|
113
|
+
it "raises UnknownObjectException if the image doesn't exist" do
|
114
|
+
lambda { browser.image(:index, 1337).src }.should raise_error(UnknownObjectException)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "#title" do
|
119
|
+
it "returns the title attribute of the image if the image exists" do
|
120
|
+
browser.image(:id, 'square').title.should == 'Square'
|
121
|
+
end
|
122
|
+
|
123
|
+
it "returns an empty string if the image exists and the attribute doesn't" do
|
124
|
+
browser.image(:index, 1).title.should == ""
|
125
|
+
end
|
126
|
+
|
127
|
+
it "raises UnknownObjectException if the image doesn't exist" do
|
128
|
+
lambda { browser.image(:index, 1337).title }.should raise_error(UnknownObjectException)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe "#respond_to?" do
|
133
|
+
it "returns true for all attribute methods" do
|
134
|
+
browser.image(:index, 1).should respond_to(:class_name)
|
135
|
+
browser.image(:index, 1).should respond_to(:id)
|
136
|
+
browser.image(:index, 1).should respond_to(:name)
|
137
|
+
browser.image(:index, 1).should respond_to(:style)
|
138
|
+
browser.image(:index, 1).should respond_to(:text)
|
139
|
+
browser.image(:index, 1).should respond_to(:value)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
# Manipulation methods
|
144
|
+
describe "#click" do
|
145
|
+
it "raises UnknownObjectException when the image doesn't exist" do
|
146
|
+
lambda { browser.image(:id, 'missing_attribute').click }.should raise_error(UnknownObjectException)
|
147
|
+
lambda { browser.image(:name, 'missing_attribute').click }.should raise_error(UnknownObjectException)
|
148
|
+
lambda { browser.image(:src, 'missing_attribute').click }.should raise_error(UnknownObjectException)
|
149
|
+
lambda { browser.image(:alt, 'missing_attribute').click }.should raise_error(UnknownObjectException)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
# File methods
|
154
|
+
bug "WTR-347", :watir do
|
155
|
+
describe "#file_created_date" do
|
156
|
+
it "returns the date the image was created as reported by the file system" do
|
157
|
+
browser.goto(WatirSpec.host + "/images.html")
|
158
|
+
image = browser.image(:index, 2)
|
159
|
+
path = "#{File.dirname(__FILE__)}/fixtures/#{image.src}"
|
160
|
+
image.file_created_date.to_i.should == File.mtime(path).to_i
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
|
166
|
+
bug "WTR-346", :watir do
|
167
|
+
describe "#file_size" do
|
168
|
+
it "returns the file size of the image if the image exists" do
|
169
|
+
browser.image(:id, 'square').file_size.should == File.size("#{WatirSpec.files}/images/square.jpg".sub("file://", ''))
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
it "raises UnknownObjectException if the image doesn't exist" do
|
174
|
+
lambda { browser.image(:index, 1337).file_size }.should raise_error(UnknownObjectException)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
describe "#height" do
|
179
|
+
not_compliant_on :watir do
|
180
|
+
it "returns the height of the image if the image exists" do
|
181
|
+
browser.image(:id, 'square').height.should == 88
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
it "raises UnknownObjectException if the image doesn't exist" do
|
186
|
+
lambda { browser.image(:index, 1337).height }.should raise_error(UnknownObjectException)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
describe "#width" do
|
191
|
+
not_compliant_on :watir do
|
192
|
+
it "returns the width of the image if the image exists" do
|
193
|
+
browser.image(:id, 'square').width.should == 88
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
it "raises UnknownObjectException if the image doesn't exist" do
|
198
|
+
lambda { browser.image(:index, 1337).width }.should raise_error(UnknownObjectException)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
# Other
|
203
|
+
describe "#loaded?" do
|
204
|
+
it "returns true if the image has been loaded" do
|
205
|
+
browser.image(:name, 'circle').should be_loaded
|
206
|
+
browser.image(:alt, 'circle').should be_loaded
|
207
|
+
browser.image(:alt, /circle/).should be_loaded
|
208
|
+
end
|
209
|
+
|
210
|
+
it "returns false if the image has not been loaded" do
|
211
|
+
browser.image(:id, 'no_such_file').should_not be_loaded
|
212
|
+
end
|
213
|
+
|
214
|
+
it "raises UnknownObjectException if the image doesn't exist" do
|
215
|
+
lambda { browser.image(:name, 'no_such_image').loaded? }.should raise_error(UnknownObjectException)
|
216
|
+
lambda { browser.image(:id, 'no_such_image').loaded? }.should raise_error(UnknownObjectException)
|
217
|
+
lambda { browser.image(:src, 'no_such_image').loaded? }.should raise_error(UnknownObjectException)
|
218
|
+
lambda { browser.image(:alt, 'no_such_image').loaded? }.should raise_error(UnknownObjectException)
|
219
|
+
lambda { browser.image(:index, 1337).loaded? }.should raise_error(UnknownObjectException)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
describe "#save" do
|
224
|
+
bug "WTR-336", :watir do
|
225
|
+
it "saves the image to a file" do
|
226
|
+
file = "#{File.expand_path Dir.pwd}/sample.img.dat"
|
227
|
+
begin
|
228
|
+
browser.image(:index, 2).save(file)
|
229
|
+
File.exist?(file).should be_true
|
230
|
+
ensure
|
231
|
+
File.delete(file) if File.exist?(file)
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Images" 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 images" do
|
12
|
+
browser.images.length.should == 9
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#[]" do
|
17
|
+
it "returns the image at the given index" do
|
18
|
+
browser.images[6].id.should == "square"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#each" do
|
23
|
+
it "iterates through images correctly" do
|
24
|
+
count = 0
|
25
|
+
|
26
|
+
browser.images.each_with_index do |c, index|
|
27
|
+
c.name.should == browser.image(:index, index+1).name
|
28
|
+
c.id.should == browser.image(:index, index+1).id
|
29
|
+
c.value.should == browser.image(: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,181 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Ins" 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 'ins' exists" do
|
13
|
+
browser.ins(:id, "lead").should exist
|
14
|
+
browser.ins(:id, /lead/).should exist
|
15
|
+
browser.ins(:text, "This is an inserted text tag 1").should exist
|
16
|
+
browser.ins(:text, /This is an inserted text tag 1/).should exist
|
17
|
+
browser.ins(:class, "lead").should exist
|
18
|
+
browser.ins(:class, /lead/).should exist
|
19
|
+
browser.ins(:index, 1).should exist
|
20
|
+
browser.ins(:xpath, "//ins[@id='lead']").should exist
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns the first ins if given no args" do
|
24
|
+
browser.ins.should exist
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns true if the element exists (default how = :id)" do
|
28
|
+
browser.ins("lead").should exist
|
29
|
+
end
|
30
|
+
|
31
|
+
it "returns false if the element doesn't exist" do
|
32
|
+
browser.ins(:id, "no_such_id").should_not exist
|
33
|
+
browser.ins(:id, /no_such_id/).should_not exist
|
34
|
+
browser.ins(:text, "no_such_text").should_not exist
|
35
|
+
browser.ins(:text, /no_such_text/).should_not exist
|
36
|
+
browser.ins(:class, "no_such_class").should_not exist
|
37
|
+
browser.ins(:class, /no_such_class/).should_not exist
|
38
|
+
browser.ins(:index, 1337).should_not exist
|
39
|
+
browser.ins(:xpath, "//ins[@id='no_such_id']").should_not exist
|
40
|
+
end
|
41
|
+
|
42
|
+
it "raises TypeError when 'what' argument is invalid" do
|
43
|
+
lambda { browser.ins(:id, 3.14).exists? }.should raise_error(TypeError)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
47
|
+
lambda { browser.ins(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Attribute methods
|
52
|
+
describe "#class_name" do
|
53
|
+
it "returns the class attribute" do
|
54
|
+
browser.ins(:index, 1).class_name.should == 'lead'
|
55
|
+
end
|
56
|
+
|
57
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
58
|
+
browser.ins(:index, 3).class_name.should == ''
|
59
|
+
end
|
60
|
+
|
61
|
+
it "raises UnknownObjectException if the ins doesn't exist" do
|
62
|
+
lambda { browser.ins(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#id" do
|
67
|
+
it "returns the id attribute" do
|
68
|
+
browser.ins(:index, 1).id.should == "lead"
|
69
|
+
end
|
70
|
+
|
71
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
72
|
+
browser.ins(:index, 3).id.should == ''
|
73
|
+
end
|
74
|
+
|
75
|
+
it "raises UnknownObjectException if the ins doesn't exist" do
|
76
|
+
lambda { browser.ins(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
77
|
+
lambda { browser.ins(:index, 1337).id }.should raise_error(UnknownObjectException)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "#name" do
|
82
|
+
it "returns the name attribute" do
|
83
|
+
browser.ins(:index, 2).name.should == "invalid_attribute"
|
84
|
+
end
|
85
|
+
|
86
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
87
|
+
browser.ins(:index, 3).name.should == ''
|
88
|
+
end
|
89
|
+
|
90
|
+
it "raises UnknownObjectException if the ins doesn't exist" do
|
91
|
+
lambda { browser.ins(:id, "no_such_id").name }.should raise_error(UnknownObjectException)
|
92
|
+
lambda { browser.ins(:index, 1337).name }.should raise_error(UnknownObjectException)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "#title" do
|
97
|
+
it "returns the title attribute" do
|
98
|
+
browser.ins(:index, 1).title.should == 'Lorem ipsum'
|
99
|
+
end
|
100
|
+
|
101
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
102
|
+
browser.ins(:index, 3).title.should == ''
|
103
|
+
end
|
104
|
+
|
105
|
+
it "raises UnknownObjectException if the ins doesn't exist" do
|
106
|
+
lambda { browser.ins(:id, 'no_such_id').title }.should raise_error( UnknownObjectException)
|
107
|
+
lambda { browser.ins(:xpath, "//ins[@id='no_such_id']").title }.should raise_error( UnknownObjectException)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "#text" do
|
112
|
+
it "returns the text of the ins" do
|
113
|
+
browser.ins(:index, 2).text.should == 'This is an inserted text tag 2'
|
114
|
+
end
|
115
|
+
|
116
|
+
it "returns an empty string if the element doesn't contain any text" do
|
117
|
+
browser.ins(:index, 4).text.should == ''
|
118
|
+
end
|
119
|
+
|
120
|
+
it "raises UnknownObjectException if the ins doesn't exist" do
|
121
|
+
lambda { browser.ins(:id, 'no_such_id').text }.should raise_error( UnknownObjectException)
|
122
|
+
lambda { browser.ins(:xpath , "//ins[@id='no_such_id']").text }.should raise_error( UnknownObjectException)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe "#value" do
|
127
|
+
it "returns the value attribute" do
|
128
|
+
browser.ins(:index, 2).value.should == "invalid_attribute"
|
129
|
+
end
|
130
|
+
|
131
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
132
|
+
browser.ins(:index, 4).value.should == ''
|
133
|
+
end
|
134
|
+
|
135
|
+
it "raises UnknownObjectException if the ins doesn't exist" do
|
136
|
+
lambda { browser.ins(:id , "no_such_id").value }.should raise_error(UnknownObjectException)
|
137
|
+
lambda { browser.ins(:index , 1337).value }.should raise_error(UnknownObjectException)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
describe "#respond_to?" do
|
142
|
+
it "returns true for all attribute methods" do
|
143
|
+
browser.ins(:index, 1).should respond_to(:class_name)
|
144
|
+
browser.ins(:index, 1).should respond_to(:id)
|
145
|
+
browser.ins(:index, 1).should respond_to(:name)
|
146
|
+
browser.ins(:index, 1).should respond_to(:title)
|
147
|
+
browser.ins(:index, 1).should respond_to(:text)
|
148
|
+
browser.ins(:index, 1).should respond_to(:value)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
# Other
|
153
|
+
describe "#click" do
|
154
|
+
it "fires events" do
|
155
|
+
browser.ins(:name, 'footer').text.should_not include('Javascript')
|
156
|
+
browser.ins(:name, 'footer').click
|
157
|
+
browser.ins(:name, 'footer').text.should include('Javascript')
|
158
|
+
end
|
159
|
+
|
160
|
+
it "raises UnknownObjectException if the ins doesn't exist" do
|
161
|
+
lambda { browser.ins(:id, "no_such_id").click }.should raise_error(UnknownObjectException)
|
162
|
+
lambda { browser.ins(:title, "no_such_title").click }.should raise_error(UnknownObjectException)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
describe "#to_s" do
|
167
|
+
bug "WTR-350", :watir do
|
168
|
+
it "returns a human readable representation of the element" do
|
169
|
+
browser.ins(:index, 2).to_s.should == "tag: ins\n" +
|
170
|
+
" name: invalid_attribute\n" +
|
171
|
+
" value: invalid_attribute\n" +
|
172
|
+
" text: This is an inserted text tag 2"
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
it "raises UnknownObjectException if the p doesn't exist" do
|
177
|
+
lambda { browser.ins(:xpath, "//ins[@id='no_such_id']").to_s }.should raise_error( UnknownObjectException)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|