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,14 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<meta charset="utf-8" />
|
3
|
+
<title>fire_event onScroll test case</title>
|
4
|
+
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
height: 200em;
|
8
|
+
}
|
9
|
+
</style>
|
10
|
+
|
11
|
+
<body onScroll="document.getElementById('result').innerHTML = 'PASS';">
|
12
|
+
<p id="result">FAIL</p>
|
13
|
+
</body>
|
14
|
+
|
@@ -0,0 +1,106 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Area" 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 area exists" do
|
13
|
+
browser.area(:id, "NCE").should exist
|
14
|
+
browser.area(:id, /NCE/).should exist
|
15
|
+
browser.area(:name, "NCE").should exist
|
16
|
+
browser.area(:name, /NCE/).should exist
|
17
|
+
browser.area(:title, "Tables").should exist
|
18
|
+
browser.area(:title, /Tables/).should exist
|
19
|
+
|
20
|
+
bug "WTR-342", :watir do
|
21
|
+
browser.area(:url, "tables.html").should exist
|
22
|
+
browser.area(:url, /tables/).should exist
|
23
|
+
browser.area(:href, "tables.html").should exist
|
24
|
+
browser.area(:href, /tables/).should exist
|
25
|
+
end
|
26
|
+
|
27
|
+
browser.area(:index, 1).should exist
|
28
|
+
browser.area(:xpath, "//area[@id='NCE']").should exist
|
29
|
+
end
|
30
|
+
|
31
|
+
it "returns true if the element exists (default how = :id)" do
|
32
|
+
browser.area("NCE").should exist
|
33
|
+
end
|
34
|
+
|
35
|
+
it "returns the first area if given no args" do
|
36
|
+
browser.area.should exist
|
37
|
+
end
|
38
|
+
|
39
|
+
it "returns false if the area doesn't exist" do
|
40
|
+
browser.area(:id, "no_such_id").should_not exist
|
41
|
+
browser.area(:id, /no_such_id/).should_not exist
|
42
|
+
browser.area(:name, "no_such_id").should_not exist
|
43
|
+
browser.area(:name, /no_such_id/).should_not exist
|
44
|
+
browser.area(:title, "no_such_title").should_not exist
|
45
|
+
browser.area(:title, /no_such_title/).should_not exist
|
46
|
+
|
47
|
+
bug "WTR-342", :watir do
|
48
|
+
browser.area(:url, "no_such_href").should_not exist
|
49
|
+
browser.area(:url, /no_such_href/).should_not exist
|
50
|
+
browser.area(:href, "tables.html").should exist
|
51
|
+
browser.area(:href, /tables/).should exist
|
52
|
+
end
|
53
|
+
|
54
|
+
browser.area(:index, 1337).should_not exist
|
55
|
+
browser.area(:xpath, "//area[@id='no_such_id']").should_not exist
|
56
|
+
end
|
57
|
+
|
58
|
+
it "raises TypeError when 'what' argument is invalid" do
|
59
|
+
lambda { browser.area(:id, 3.14).exists? }.should raise_error(TypeError)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
63
|
+
lambda { browser.area(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Attribute methods
|
68
|
+
describe "#id" do
|
69
|
+
it "returns the id attribute" do
|
70
|
+
browser.area(:index, 1).id.should == "NCE"
|
71
|
+
end
|
72
|
+
|
73
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
74
|
+
browser.area(:index, 3).id.should == ''
|
75
|
+
end
|
76
|
+
|
77
|
+
it "raises UnknownObjectException if the area doesn't exist" do
|
78
|
+
lambda { browser.area(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
79
|
+
lambda { browser.area(:index, 1337).id }.should raise_error(UnknownObjectException)
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "#name" do
|
85
|
+
it "returns the name attribute" do
|
86
|
+
browser.area(:index, 1).name.should == "NCE"
|
87
|
+
end
|
88
|
+
|
89
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
90
|
+
browser.area(:index, 3).name.should == ''
|
91
|
+
end
|
92
|
+
|
93
|
+
it "raises UnknownObjectException if the area doesn't exist" do
|
94
|
+
lambda { browser.area(:id, "no_such_id").name }.should raise_error(UnknownObjectException)
|
95
|
+
lambda { browser.area(:index, 1337).name }.should raise_error(UnknownObjectException)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe "#respond_to?" do
|
100
|
+
it "returns true for all attribute methods" do
|
101
|
+
browser.area(:index, 1).should respond_to(:id)
|
102
|
+
browser.area(:index, 1).should respond_to(:name)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Areas" 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 areas" do
|
12
|
+
browser.areas.length.should == 3
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#[]" do
|
17
|
+
it "returns the area at the given index" do
|
18
|
+
browser.areas[1].id.should == "NCE"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#each" do
|
23
|
+
it "iterates through areas correctly" do
|
24
|
+
count = 0
|
25
|
+
|
26
|
+
browser.areas.each_with_index do |a, index|
|
27
|
+
a.name.should == browser.area(:index, index+1).name
|
28
|
+
a.id.should == browser.area(:index, index+1).id
|
29
|
+
a.value.should == browser.area(: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,297 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Browser" do
|
5
|
+
|
6
|
+
describe "#exists?" do
|
7
|
+
it "returns true if we are at a page" do
|
8
|
+
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
9
|
+
browser.should exist
|
10
|
+
end
|
11
|
+
|
12
|
+
it "returns false after IE#close" do
|
13
|
+
b = WatirSpec.new_browser
|
14
|
+
b.close
|
15
|
+
b.should_not exist
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#html" do
|
20
|
+
# what guard we want to use here kind of depends on how other impls. behave
|
21
|
+
not_compliant_on :watir do
|
22
|
+
it "returns the downloaed HTML of the page" do
|
23
|
+
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
24
|
+
browser.html.should == File.read(File.dirname(__FILE__) + "/html/non_control_elements.html")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
deviates_on :watir do
|
29
|
+
it "returns the DOM of the page as an HTML string" do
|
30
|
+
browser.goto(WatirSpec.files + "/right_click.html")
|
31
|
+
browser.html.should == "<HTML><HEAD><TITLE>Right Click Test</TITLE>\r\n<META http-equiv=Content-type content=\"text/html; charset=utf-8\">\r\n<SCRIPT src=\"javascript/helpers.js\" type=text/javascript charset=utf-8></SCRIPT>\r\n</HEAD>\r\n<BODY>\r\n<DIV id=messages></DIV>\r\n<DIV oncontextmenu='WatirSpec.addMessage(\"right-clicked\")' id=click>Right click!</DIV></BODY></HTML>"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#title" do
|
37
|
+
it "returns the current page title" do
|
38
|
+
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
39
|
+
browser.title.should == "Non-control elements"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#status" do
|
44
|
+
bug "WTR-348", :watir do
|
45
|
+
it "returns the current value of window.status" do
|
46
|
+
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
47
|
+
|
48
|
+
# for firefox, this needs to be enabled in
|
49
|
+
# Preferences -> Content -> Advanced -> Change status bar text
|
50
|
+
browser.execute_script "window.status = 'All done!';"
|
51
|
+
browser.status.should == "All done!"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#text" do
|
57
|
+
it "returns the text of the page" do
|
58
|
+
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
59
|
+
browser.text.should include("Dubito, ergo cogito, ergo sum.")
|
60
|
+
end
|
61
|
+
|
62
|
+
it "returns the text also if the content-type is text/plain" do
|
63
|
+
# more specs for text/plain? what happens if we call other methods?
|
64
|
+
browser.goto(WatirSpec.host + "/plain_text")
|
65
|
+
browser.text.strip.should == 'This is text/plain'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "#url" do
|
70
|
+
it "returns the current url" do
|
71
|
+
browser.goto(WatirSpec.host + "/non_control_elements.html")
|
72
|
+
browser.url.should == WatirSpec.host + "/non_control_elements.html"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#document" do
|
77
|
+
it "returns the underlying object" do
|
78
|
+
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
79
|
+
|
80
|
+
case browser.class.name
|
81
|
+
when "Celerity::Browser"
|
82
|
+
browser.document.should be_instance_of(Java::ComGargoylesoftwareHtmlunitHtml::HtmlHtml)
|
83
|
+
else
|
84
|
+
browser.document.should_not be_nil
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe ".start" do
|
90
|
+
it "goes to the given URL and return an instance of itself" do
|
91
|
+
browser = WatirSpec.implementation.browser_class.start(WatirSpec.files + "/non_control_elements.html")
|
92
|
+
browser.should be_instance_of(WatirSpec.implementation.browser_class)
|
93
|
+
browser.title.should == "Non-control elements"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe "#goto" do
|
98
|
+
it "adds http:// to URLs with no URL scheme specified" do
|
99
|
+
url = WatirSpec.host[%r{http://(.*)}, 1]
|
100
|
+
url.should_not be_nil
|
101
|
+
browser.goto(url)
|
102
|
+
browser.url.should =~ %r[http://#{url}/?]
|
103
|
+
end
|
104
|
+
|
105
|
+
it "goes to the given url without raising errors" do
|
106
|
+
lambda { browser.goto(WatirSpec.files + "/non_control_elements.html") }.should_not raise_error
|
107
|
+
end
|
108
|
+
|
109
|
+
it "updates the page when location is changed with setTimeout + window.location" do
|
110
|
+
browser.goto(WatirSpec.files + "/timeout_window_location.html")
|
111
|
+
sleep 1
|
112
|
+
browser.url.should include("non_control_elements.html")
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe "#refresh" do
|
117
|
+
it "refreshes the page" do
|
118
|
+
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
119
|
+
browser.span(:name, 'footer').click
|
120
|
+
browser.span(:name, 'footer').text.should include('Javascript')
|
121
|
+
browser.refresh
|
122
|
+
browser.span(:name, 'footer').text.should_not include('Javascript')
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe "#execute_script" do
|
127
|
+
it "executes the given JavaScript on the current page" do
|
128
|
+
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
129
|
+
browser.pre(:id, 'rspec').text.should_not == "javascript text"
|
130
|
+
browser.execute_script("document.getElementById('rspec').innerHTML = 'javascript text'")
|
131
|
+
browser.pre(:id, 'rspec').text.should == "javascript text"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe "#back and #forward" do
|
136
|
+
it "goes to the previous page" do
|
137
|
+
browser.goto("#{WatirSpec.host}/non_control_elements.html")
|
138
|
+
orig_url = browser.url
|
139
|
+
browser.goto("#{WatirSpec.host}/tables.html")
|
140
|
+
new_url = browser.url
|
141
|
+
orig_url.should_not == new_url
|
142
|
+
browser.back
|
143
|
+
orig_url.should == browser.url
|
144
|
+
end
|
145
|
+
|
146
|
+
it "goes to the next page" do
|
147
|
+
urls = []
|
148
|
+
browser.goto(WatirSpec.host + "/non_control_elements.html")
|
149
|
+
urls << browser.url
|
150
|
+
browser.goto(WatirSpec.host + "/tables.html")
|
151
|
+
urls << browser.url
|
152
|
+
|
153
|
+
browser.back
|
154
|
+
browser.url.should == urls.first
|
155
|
+
browser.forward
|
156
|
+
browser.url.should == urls.last
|
157
|
+
end
|
158
|
+
|
159
|
+
it "navigates between several history items" do
|
160
|
+
urls = [ "#{WatirSpec.host}/non_control_elements.html",
|
161
|
+
"#{WatirSpec.host}/tables.html",
|
162
|
+
"#{WatirSpec.host}/forms_with_input_elements.html",
|
163
|
+
"#{WatirSpec.host}/definition_lists.html"
|
164
|
+
].map do |page|
|
165
|
+
browser.goto page
|
166
|
+
browser.url
|
167
|
+
end
|
168
|
+
|
169
|
+
3.times { browser.back }
|
170
|
+
browser.url.should == urls.first
|
171
|
+
2.times { browser.forward }
|
172
|
+
browser.url.should == urls[2]
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
# Other
|
177
|
+
describe "#contains_text" do
|
178
|
+
before :each do
|
179
|
+
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
180
|
+
end
|
181
|
+
|
182
|
+
it "raises ArgumentError when called with no arguments" do
|
183
|
+
lambda { browser.contains_text }.should raise_error(ArgumentError)
|
184
|
+
end
|
185
|
+
|
186
|
+
it "raises TypeError when called with wrong arguments" do
|
187
|
+
lambda { browser.contains_text(nil) }.should raise_error(TypeError)
|
188
|
+
lambda { browser.contains_text(42) }.should raise_error(TypeError)
|
189
|
+
end
|
190
|
+
|
191
|
+
it "returns the index if the given text exists" do
|
192
|
+
browser.contains_text('Dubito, ergo cogito, ergo sum.').should be_instance_of(Fixnum)
|
193
|
+
browser.contains_text(/Dubito.*sum./).should_not be_nil
|
194
|
+
end
|
195
|
+
|
196
|
+
it "returns nil if the text doesn't exist" do
|
197
|
+
browser.contains_text('no_such_text').should be_nil
|
198
|
+
browser.contains_text(/no_such_text/).should be_nil
|
199
|
+
end
|
200
|
+
|
201
|
+
it "does not raise error on a blank page" do
|
202
|
+
browser = WatirSpec.new_browser
|
203
|
+
lambda { browser.contains_text('') }.should_not raise_error
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
describe "#element_by_xpath" do
|
208
|
+
before :each do
|
209
|
+
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
|
210
|
+
end
|
211
|
+
|
212
|
+
bug "WTR-343", :watir do
|
213
|
+
it "finds submit buttons matching the given xpath" do
|
214
|
+
browser.element_by_xpath("//input[@type='submit']").should exist
|
215
|
+
end
|
216
|
+
|
217
|
+
it "finds reset buttons matching the given xpath" do
|
218
|
+
browser.element_by_xpath("//input[@type='reset']").should exist
|
219
|
+
end
|
220
|
+
|
221
|
+
it "finds image buttons matching the given xpath" do
|
222
|
+
browser.element_by_xpath("//input[@type='image']").should exist
|
223
|
+
end
|
224
|
+
|
225
|
+
it "finds the element matching the given xpath" do
|
226
|
+
browser.element_by_xpath("//input[@type='password']").should exist
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
bug "WTR-327", :watir do
|
231
|
+
it "will not find elements that doesn't exist" do
|
232
|
+
e = browser.element_by_xpath("//input[@type='foobar']")
|
233
|
+
e.should_not exist
|
234
|
+
lambda { e.set('foo') }.should raise_error(UnknownObjectException)
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
describe "#elements_by_xpath" do
|
240
|
+
before :each do
|
241
|
+
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
|
242
|
+
end
|
243
|
+
|
244
|
+
bug "WTR-344", :watir do
|
245
|
+
it "returns an Array of matching elements" do
|
246
|
+
objects = browser.elements_by_xpath("//*[@type='text']")
|
247
|
+
objects.should be_kind_of(Array)
|
248
|
+
objects.size.should == 6
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
bug "WTR-328", :watir do
|
253
|
+
it "returns an empty Array if there are no matching elements" do
|
254
|
+
objects = browser.elements_by_xpath("//*[@type='foobar']")
|
255
|
+
objects.should be_kind_of(Array)
|
256
|
+
objects.size.should == 0
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
describe "#add_checker" do
|
262
|
+
it "raises ArgumentError when not given any arguments" do
|
263
|
+
lambda { browser.add_checker }.should raise_error(ArgumentError)
|
264
|
+
end
|
265
|
+
|
266
|
+
it "runs the given proc on each page load" do
|
267
|
+
output = ''
|
268
|
+
proc = Proc.new { |browser| output << browser.text }
|
269
|
+
|
270
|
+
browser.add_checker(proc)
|
271
|
+
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
272
|
+
|
273
|
+
output.should include('Dubito, ergo cogito, ergo sum')
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
describe "#disable_checker" do
|
278
|
+
it "removes a previously added checker" do
|
279
|
+
output = ''
|
280
|
+
checker = lambda { |browser| output << browser.text }
|
281
|
+
|
282
|
+
browser.add_checker(checker)
|
283
|
+
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
284
|
+
output.should include('Dubito, ergo cogito, ergo sum')
|
285
|
+
|
286
|
+
browser.disable_checker(checker)
|
287
|
+
browser.goto(WatirSpec.files + "/definition_lists.html")
|
288
|
+
output.should_not include('definition_lists')
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
it "raises UnknownObjectException when trying to access DOM elements on plain/text-page" do
|
293
|
+
browser.goto(WatirSpec.host + "/plain_text")
|
294
|
+
lambda { browser.div(:id, 'foo').id }.should raise_error(UnknownObjectException)
|
295
|
+
end
|
296
|
+
|
297
|
+
end
|