watir-webdriver 0.0.1.dev
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/.gitmodules +3 -0
- data/LICENSE +20 -0
- data/README.rdoc +32 -0
- data/Rakefile +107 -0
- data/TODO +15 -0
- data/VERSION +1 -0
- data/lib/watir-webdriver.rb +74 -0
- data/lib/watir-webdriver/base_element.rb +347 -0
- data/lib/watir-webdriver/browser.rb +130 -0
- data/lib/watir-webdriver/browserbot.js +34 -0
- data/lib/watir-webdriver/collections/buttons_collection.rb +13 -0
- data/lib/watir-webdriver/collections/element_collection.rb +45 -0
- data/lib/watir-webdriver/collections/table_rows_collection.rb +14 -0
- data/lib/watir-webdriver/collections/text_fields_collection.rb +13 -0
- data/lib/watir-webdriver/container.rb +24 -0
- data/lib/watir-webdriver/core_ext/string.rb +22 -0
- data/lib/watir-webdriver/elements/button.rb +27 -0
- data/lib/watir-webdriver/elements/checkbox.rb +23 -0
- data/lib/watir-webdriver/elements/file_field.rb +20 -0
- data/lib/watir-webdriver/elements/form.rb +11 -0
- data/lib/watir-webdriver/elements/generated.rb +941 -0
- data/lib/watir-webdriver/elements/headings.rb +48 -0
- data/lib/watir-webdriver/elements/hidden.rb +18 -0
- data/lib/watir-webdriver/elements/image.rb +33 -0
- data/lib/watir-webdriver/elements/input.rb +39 -0
- data/lib/watir-webdriver/elements/link.rb +13 -0
- data/lib/watir-webdriver/elements/option.rb +36 -0
- data/lib/watir-webdriver/elements/radio.rb +23 -0
- data/lib/watir-webdriver/elements/select_list.rb +73 -0
- data/lib/watir-webdriver/elements/shared_radio_checkbox.rb +13 -0
- data/lib/watir-webdriver/elements/table.rb +18 -0
- data/lib/watir-webdriver/elements/table_row.rb +17 -0
- data/lib/watir-webdriver/elements/text_field.rb +60 -0
- data/lib/watir-webdriver/exception.rb +20 -0
- data/lib/watir-webdriver/locators/button_locator.rb +57 -0
- data/lib/watir-webdriver/locators/element_locator.rb +269 -0
- data/lib/watir-webdriver/locators/table_row_locator.rb +25 -0
- data/lib/watir-webdriver/locators/text_field_locator.rb +61 -0
- data/lib/watir-webdriver/xpath_support.rb +23 -0
- data/spec/element_locator_spec.rb +11 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/watirspec/area_spec.rb +78 -0
- data/spec/watirspec/areas_spec.rb +31 -0
- data/spec/watirspec/browser_spec.rb +262 -0
- data/spec/watirspec/button_spec.rb +242 -0
- data/spec/watirspec/buttons_spec.rb +48 -0
- data/spec/watirspec/checkbox_spec.rb +272 -0
- data/spec/watirspec/checkboxes_spec.rb +32 -0
- data/spec/watirspec/dd_spec.rb +136 -0
- data/spec/watirspec/dds_spec.rb +31 -0
- data/spec/watirspec/div_spec.rb +222 -0
- data/spec/watirspec/divs_spec.rb +31 -0
- data/spec/watirspec/dl_spec.rb +136 -0
- data/spec/watirspec/dls_spec.rb +32 -0
- data/spec/watirspec/dt_spec.rb +136 -0
- data/spec/watirspec/dts_spec.rb +31 -0
- data/spec/watirspec/element_spec.rb +87 -0
- data/spec/watirspec/em_spec.rb +110 -0
- data/spec/watirspec/ems_spec.rb +32 -0
- data/spec/watirspec/filefield_spec.rb +119 -0
- data/spec/watirspec/filefields_spec.rb +32 -0
- data/spec/watirspec/form_spec.rb +63 -0
- data/spec/watirspec/forms_spec.rb +33 -0
- data/spec/watirspec/frame_spec.rb +140 -0
- data/spec/watirspec/frames_spec.rb +62 -0
- data/spec/watirspec/hidden_spec.rb +102 -0
- data/spec/watirspec/hiddens_spec.rb +32 -0
- data/spec/watirspec/hn_spec.rb +93 -0
- data/spec/watirspec/hns_spec.rb +38 -0
- data/spec/watirspec/image_spec.rb +207 -0
- data/spec/watirspec/images_spec.rb +31 -0
- data/spec/watirspec/label_spec.rb +75 -0
- data/spec/watirspec/labels_spec.rb +31 -0
- data/spec/watirspec/li_spec.rb +127 -0
- data/spec/watirspec/lib/guards.rb +59 -0
- data/spec/watirspec/lib/server.rb +127 -0
- data/spec/watirspec/lib/spec_helper.rb +79 -0
- data/spec/watirspec/lib/watirspec.rb +72 -0
- data/spec/watirspec/link_spec.rb +165 -0
- data/spec/watirspec/links_spec.rb +35 -0
- data/spec/watirspec/lis_spec.rb +31 -0
- data/spec/watirspec/map_spec.rb +92 -0
- data/spec/watirspec/maps_spec.rb +32 -0
- data/spec/watirspec/meta_spec.rb +22 -0
- data/spec/watirspec/metas_spec.rb +30 -0
- data/spec/watirspec/ol_spec.rb +78 -0
- data/spec/watirspec/ols_spec.rb +31 -0
- data/spec/watirspec/option_spec.rb +173 -0
- data/spec/watirspec/p_spec.rb +143 -0
- data/spec/watirspec/pre_spec.rb +125 -0
- data/spec/watirspec/pres_spec.rb +31 -0
- data/spec/watirspec/ps_spec.rb +31 -0
- data/spec/watirspec/radio_spec.rb +278 -0
- data/spec/watirspec/radios_spec.rb +32 -0
- data/spec/watirspec/select_list_spec.rb +318 -0
- data/spec/watirspec/select_lists_spec.rb +35 -0
- data/spec/watirspec/span_spec.rb +157 -0
- data/spec/watirspec/spans_spec.rb +57 -0
- data/spec/watirspec/spec_helper.rb +17 -0
- data/spec/watirspec/strong_spec.rb +89 -0
- data/spec/watirspec/strongs_spec.rb +32 -0
- data/spec/watirspec/table_bodies_spec.rb +45 -0
- data/spec/watirspec/table_body_spec.rb +98 -0
- data/spec/watirspec/table_cell_spec.rb +68 -0
- data/spec/watirspec/table_cells_spec.rb +47 -0
- data/spec/watirspec/table_footer_spec.rb +85 -0
- data/spec/watirspec/table_footers_spec.rb +47 -0
- data/spec/watirspec/table_header_spec.rb +85 -0
- data/spec/watirspec/table_headers_spec.rb +45 -0
- data/spec/watirspec/table_row_spec.rb +87 -0
- data/spec/watirspec/table_rows_spec.rb +50 -0
- data/spec/watirspec/table_spec.rb +166 -0
- data/spec/watirspec/tables_spec.rb +33 -0
- data/spec/watirspec/text_field_spec.rb +276 -0
- data/spec/watirspec/text_fields_spec.rb +35 -0
- data/spec/watirspec/ul_spec.rb +76 -0
- data/spec/watirspec/uls_spec.rb +33 -0
- data/spec/xpath_builder_spec.rb +49 -0
- data/support/html5/html5.idl +815 -0
- data/support/html5/html5_extras.idl +147 -0
- data/support/html5/idl_extractor.rb +73 -0
- data/support/html5/watir_visitor.rb +169 -0
- metadata +220 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
+
|
4
|
+
describe "Labels" 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 labels" do
|
12
|
+
browser.labels.length.should == 26 # changed this from 25 - Jari
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#[]" do
|
17
|
+
it "returns the pre at the given index" do
|
18
|
+
browser.labels[0].id.should == "first_label"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#each" do
|
23
|
+
it "iterates through labels correctly" do
|
24
|
+
browser.labels.each_with_index do |l, index|
|
25
|
+
l.id.should == browser.label(:index, index).id
|
26
|
+
l.value.should == browser.label(:index, index).value
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
+
|
4
|
+
describe "Li" 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 'li' exists" do
|
13
|
+
browser.li(:id, "non_link_1").should exist
|
14
|
+
browser.li(:id, /non_link_1/).should exist
|
15
|
+
browser.li(:text, "Non-link 3").should exist
|
16
|
+
browser.li(:text, /Non-link 3/).should exist
|
17
|
+
browser.li(:class, "nonlink").should exist
|
18
|
+
browser.li(:class, /nonlink/).should exist
|
19
|
+
browser.li(:index, 0).should exist
|
20
|
+
browser.li(:xpath, "//li[@id='non_link_1']").should exist
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns false if the 'li' doesn't exist" do
|
24
|
+
browser.li(:id, "no_such_id").should_not exist
|
25
|
+
browser.li(:id, /no_such_id/).should_not exist
|
26
|
+
browser.li(:text, "no_such_text").should_not exist
|
27
|
+
browser.li(:text, /no_such_text/).should_not exist
|
28
|
+
browser.li(:class, "no_such_class").should_not exist
|
29
|
+
browser.li(:class, /no_such_class/).should_not exist
|
30
|
+
browser.li(:index, 1337).should_not exist
|
31
|
+
browser.li(:xpath, "//li[@id='no_such_id']").should_not exist
|
32
|
+
end
|
33
|
+
|
34
|
+
it "raises TypeError when 'what' argument is invalid" do
|
35
|
+
lambda { browser.li(:id, 3.14).exists? }.should raise_error(TypeError)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
39
|
+
lambda { browser.li(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Attribute methods
|
44
|
+
describe "#class_name" do
|
45
|
+
it "returns the class attribute" do
|
46
|
+
browser.li(:id, 'non_link_1').class_name.should == 'nonlink'
|
47
|
+
end
|
48
|
+
|
49
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
50
|
+
browser.li(:index, 0).class_name.should == ''
|
51
|
+
end
|
52
|
+
|
53
|
+
it "raises UnknownObjectException if the li doesn't exist" do
|
54
|
+
lambda { browser.li(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "#id" do
|
59
|
+
it "returns the id attribute" do
|
60
|
+
browser.li(:class, 'nonlink').id.should == "non_link_1"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
64
|
+
browser.li(:index, 0).id.should == ''
|
65
|
+
end
|
66
|
+
|
67
|
+
it "raises UnknownObjectException if the li doesn't exist" do
|
68
|
+
lambda { browser.li(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
69
|
+
lambda { browser.li(:index, 1337).id }.should raise_error(UnknownObjectException)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "#title" do
|
74
|
+
it "returns the title attribute" do
|
75
|
+
browser.li(:id, 'non_link_1').title.should == 'This is not a link!'
|
76
|
+
end
|
77
|
+
|
78
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
79
|
+
browser.li(:index, 0).title.should == ''
|
80
|
+
end
|
81
|
+
|
82
|
+
it "raises UnknownObjectException if the li doesn't exist" do
|
83
|
+
lambda { browser.li(:id, 'no_such_id').title }.should raise_error( UnknownObjectException)
|
84
|
+
lambda { browser.li(:xpath, "//li[@id='no_such_id']").title }.should raise_error( UnknownObjectException)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "#text" do
|
89
|
+
it "returns the text of the p" do
|
90
|
+
browser.li(:id, 'non_link_1').text.should == 'Non-link 1'
|
91
|
+
end
|
92
|
+
|
93
|
+
it "returns an empty string if the element doesn't contain any text" do
|
94
|
+
browser.li(:index, 0).text.should == ''
|
95
|
+
end
|
96
|
+
|
97
|
+
it "raises UnknownObjectException if the li doesn't exist" do
|
98
|
+
lambda { browser.li(:id, 'no_such_id').text }.should raise_error( UnknownObjectException)
|
99
|
+
lambda { browser.li(:xpath , "//li[@id='no_such_id']").text }.should raise_error( UnknownObjectException)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "#respond_to?" do
|
104
|
+
it "returns true for all attribute methods" do
|
105
|
+
browser.li(:index, 0).should respond_to(:class_name)
|
106
|
+
browser.li(:index, 0).should respond_to(:id)
|
107
|
+
browser.li(:index, 0).should respond_to(:text)
|
108
|
+
browser.li(:index, 0).should respond_to(:title)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# Other
|
113
|
+
describe "#to_s" do
|
114
|
+
it "returns a human readable representation of the element" do
|
115
|
+
browser.li(:id, 'non_link_1').to_s.should == "tag: li\n" +
|
116
|
+
" id: non_link_1\n" +
|
117
|
+
" class: nonlink\n" +
|
118
|
+
" title: This is not a link!\n" +
|
119
|
+
" text: Non-link 1"
|
120
|
+
end
|
121
|
+
|
122
|
+
it "raises UnknownObjectException if the li doesn't exist" do
|
123
|
+
lambda { browser.li(:xpath, "//li[@id='no_such_id']").text }.should raise_error( UnknownObjectException)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module WatirSpec
|
3
|
+
module Guards
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def guards
|
7
|
+
@guards ||= Hash.new { |hash, key| hash[key] = [] }
|
8
|
+
end
|
9
|
+
|
10
|
+
def record(guard_name, impls, data)
|
11
|
+
impls.each do |impl|
|
12
|
+
guards[impl] << [guard_name, data]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def report
|
17
|
+
gs = guards[WatirSpec.implementation]
|
18
|
+
print "\n\nWatirSpec guards for this implementation: "
|
19
|
+
|
20
|
+
if gs.empty?
|
21
|
+
puts "none."
|
22
|
+
else
|
23
|
+
puts
|
24
|
+
gs.each do |guard_name, data|
|
25
|
+
puts "\t#{guard_name.to_s.ljust(20)}: #{data.inspect}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def deviates_on(*impls)
|
32
|
+
Guards.record :deviates, impls, :file => caller.first
|
33
|
+
return yield if WatirSpec.unguarded?
|
34
|
+
yield if impls.include? WatirSpec.implementation
|
35
|
+
end
|
36
|
+
|
37
|
+
def not_compliant_on(*impls)
|
38
|
+
Guards.record :not_compliant, impls, :file => caller.first
|
39
|
+
return yield if WatirSpec.unguarded?
|
40
|
+
yield unless impls.include? WatirSpec.implementation
|
41
|
+
end
|
42
|
+
|
43
|
+
def compliant_on(*impls)
|
44
|
+
Guards.record :compliant, impls, :file => caller.first
|
45
|
+
return yield if WatirSpec.unguarded?
|
46
|
+
yield if impls.include? WatirSpec.implementation
|
47
|
+
end
|
48
|
+
|
49
|
+
def bug(key, *impls)
|
50
|
+
Guards.record :bug, impls, :file => caller.first, :key => key
|
51
|
+
return yield if WatirSpec.unguarded?
|
52
|
+
yield unless impls.include? WatirSpec.implementation
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class Object
|
58
|
+
include WatirSpec::Guards
|
59
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module WatirSpec
|
3
|
+
class Server < Sinatra::Base
|
4
|
+
class << self
|
5
|
+
attr_accessor :autorun
|
6
|
+
|
7
|
+
def run_async
|
8
|
+
case WatirSpec.platform
|
9
|
+
when :java
|
10
|
+
Thread.new { run! }
|
11
|
+
sleep 0.1 until WatirSpec::Server.running?
|
12
|
+
when :windows
|
13
|
+
require "win32/process"
|
14
|
+
pid = Process.create(
|
15
|
+
:app_name => "#{WatirSpec.ruby} #{File.dirname(__FILE__)}/../spec_helper.rb",
|
16
|
+
:process_inherit => true,
|
17
|
+
:thread_inherit => true,
|
18
|
+
:inherit => true
|
19
|
+
).process_id
|
20
|
+
else
|
21
|
+
pid = fork { run! }
|
22
|
+
sleep 1
|
23
|
+
end
|
24
|
+
|
25
|
+
if pid
|
26
|
+
# is this really necessary?
|
27
|
+
at_exit {
|
28
|
+
begin
|
29
|
+
Process.kill 0, pid
|
30
|
+
alive = true
|
31
|
+
rescue Errno::ESRCH
|
32
|
+
alive = false
|
33
|
+
end
|
34
|
+
|
35
|
+
Process.kill(9, pid) if alive
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def run!
|
41
|
+
handler = detect_rack_handler
|
42
|
+
handler.run(self, :Host => host, :Port => port) { @running = true }
|
43
|
+
end
|
44
|
+
|
45
|
+
def autorun
|
46
|
+
@autorun ||= true
|
47
|
+
end
|
48
|
+
|
49
|
+
def should_run?
|
50
|
+
autorun && !running?
|
51
|
+
end
|
52
|
+
|
53
|
+
def running?
|
54
|
+
defined?(@running) && @running
|
55
|
+
end
|
56
|
+
end # class << Server
|
57
|
+
|
58
|
+
set :public, WatirSpec.html
|
59
|
+
set :static, true
|
60
|
+
set :run, false
|
61
|
+
set :environment, :production
|
62
|
+
set :host, "localhost" if WatirSpec.platform == :windows
|
63
|
+
set :port, 2000
|
64
|
+
set :server, %w[mongrel webrick]
|
65
|
+
|
66
|
+
get '/' do
|
67
|
+
self.class.name
|
68
|
+
end
|
69
|
+
|
70
|
+
post '/post_to_me' do
|
71
|
+
"You posted the following content:\n#{ env['rack.input'].read }"
|
72
|
+
end
|
73
|
+
|
74
|
+
get '/plain_text' do
|
75
|
+
content_type 'text/plain'
|
76
|
+
'This is text/plain'
|
77
|
+
end
|
78
|
+
|
79
|
+
get '/ajax' do
|
80
|
+
sleep 10
|
81
|
+
"A slooow ajax response"
|
82
|
+
end
|
83
|
+
|
84
|
+
get '/charset_mismatch' do
|
85
|
+
content_type 'text/html; charset=UTF-8'
|
86
|
+
<<-HTML
|
87
|
+
<html>
|
88
|
+
<head>
|
89
|
+
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" />
|
90
|
+
</head>
|
91
|
+
<body>
|
92
|
+
<h1>ø</h1>
|
93
|
+
</body>
|
94
|
+
</html>
|
95
|
+
HTML
|
96
|
+
end
|
97
|
+
|
98
|
+
get '/octet_stream' do
|
99
|
+
content_type 'application/octet-stream'
|
100
|
+
'This is application/octet-stream'
|
101
|
+
end
|
102
|
+
|
103
|
+
get '/set_cookie' do
|
104
|
+
content_type 'text/plain'
|
105
|
+
headers 'Set-Cookie' => "monster=/"
|
106
|
+
|
107
|
+
"C is for cookie, it's good enough for me"
|
108
|
+
end
|
109
|
+
|
110
|
+
get '/header_echo' do
|
111
|
+
content_type 'text/plain'
|
112
|
+
env.inspect
|
113
|
+
end
|
114
|
+
|
115
|
+
get '/authentication' do
|
116
|
+
auth = Rack::Auth::Basic::Request.new(env)
|
117
|
+
|
118
|
+
unless auth.provided? && auth.credentials == %w[foo bar]
|
119
|
+
headers 'WWW-Authenticate' => %(Basic realm="localhost")
|
120
|
+
halt 401, 'Authorization Required'
|
121
|
+
end
|
122
|
+
|
123
|
+
"ok"
|
124
|
+
end
|
125
|
+
|
126
|
+
end # Server
|
127
|
+
end # WatirSpec
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module WatirSpec
|
3
|
+
module SpecHelper
|
4
|
+
|
5
|
+
module BrowserHelper
|
6
|
+
def browser; @browser; end
|
7
|
+
end
|
8
|
+
|
9
|
+
module PersistentBrowserHelper
|
10
|
+
def browser; $browser; end
|
11
|
+
end
|
12
|
+
|
13
|
+
module MessagesHelper
|
14
|
+
def messages
|
15
|
+
browser.div(:id, 'messages').divs.map { |d| d.text }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
module_function
|
20
|
+
|
21
|
+
def execute
|
22
|
+
load_requires
|
23
|
+
configure
|
24
|
+
start_server
|
25
|
+
add_guard_hook
|
26
|
+
end
|
27
|
+
|
28
|
+
def configure
|
29
|
+
Thread.abort_on_exception = true
|
30
|
+
|
31
|
+
Spec::Runner.configure do |config|
|
32
|
+
config.include(MessagesHelper)
|
33
|
+
|
34
|
+
if WatirSpec.persistent_browser == false
|
35
|
+
config.include(BrowserHelper)
|
36
|
+
|
37
|
+
config.before(:all) { @browser = WatirSpec.new_browser }
|
38
|
+
config.after(:all) { @browser.close if @browser }
|
39
|
+
else
|
40
|
+
config.include(PersistentBrowserHelper)
|
41
|
+
$browser = WatirSpec.new_browser
|
42
|
+
at_exit { $browser.close }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def load_requires
|
48
|
+
# load spec_helper from containing folder, if it exists
|
49
|
+
hook = File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper.rb")
|
50
|
+
raise(Errno::ENOENT, hook) unless File.exist?(hook)
|
51
|
+
|
52
|
+
load hook
|
53
|
+
require "fileutils"
|
54
|
+
require "spec"
|
55
|
+
|
56
|
+
begin
|
57
|
+
require "ruby-debug"
|
58
|
+
Debugger.start
|
59
|
+
Debugger.settings[:autoeval] = true
|
60
|
+
Debugger.settings[:autolist] = 1
|
61
|
+
rescue LoadError
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def start_server
|
66
|
+
if WatirSpec::Server.should_run?
|
67
|
+
WatirSpec::Server.run_async
|
68
|
+
else
|
69
|
+
$stderr.puts "not running WatirSpec::Server"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def add_guard_hook
|
74
|
+
return if WatirSpec.unguarded?
|
75
|
+
at_exit { WatirSpec::Guards.report }
|
76
|
+
end
|
77
|
+
|
78
|
+
end # SpecHelper
|
79
|
+
end # WatirSpec
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module WatirSpec
|
3
|
+
class << self
|
4
|
+
attr_accessor :browser_args, :persistent_browser, :unguarded, :implementation
|
5
|
+
|
6
|
+
def html
|
7
|
+
File.expand_path("#{File.dirname(__FILE__)}/../html")
|
8
|
+
end
|
9
|
+
|
10
|
+
def files
|
11
|
+
"file://#{html}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def host
|
15
|
+
"http://#{Server.host}:#{Server.port}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def unguarded?
|
19
|
+
@unguarded ||= false
|
20
|
+
end
|
21
|
+
|
22
|
+
def platform
|
23
|
+
@platform ||= case RUBY_PLATFORM
|
24
|
+
when /java/
|
25
|
+
:java
|
26
|
+
when /mswin|msys|mingw32/
|
27
|
+
:windows
|
28
|
+
when /darwin/
|
29
|
+
:macosx
|
30
|
+
when /linux/
|
31
|
+
:linux
|
32
|
+
else
|
33
|
+
RUBY_PLATFORM
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def implementation
|
38
|
+
@implementation ||= case Browser.name
|
39
|
+
when "Watir::IE"
|
40
|
+
:watir
|
41
|
+
when "Watir::Firefox", "FireWatir::Firefox"
|
42
|
+
:firewatir
|
43
|
+
when "Celerity::Browser"
|
44
|
+
:celerity
|
45
|
+
else
|
46
|
+
:unknown
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def new_browser
|
51
|
+
args = WatirSpec.browser_args
|
52
|
+
args ? Browser.new(*args) : Browser.new
|
53
|
+
end
|
54
|
+
|
55
|
+
def ruby
|
56
|
+
if @ruby.nil?
|
57
|
+
if defined?(Gem)
|
58
|
+
@ruby = Gem.ruby
|
59
|
+
else
|
60
|
+
require "rbconfig"
|
61
|
+
rb = File.join(RbConfig::CONFIG.values_at('BINDIR', 'RUBY_INSTALL_NAME').compact)
|
62
|
+
ext = RbConfig::CONFIG['EXEEXT']
|
63
|
+
|
64
|
+
@ruby = "#{rb}#{ext}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
@ruby
|
69
|
+
end
|
70
|
+
|
71
|
+
end # class << WatirSpec
|
72
|
+
end # WatirSpec
|