watirmark 5.14.16 → 5.27.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/watirmark +2 -8
- data/generators/new_project/generator.rb +58 -0
- data/{app_generators/create_project/templates/project → generators/new_project/templates}/config.yml.erb +0 -0
- data/{app_generators/create_project → generators/new_project}/templates/features/env.rb.erb +0 -0
- data/{app_generators/create_project → generators/new_project}/templates/features/model_steps.rb.erb +0 -0
- data/{app_generators/create_project → generators/new_project}/templates/features/post_error_steps.rb.erb +0 -0
- data/{app_generators/create_project → generators/new_project}/templates/features/sample.feature.erb +0 -0
- data/{app_generators/create_project → generators/new_project}/templates/features/site_steps.rb.erb +0 -0
- data/generators/new_project/templates/gemfile.rb.erb +10 -0
- data/generators/new_project/templates/generators/mvc/generator.rb.erb +61 -0
- data/generators/new_project/templates/generators/mvc/templates/controller.rb.erb +9 -0
- data/generators/new_project/templates/generators/mvc/templates/model.rb.erb +7 -0
- data/generators/new_project/templates/generators/mvc/templates/view.rb.erb +16 -0
- data/{app_generators/create_project/templates/library → generators/new_project/templates/lib}/configuration.rb.erb +0 -0
- data/{app_generators/create_project/templates/library → generators/new_project/templates/lib}/core_libraries.rb.erb +0 -0
- data/{app_generators/create_project/templates/library → generators/new_project/templates/lib}/loader.rb.erb +0 -0
- data/{app_generators/create_project/templates/library → generators/new_project/templates/lib/name/checkers}/page_load_checker.rb.erb +0 -0
- data/{app_generators/create_project/templates/library → generators/new_project/templates/lib/name/checkers}/post_errors_checker.rb.erb +0 -0
- data/{app_generators/create_project/templates/library → generators/new_project/templates/lib/name/site}/base_controller.rb.erb +0 -0
- data/{app_generators/create_project/templates/library → generators/new_project/templates/lib/name/site}/base_view.rb.erb +0 -0
- data/{app_generators/create_project/templates/library → generators/new_project/templates/lib/name/site}/search_controller.rb.erb +0 -0
- data/{app_generators/create_project/templates/library/project_require_file.rb.erb → generators/new_project/templates/lib/name.rb.erb} +0 -0
- data/{app_generators/create_project/templates/library → generators/new_project/templates/lib}/workflows.rb.erb +0 -0
- data/{app_generators/create_project/templates/project → generators/new_project/templates}/rakefile.rb.erb +1 -1
- data/generators/new_project/templates/script/generate.rb.erb +4 -0
- data/lib/watirmark/at_exit.rb +5 -9
- data/lib/watirmark/configuration.rb +7 -2
- data/lib/watirmark/controller/actions.rb +35 -12
- data/lib/watirmark/controller/controller.rb +8 -4
- data/lib/watirmark/controller/dialogs.rb +3 -3
- data/lib/watirmark/cucumber/email_helper.rb +19 -0
- data/lib/watirmark/cucumber/env.rb +6 -5
- data/lib/watirmark/cucumber/hook_helper.rb +38 -0
- data/lib/watirmark/cucumber/hooks.rb +13 -8
- data/lib/watirmark/cucumber/load_cached_models.rb +9 -0
- data/lib/watirmark/cucumber/model_helper.rb +4 -4
- data/lib/watirmark/cucumber/transforms.rb +3 -1
- data/lib/watirmark/extensions/ruby_extensions.rb +8 -0
- data/lib/watirmark/extensions/webdriver_extensions.rb +38 -3
- data/lib/watirmark/formatters/snapshot_formatter.rb +3 -0
- data/lib/watirmark/models/cucumber_helper.rb +12 -5
- data/lib/watirmark/models/factory.rb +35 -2
- data/lib/watirmark/page/page.rb +1 -0
- data/lib/watirmark/page/page_definition.rb +7 -5
- data/lib/watirmark/profile.rb +2 -2
- data/lib/watirmark/rake/smoketest.rb +6 -4
- data/lib/watirmark/screenshot.rb +3 -8
- data/lib/watirmark/session.rb +105 -9
- data/lib/watirmark/version.rb +1 -1
- data/lib/watirmark.rb +1 -8
- data/spec/config_spec.rb +45 -37
- data/spec/controller_actions_spec.rb +70 -7
- data/spec/controller_spec.rb +103 -83
- data/spec/model_factory_spec.rb +191 -8
- data/spec/model_traits_spec.rb +5 -0
- data/spec/page_spec.rb +10 -2
- data/spec/process_page_spec.rb +3 -3
- data/spec/session_spec.rb +56 -0
- data/spec/spec_helper.rb +1 -1
- metadata +146 -142
- data/app_generators/create_project/create_project_generator.rb +0 -115
- data/app_generators/create_project/templates/generators/controller.rb.erb +0 -9
- data/app_generators/create_project/templates/generators/generate.rb.erb +0 -9
- data/app_generators/create_project/templates/generators/model.rb.erb +0 -7
- data/app_generators/create_project/templates/generators/mvc_generator.rb.erb +0 -100
- data/app_generators/create_project/templates/generators/rbeautify.rb.erb +0 -212
- data/app_generators/create_project/templates/generators/view.rb.erb +0 -16
- data/app_generators/create_project/templates/generators/workflow_loader.rb.erb +0 -1
- data/app_generators/create_project/templates/project/gemfile.rb.erb +0 -11
- data/bin/etapestry/Gemfile +0 -11
- data/bin/etapestry/config.yml +0 -3
- data/bin/etapestry/features/etapestry_home.feature +0 -5
- data/bin/etapestry/features/step_definitions/model_steps.rb +0 -9
- data/bin/etapestry/features/step_definitions/post_error_steps.rb +0 -15
- data/bin/etapestry/features/step_definitions/site_steps.rb +0 -7
- data/bin/etapestry/features/support/env.rb +0 -8
- data/bin/etapestry/generators/mvc/mvc_generator.rb +0 -100
- data/bin/etapestry/generators/mvc/rbeautify.rb +0 -212
- data/bin/etapestry/generators/mvc/templates/controller.rb.erb +0 -9
- data/bin/etapestry/generators/mvc/templates/model.rb.erb +0 -7
- data/bin/etapestry/generators/mvc/templates/view.rb.erb +0 -16
- data/bin/etapestry/generators/mvc/templates/workflow_loader.rb.erb +0 -1
- data/bin/etapestry/lib/etapestry/checkers/page_load_checker.rb +0 -11
- data/bin/etapestry/lib/etapestry/checkers/post_errors_checker.rb +0 -23
- data/bin/etapestry/lib/etapestry/configuration.rb +0 -6
- data/bin/etapestry/lib/etapestry/core_libraries.rb +0 -9
- data/bin/etapestry/lib/etapestry/loader.rb +0 -23
- data/bin/etapestry/lib/etapestry/site/base_controller.rb +0 -9
- data/bin/etapestry/lib/etapestry/site/base_view.rb +0 -6
- data/bin/etapestry/lib/etapestry/site/search_controller.rb +0 -12
- data/bin/etapestry/lib/etapestry/workflows.rb +0 -0
- data/bin/etapestry/lib/etapestry.rb +0 -8
- data/bin/etapestry/rakefile.rb +0 -21
- data/bin/etapestry/script/generate.rb +0 -9
- data/bin/twitter/features/hashtag_search.feature +0 -93
- data/bin/twitter/features/step_definitions/hashtag_steps.rb +0 -9
- data/bin/twitter/lib/twitter/workflows/search/result_controller.rb +0 -13
- data/bin/twitter/lib/twitter/workflows/search/result_model.rb +0 -5
- data/bin/twitter/lib/twitter/workflows/search/result_view.rb +0 -19
@@ -136,9 +136,13 @@ module Watir
|
|
136
136
|
end
|
137
137
|
|
138
138
|
class Element
|
139
|
-
|
140
|
-
|
141
|
-
|
139
|
+
begin
|
140
|
+
alias :prev_sibling :previous_sibling
|
141
|
+
alias :prevsibling :previous_sibling
|
142
|
+
alias :nextsibling :next_sibling
|
143
|
+
rescue NameError
|
144
|
+
# not using convio-specific webdriver. Ignore and continue
|
145
|
+
end
|
142
146
|
|
143
147
|
def click_if_exists
|
144
148
|
click if exists?
|
@@ -147,4 +151,35 @@ module Watir
|
|
147
151
|
alias :click_no_wait :click
|
148
152
|
end
|
149
153
|
|
154
|
+
class TextFieldLocator
|
155
|
+
def validate_element(element)
|
156
|
+
if element.tag_name.downcase == 'textarea'
|
157
|
+
warn "Locating textareas with '#text_field' is deprecated. Please, use '#textarea' method instead for #{@selector}"
|
158
|
+
end
|
159
|
+
super
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
|
150
164
|
end
|
165
|
+
|
166
|
+
module Selenium
|
167
|
+
module WebDriver
|
168
|
+
module Chrome
|
169
|
+
class Service
|
170
|
+
alias :stop_original :stop
|
171
|
+
def stop
|
172
|
+
watirmark_close_browser
|
173
|
+
stop_original
|
174
|
+
end
|
175
|
+
|
176
|
+
def watirmark_close_browser
|
177
|
+
return if @process.nil? || @process.exited? || @stopped
|
178
|
+
@stopped = true
|
179
|
+
config = Watirmark::Configuration.instance
|
180
|
+
Watirmark::Session.instance.closebrowser if config.closebrowseronexit || config.headless
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
@@ -16,6 +16,9 @@ module RSpec
|
|
16
16
|
snapshot = "#{Time.now.to_i} - #{append_text}.png"
|
17
17
|
Page.browser.screenshot.save "#{@path}/#{snapshot}"
|
18
18
|
end
|
19
|
+
rescue Exception => e
|
20
|
+
# an exception occurred. We don't want exception to occur here or we'll get false positive test results.
|
21
|
+
Watirmark.logger.warn "An exception was rescued in example_failed for SnapshotFormatter. This exception is ignored"
|
19
22
|
end
|
20
23
|
end
|
21
24
|
end
|
@@ -24,13 +24,20 @@ module Watirmark
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def insert_model(text)
|
27
|
+
return text unless text.class == String || text.class == Cucumber::Ast::DocString
|
27
28
|
result = text
|
28
|
-
|
29
|
-
|
29
|
+
method_regexp = /\[([^\[\]]+)\]\.(\w+)/
|
30
|
+
model_regexp = /\[([^\[\]]+)\]/
|
31
|
+
if text =~ method_regexp
|
32
|
+
while result =~ method_regexp #get value from models
|
33
|
+
model_name = $1
|
34
|
+
method = $2
|
35
|
+
value = DataModels[model_name].send method.to_sym
|
36
|
+
result.sub!(method_regexp, value.to_s)
|
37
|
+
end
|
38
|
+
elsif text =~ model_regexp
|
30
39
|
model_name = $1
|
31
|
-
|
32
|
-
value = DataModels[model_name].send method.to_sym
|
33
|
-
result.sub!(regexp, value.to_s)
|
40
|
+
result = DataModels[model_name] if DataModels[model_name] != nil
|
34
41
|
end
|
35
42
|
result
|
36
43
|
end
|
@@ -17,6 +17,16 @@ module Watirmark
|
|
17
17
|
attr_accessor :defaults, :model_name, :models, :parent, :children, :model_type
|
18
18
|
attr_reader :keywords
|
19
19
|
|
20
|
+
def marshal_dump
|
21
|
+
[@keywords, @model_name, @models, @parent, @children, @model_type, self.to_h]
|
22
|
+
end
|
23
|
+
|
24
|
+
def marshal_load(obj)
|
25
|
+
keyword_values = obj.pop
|
26
|
+
@keywords, @model_name, @models, @parent, @children, @model_type = obj
|
27
|
+
update keyword_values
|
28
|
+
end
|
29
|
+
|
20
30
|
def initialize(params={})
|
21
31
|
@params = params
|
22
32
|
@model_type = self.class.model_type_name
|
@@ -34,6 +44,12 @@ module Watirmark
|
|
34
44
|
@uuid ||= (Watirmark::Configuration.instance.uuid || UUID.new.generate(:compact)[0..9]).to_s
|
35
45
|
end
|
36
46
|
|
47
|
+
def hash_id(size = nil, type = :hex)
|
48
|
+
size = size || Watirmark::Configuration.instance.hash_id_length || 8
|
49
|
+
seed = Watirmark::Configuration.instance.hash_id_seed || "Watirmark Default Seed"
|
50
|
+
@hash_id ||= generate_hash_id seed, size, type
|
51
|
+
end
|
52
|
+
|
37
53
|
def strip_equals_from_method_name(method)
|
38
54
|
method.to_s.delete('=').to_sym
|
39
55
|
end
|
@@ -49,6 +65,7 @@ module Watirmark
|
|
49
65
|
@children << model
|
50
66
|
create_child_methods
|
51
67
|
Watirmark.logger.info "Added Model #{model.inspect} to #{model_name || model_class_name}"
|
68
|
+
return self
|
52
69
|
end
|
53
70
|
|
54
71
|
|
@@ -102,8 +119,7 @@ module Watirmark
|
|
102
119
|
end
|
103
120
|
|
104
121
|
def remove_empty_entries hash
|
105
|
-
hash.
|
106
|
-
hash.delete_if {|k| k =~ /^\s+$/}
|
122
|
+
hash.delete_if {|k| k.nil? || k == ':' || k =~ /^\s+$/ || k.empty?}
|
107
123
|
end
|
108
124
|
|
109
125
|
def to_h
|
@@ -124,6 +140,12 @@ module Watirmark
|
|
124
140
|
h
|
125
141
|
end
|
126
142
|
|
143
|
+
def unique_instance_name
|
144
|
+
class_name = self.class.name[/([^\:]+)Model$/i,1]
|
145
|
+
model_name_exists = model_name.nil? ? false : (not model_name.empty?)
|
146
|
+
unique_name = model_name_exists ? model_name : class_name.downcase
|
147
|
+
unique_name_with_uuid = unique_name + "_" + uuid
|
148
|
+
end
|
127
149
|
|
128
150
|
private
|
129
151
|
|
@@ -163,6 +185,17 @@ module Watirmark
|
|
163
185
|
model.model_class_name.to_s.sub(/Model$/, '').underscore
|
164
186
|
end
|
165
187
|
|
188
|
+
def generate_hash_id(seed, size=8, type = :hex)
|
189
|
+
seed_int = seed.scan(/./).inject(1) { |product, chr| product * chr.ord }
|
190
|
+
prng = Random.new(seed_int)
|
191
|
+
if type == :alpha
|
192
|
+
o = ('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a
|
193
|
+
else #:hex
|
194
|
+
o = ('a'..'f').to_a + (0..9).to_a
|
195
|
+
end
|
196
|
+
(0...size.to_i).map { o.sample(random: prng) }.join
|
197
|
+
end
|
198
|
+
|
166
199
|
end
|
167
200
|
end
|
168
201
|
end
|
data/lib/watirmark/page/page.rb
CHANGED
@@ -35,6 +35,7 @@ module Watirmark
|
|
35
35
|
keywords = self.class.keyword_metadata || {}
|
36
36
|
keywords.each_key do |key|
|
37
37
|
keyed_element = KeyedElement.new(self, keywords[key])
|
38
|
+
next if !@keyed_elements.empty? and @keyed_elements.any? {|k| k.keyword.eql? keyed_element.keyword }
|
38
39
|
@keyed_elements << keyed_element
|
39
40
|
meta_def key do |*args|
|
40
41
|
keyed_element.get *args
|
@@ -7,7 +7,7 @@ module Watirmark
|
|
7
7
|
:process_page_active_page_method,
|
8
8
|
:process_page_submit_method
|
9
9
|
|
10
|
-
def process_page(name
|
10
|
+
def process_page(name)
|
11
11
|
@current_process_page = find_or_create_process_page(name)
|
12
12
|
yield
|
13
13
|
@current_process_page = @current_process_page.parent
|
@@ -33,7 +33,7 @@ module Watirmark
|
|
33
33
|
@process_page_active_page_method = proc
|
34
34
|
end
|
35
35
|
|
36
|
-
|
36
|
+
private
|
37
37
|
|
38
38
|
def add_superclass_process_pages_to_subclass(klass)
|
39
39
|
klass.process_pages = (@process_pages ? @process_pages.dup : klass.process_pages = [])
|
@@ -73,7 +73,6 @@ module Watirmark
|
|
73
73
|
end
|
74
74
|
|
75
75
|
|
76
|
-
|
77
76
|
module PageDefinition
|
78
77
|
include ProcessPageDefinition
|
79
78
|
attr_accessor :kwds, :perms, :kwd_metadata
|
@@ -102,6 +101,7 @@ module Watirmark
|
|
102
101
|
def private_keyword(name, map=nil, &block)
|
103
102
|
create_new_keyword(name, map, &block)
|
104
103
|
end
|
104
|
+
|
105
105
|
alias :navigation_keyword :private_keyword
|
106
106
|
|
107
107
|
# Create an alias to an existing keyword
|
@@ -119,14 +119,16 @@ module Watirmark
|
|
119
119
|
end
|
120
120
|
|
121
121
|
def browser_exists?
|
122
|
-
|
122
|
+
!!@@browser
|
123
123
|
end
|
124
124
|
|
125
125
|
def keywords
|
126
|
+
@kwds ||= Hash.new { |h, k| h[k] = Array.new }
|
126
127
|
@kwds.values.flatten.uniq.sort_by { |key| key.to_s }
|
127
128
|
end
|
128
129
|
|
129
130
|
def native_keywords
|
131
|
+
@kwds ||= Hash.new { |h, k| h[k] = Array.new }
|
130
132
|
@kwds[self.to_s].sort_by { |key| key.to_s }
|
131
133
|
end
|
132
134
|
|
@@ -135,7 +137,7 @@ module Watirmark
|
|
135
137
|
@kwd_metadata.values.inject(:merge)
|
136
138
|
end
|
137
139
|
|
138
|
-
|
140
|
+
private
|
139
141
|
def nested_hash
|
140
142
|
Hash.new { |h, k| h[k] = Hash.new { |h, k| h[k]=Hash.new } }
|
141
143
|
end
|
data/lib/watirmark/profile.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'ruby-prof'
|
2
2
|
|
3
3
|
class Profiler
|
4
|
-
def self.profile(options={}
|
4
|
+
def self.profile(options={})
|
5
5
|
RubyProf.start
|
6
6
|
beginning = Time.now
|
7
7
|
puts '-----------------------'
|
8
8
|
puts options[:name]
|
9
9
|
puts '-----------------------'
|
10
|
-
|
10
|
+
yield
|
11
11
|
result = RubyProf.stop
|
12
12
|
result.eliminate_methods!([/IO/, /Net::/, /Global/])
|
13
13
|
printer = RubyProf::FlatPrinter.new(result)
|
@@ -2,16 +2,18 @@ module SmokeTest
|
|
2
2
|
|
3
3
|
class << self
|
4
4
|
def rspec_task(task_name, files, tag=:smoke)
|
5
|
+
Dir.mkdir("reports") unless Dir.exists?("reports")
|
5
6
|
RSpec::Core::RakeTask.new(task_name) do |spec|
|
6
|
-
spec.rspec_opts = "--tag #{tag} -fd -fh --out
|
7
|
+
spec.rspec_opts = "--tag #{tag} --tag ~bug -fd -fh --out reports/#{spec.name}.html --backtrace"
|
7
8
|
spec.pattern = files
|
8
9
|
end
|
9
10
|
end
|
10
11
|
|
11
12
|
def cucumber_task(task_name, files=nil, tag=:smoke)
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
Dir.mkdir("reports") unless Dir.exists?("reports")
|
14
|
+
Cucumber::Rake::Task.new(task_name) do |t|
|
15
|
+
t.cucumber_opts = "--tags @#{tag} --tags ~@bug -r features #{FileList[files]} -b --format html -o reports/report.html --format pretty"
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
data/lib/watirmark/screenshot.rb
CHANGED
@@ -20,9 +20,9 @@ module Watirmark
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def compare_specific_screenshot_size(currents, masters)
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
unless currents.screenshots.md5 == masters.album.md5
|
24
|
+
report_failure(currents.screenshots.filename, masters.album.filename)
|
25
|
+
end
|
26
26
|
end
|
27
27
|
|
28
28
|
def compare_standard_screenshot_sizes(currents, masters)
|
@@ -82,7 +82,6 @@ module Watirmark
|
|
82
82
|
def take_screen_shot(snapshotwidth)
|
83
83
|
update_window_size(snapshotwidth)
|
84
84
|
@filename = "reports/screenshots/#{UUID.new.generate(:compact)}.png"
|
85
|
-
focus_browser
|
86
85
|
Page.browser.screenshot.save @filename
|
87
86
|
end
|
88
87
|
|
@@ -103,10 +102,6 @@ module Watirmark
|
|
103
102
|
def revert_window_size
|
104
103
|
Page.browser.window.resize_to(@screenwidth, @screenheight)
|
105
104
|
end
|
106
|
-
|
107
|
-
def focus_browser
|
108
|
-
Page.browser.element.click
|
109
|
-
end
|
110
105
|
end
|
111
106
|
|
112
107
|
class Master < Current
|
data/lib/watirmark/session.rb
CHANGED
@@ -4,6 +4,7 @@ module Watirmark
|
|
4
4
|
# post failures and then compare on a cucumber step
|
5
5
|
module CucumberPostFailureBuffering
|
6
6
|
@@buffer_post_failure = false
|
7
|
+
@@post_failure = nil
|
7
8
|
|
8
9
|
def post_failure
|
9
10
|
@@post_failure
|
@@ -17,10 +18,10 @@ module Watirmark
|
|
17
18
|
@@buffer_post_failure
|
18
19
|
end
|
19
20
|
|
20
|
-
def catch_post_failures
|
21
|
+
def catch_post_failures
|
21
22
|
@@post_failure = nil
|
22
23
|
@@buffer_post_failure = true
|
23
|
-
|
24
|
+
yield
|
24
25
|
@@buffer_post_failure = false
|
25
26
|
@@post_failure
|
26
27
|
end
|
@@ -47,12 +48,28 @@ module Watirmark
|
|
47
48
|
# set up the global variables, reading from the config file
|
48
49
|
def initialize
|
49
50
|
Watirmark.add_exit_task {
|
50
|
-
closebrowser if config.closebrowseronexit
|
51
|
+
closebrowser if config.closebrowseronexit || config.headless
|
52
|
+
@driver.quit if config.webdriver.to_s.eql? 'sauce'
|
51
53
|
}
|
52
|
-
|
54
|
+
|
55
|
+
if config.webdriver.to_s.eql? 'firefox'
|
56
|
+
config.firefox_profile = default_firefox_profile
|
57
|
+
elsif config.webdriver.to_s.eql? 'firefox_proxy'
|
58
|
+
config.firefox_profile = proxy_firefox_profile(config.proxy_host, config.proxy_port)
|
59
|
+
end
|
53
60
|
end
|
54
61
|
|
55
62
|
def default_firefox_profile
|
63
|
+
file_types = "text/comma-separated-values,text/csv,application/pdf, application/x-msdos-program, application/x-unknown-application-octet-stream,
|
64
|
+
application/vnd.ms-powerpoint, application/excel, application/vnd.ms-publisher, application/x-unknown-message-rfc822, application/vnd.ms-excel,
|
65
|
+
application/msword, application/x-mspublisher, application/x-tar, application/zip, application/x-gzip, application/x-stuffit,
|
66
|
+
application/vnd.ms-works, application/powerpoint, application/rtf, application/postscript, application/x-gtar,
|
67
|
+
video/quicktime, video/x-msvideo, video/mpeg, audio/x-wav, audio/x-midi, audio/x-aiff, text/plain, application/vnd.ms-excel [official],
|
68
|
+
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/msexcel, application/x-msexcel,
|
69
|
+
application/x-excel, application/vnd.ms-excel, application/excel, application/x-ms-excel, application/x-dos_ms_excel,
|
70
|
+
text/csv, text/comma-separated-values, application/octet-stream, application/haansoftxls, application/msexcell,
|
71
|
+
application/softgrid-xls, application/vnd.ms-excel, x-softmaker-pm"
|
72
|
+
|
56
73
|
if Configuration.instance.default_firefox_profile
|
57
74
|
Watirmark.logger.info "Using firefox profile: #{Configuration.instance.default_firefox_profile}"
|
58
75
|
profile = Selenium::WebDriver::Firefox::Profile.from_name Configuration.instance.default_firefox_profile
|
@@ -65,8 +82,32 @@ module Watirmark
|
|
65
82
|
download_directory.gsub!("/", "\\") if Selenium::WebDriver::Platform.windows?
|
66
83
|
profile['browser.download.folderList'] = 2 # custom location
|
67
84
|
profile['browser.download.dir'] = download_directory
|
68
|
-
profile['browser.helperApps.neverAsk.saveToDisk'] =
|
85
|
+
profile['browser.helperApps.neverAsk.saveToDisk'] = file_types
|
86
|
+
profile['security.warn_entering_secure'] = false
|
87
|
+
profile['security.warn_submit_insecure'] = false
|
88
|
+
profile['security.warn_entering_secure.show_once'] = false
|
89
|
+
profile['security.warn_entering_weak'] = false
|
90
|
+
profile['security.warn_entering_weak.show_once'] = false
|
91
|
+
profile['security.warn_leaving_secure'] = false
|
92
|
+
profile['security.warn_leaving_secure.show_once'] = false
|
93
|
+
profile['security.warn_viewing_mixed'] = false
|
94
|
+
profile['security.warn_viewing_mixed.show_once'] = false
|
95
|
+
profile['security.mixed_content.block_active_content'] = false
|
69
96
|
end
|
97
|
+
profile["focusmanager.testmode"] = true
|
98
|
+
profile
|
99
|
+
end
|
100
|
+
|
101
|
+
def proxy_firefox_profile(hostname,port)
|
102
|
+
profile = default_firefox_profile
|
103
|
+
profile['network.proxy.http'] = hostname
|
104
|
+
profile['network.proxy.http_port'] = port.to_i
|
105
|
+
profile['network.proxy.ssl'] = hostname
|
106
|
+
profile['network.proxy.ssl_port'] = port.to_i
|
107
|
+
profile['network.proxy.ftp'] = hostname
|
108
|
+
profile['network.proxy.ftp_port'] = port.to_i
|
109
|
+
profile['network.proxy_type'] = 1
|
110
|
+
profile['network.proxy.type'] = 1
|
70
111
|
profile
|
71
112
|
end
|
72
113
|
|
@@ -76,35 +117,90 @@ module Watirmark
|
|
76
117
|
end
|
77
118
|
|
78
119
|
def openbrowser
|
120
|
+
use_headless_display if config.headless
|
79
121
|
Page.browser = new_watir_browser
|
80
122
|
initialize_page_checkers
|
81
|
-
initialize_screenshots
|
82
123
|
Page.browser
|
83
124
|
end
|
84
125
|
|
85
126
|
def closebrowser
|
86
127
|
begin
|
87
128
|
Page.browser.close
|
88
|
-
rescue Errno::ECONNREFUSED
|
129
|
+
rescue Errno::ECONNREFUSED, Selenium::WebDriver::Error::WebDriverError
|
89
130
|
# browser already closed or unavailable
|
90
131
|
ensure
|
91
132
|
Page.browser = nil
|
92
133
|
end
|
134
|
+
|
135
|
+
if @headless
|
136
|
+
@headless.destroy
|
137
|
+
@headless = nil
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def getos
|
142
|
+
case RUBY_PLATFORM
|
143
|
+
when /cygwin|mswin|mingw|bccwin|wince|emx/
|
144
|
+
return "windows"
|
145
|
+
when /darwin/
|
146
|
+
return "mac"
|
147
|
+
when /linux/
|
148
|
+
return "linux"
|
149
|
+
end
|
93
150
|
end
|
94
151
|
|
95
152
|
private
|
96
153
|
|
154
|
+
def use_headless_display
|
155
|
+
unless RbConfig::CONFIG['host_os'].match('linux')
|
156
|
+
warn "Headless only supported on Linux"
|
157
|
+
return
|
158
|
+
end
|
159
|
+
require 'headless'
|
160
|
+
@headless = Headless.new
|
161
|
+
@headless.start
|
162
|
+
end
|
163
|
+
|
97
164
|
def new_watir_browser
|
98
165
|
config.webdriver ||= :firefox
|
99
166
|
if config.webdriver.to_sym == :firefox
|
100
167
|
Watir::Browser.new config.webdriver.to_sym, :profile => config.firefox_profile
|
168
|
+
elsif config.webdriver.to_sym == :firefox_proxy
|
169
|
+
Watir::Browser.new :firefox, :profile => config.firefox_profile
|
170
|
+
elsif config.webdriver.to_sym == :sauce
|
171
|
+
Watir::Browser.new use_sauce
|
101
172
|
else
|
102
173
|
Watir::Browser.new config.webdriver.to_sym
|
103
174
|
end
|
104
175
|
end
|
105
176
|
|
106
|
-
def
|
107
|
-
|
177
|
+
def use_sauce
|
178
|
+
sb = config.sauce_browser.nil? ? "firefox" : config.sauce_browser.to_s
|
179
|
+
caps = sauce_config(sb)
|
180
|
+
|
181
|
+
@driver = Selenium::WebDriver.for(
|
182
|
+
:remote,
|
183
|
+
:url => "http://#{config.sauce_username}:#{config.sauce_access_key}@ondemand.saucelabs.com:80/wd/hub",
|
184
|
+
:desired_capabilities => caps)
|
185
|
+
@driver
|
186
|
+
end
|
187
|
+
|
188
|
+
def sauce_config(sb)
|
189
|
+
caps = Selenium::WebDriver::Remote::Capabilities.send(sb.to_sym)
|
190
|
+
caps.browser_name = sb
|
191
|
+
case sb
|
192
|
+
when "firefox"
|
193
|
+
caps.version = config.sauce_browser_version.nil? ? 26 : config.sauce_browser_version.to_i
|
194
|
+
when "chrome"
|
195
|
+
caps.version = config.sauce_browser_version.nil? ? 32 : config.sauce_browser_version.to_i
|
196
|
+
when "ie"
|
197
|
+
caps.browser_name = "internet explorer" # caps.browser_name requires ie to be full name
|
198
|
+
caps.version = config.sauce_browser_version.nil? ? 10 : config.sauce_browser_version.to_i
|
199
|
+
end
|
200
|
+
caps.platform = config.sauce_os.nil? ? "Windows 7" : config.sauce_os.to_s
|
201
|
+
caps[:name] = config.sauce_test_title.nil? ? "Testing Selenium 2 with Ruby on Sauce" : config.sauce_test_title
|
202
|
+
puts caps
|
203
|
+
caps
|
108
204
|
end
|
109
205
|
|
110
206
|
def initialize_page_checkers
|
data/lib/watirmark/version.rb
CHANGED
data/lib/watirmark.rb
CHANGED
@@ -1,11 +1,3 @@
|
|
1
|
-
if RUBY_VERSION != "1.9.3"
|
2
|
-
warn "
|
3
|
-
************************************************************************
|
4
|
-
Using unsupported Ruby version #{RUBY_VERSION}. Please upgrade to 1.9.3
|
5
|
-
************************************************************************
|
6
|
-
"
|
7
|
-
end
|
8
|
-
|
9
1
|
require 'watirmark/configuration'
|
10
2
|
Watirmark::Configuration.instance.reload
|
11
3
|
|
@@ -23,4 +15,5 @@ require 'uuid'
|
|
23
15
|
require 'watirmark/model'
|
24
16
|
require 'watirmark/rake/smoketest'
|
25
17
|
require 'active_support/inflector'
|
18
|
+
require 'watirmark/screenshot'
|
26
19
|
FileUtils.rm_rf('reports/screenshots')
|
data/spec/config_spec.rb
CHANGED
@@ -1,16 +1,58 @@
|
|
1
1
|
require_relative 'spec_helper'
|
2
2
|
|
3
|
-
|
3
|
+
describe "text file" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@config = Watirmark::Configuration.instance
|
7
|
+
@config.reset
|
8
|
+
@config.configfile = File.dirname(__FILE__) + '/configurations/config.txt'
|
9
|
+
@config.read_from_file
|
10
|
+
end
|
11
|
+
|
12
|
+
specify 'string' do
|
13
|
+
@config.string.should == "foo"
|
14
|
+
end
|
15
|
+
|
16
|
+
specify 'true_boolean' do
|
17
|
+
@config.true_boolean.should == true
|
18
|
+
end
|
19
|
+
|
20
|
+
specify 'false_boolean' do
|
21
|
+
@config.false_boolean.should == false
|
22
|
+
end
|
23
|
+
|
24
|
+
specify 'symbol' do
|
25
|
+
@config.symbol.should == :foo
|
26
|
+
end
|
27
|
+
|
28
|
+
specify 'integer' do
|
29
|
+
@config.integer.should == 3
|
30
|
+
end
|
31
|
+
|
32
|
+
specify 'float' do
|
33
|
+
@config.float.should == 1.2
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "yaml file" do
|
38
|
+
|
39
|
+
before :all do
|
40
|
+
@config = Watirmark::Configuration.instance
|
41
|
+
@config.reset
|
42
|
+
@config.configfile = File.dirname(__FILE__) + '/configurations/config.yml'
|
43
|
+
@config.read_from_file
|
44
|
+
end
|
45
|
+
|
4
46
|
specify 'string' do
|
5
47
|
@config.string.should == "foo"
|
6
48
|
end
|
7
49
|
|
8
50
|
specify 'true_boolean' do
|
9
|
-
@config.true_boolean.should
|
51
|
+
@config.true_boolean.should == true
|
10
52
|
end
|
11
53
|
|
12
54
|
specify 'false_boolean' do
|
13
|
-
@config.false_boolean.should
|
55
|
+
@config.false_boolean.should == false
|
14
56
|
end
|
15
57
|
|
16
58
|
specify 'symbol' do
|
@@ -26,28 +68,6 @@ shared_examples_for "configuration_file" do
|
|
26
68
|
end
|
27
69
|
end
|
28
70
|
|
29
|
-
describe "text file" do
|
30
|
-
it_behaves_like "configuration_file"
|
31
|
-
|
32
|
-
before :all do
|
33
|
-
@config = Watirmark::Configuration.instance
|
34
|
-
@config.reset
|
35
|
-
@config.configfile = File.dirname(__FILE__) + '/configurations/config.txt'
|
36
|
-
@config.read_from_file
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "yaml file" do
|
41
|
-
it_behaves_like "configuration_file"
|
42
|
-
|
43
|
-
before :all do
|
44
|
-
@config = Watirmark::Configuration.instance
|
45
|
-
@config.reset
|
46
|
-
@config.configfile = File.dirname(__FILE__) + '/configurations/config.yml'
|
47
|
-
@config.read_from_file
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
71
|
describe "configuration" do
|
52
72
|
before :all do
|
53
73
|
@config = Watirmark::Configuration.instance
|
@@ -66,17 +86,5 @@ describe "configuration" do
|
|
66
86
|
specify 'inspect' do
|
67
87
|
@config.inspect.should =~ /^{.+}/
|
68
88
|
end
|
69
|
-
|
70
|
-
specify 'override how a setting is set' do
|
71
|
-
module Watirmark
|
72
|
-
class Configuration
|
73
|
-
def hostname_value(hostname)
|
74
|
-
hostname + '/test'
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
Watirmark::Configuration.instance.hostname = 'www.convio.com'
|
79
|
-
Watirmark::Configuration.instance.hostname.should == 'www.convio.com/test'
|
80
|
-
end
|
81
89
|
|
82
90
|
end
|