lapis_lazuli 2.0.1 → 3.0.0
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.
- checksums.yaml +5 -5
- data/README.md +1 -1
- data/lapis_lazuli.gemspec +10 -8
- data/lib/lapis_lazuli/api.rb +1 -1
- data/lib/lapis_lazuli/argparse.rb +1 -1
- data/lib/lapis_lazuli/browser.rb +37 -61
- data/lib/lapis_lazuli/browser/error.rb +89 -62
- data/lib/lapis_lazuli/browser/find.rb +1 -2
- data/lib/lapis_lazuli/cli.rb +1 -1
- data/lib/lapis_lazuli/cucumber.rb +1 -1
- data/lib/lapis_lazuli/generators/cucumber.rb +1 -1
- data/lib/lapis_lazuli/generators/cucumber/template/README.md +2 -0
- data/lib/lapis_lazuli/generators/cucumber/template/config/config.yml +6 -21
- data/lib/lapis_lazuli/generators/cucumber/template/config/cucumber.yml +42 -13
- data/lib/lapis_lazuli/generators/cucumber/template/config/users.yml +21 -0
- data/lib/lapis_lazuli/generators/cucumber/template/features/1_basic.feature +49 -0
- data/lib/lapis_lazuli/generators/cucumber/template/features/2_account.feature +38 -0
- data/lib/lapis_lazuli/generators/cucumber/template/features/3_todo_list.feature +23 -0
- data/lib/lapis_lazuli/generators/cucumber/template/features/helpers/authentication_helper.rb +122 -0
- data/lib/lapis_lazuli/generators/cucumber/template/features/helpers/navigation_helper.rb +64 -0
- data/lib/lapis_lazuli/generators/cucumber/template/features/helpers/registration_helper.rb +102 -0
- data/lib/lapis_lazuli/generators/cucumber/template/features/helpers/user_helper.rb +74 -0
- data/lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/account_steps.rb +60 -0
- data/lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/basic_steps.rb +70 -0
- data/lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/todo_steps.rb +27 -0
- data/lib/lapis_lazuli/generators/cucumber/template/features/support/env.rb +3 -2
- data/lib/lapis_lazuli/generic/xpath.rb +1 -1
- data/lib/lapis_lazuli/options.rb +3 -2
- data/lib/lapis_lazuli/placeholders.rb +1 -1
- data/lib/lapis_lazuli/proxy.rb +1 -1
- data/lib/lapis_lazuli/runtime.rb +1 -1
- data/lib/lapis_lazuli/scenario.rb +1 -1
- data/lib/lapis_lazuli/storage.rb +1 -1
- data/lib/lapis_lazuli/version.rb +2 -2
- data/lib/lapis_lazuli/versions.rb +1 -1
- data/lib/lapis_lazuli/world/config.rb +348 -334
- data/lib/lapis_lazuli/world/hooks.rb +85 -84
- data/lib/lapis_lazuli/world/logging.rb +1 -1
- data/test/Gemfile +2 -16
- data/test/config/config.yml +7 -6
- data/test/config/cucumber.yml +6 -8
- data/test/features/bindings.feature +1 -1
- data/test/features/browser.feature +1 -1
- data/test/features/step_definitions/interaction_steps.rb +5 -2
- data/test/features/step_definitions/validation_steps.rb +2 -2
- data/test/features/support/env.rb +21 -1
- data/test/results/latest_results.json +0 -0
- metadata +74 -28
- data/lib/lapis_lazuli/generators/cucumber/template/features/account.feature +0 -26
- data/lib/lapis_lazuli/generators/cucumber/template/features/example.feature +0 -30
- data/lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/interaction_steps.rb +0 -165
- data/lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/precondition_steps.rb +0 -63
- data/lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/validation_steps.rb +0 -67
- data/lib/lapis_lazuli/generators/cucumber/template/features/support/functions.rb +0 -68
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1cb9d8e7f2c00b9ac46c3878aa10a7adcc92d844755a3a5d765c8c83fa89bdab
|
4
|
+
data.tar.gz: 18c87f3db4b6c4b5e160c25437749f2ce01d182001403d1b5a84bfb0a415da15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba5f638f5687acc0738764630fdefd801d81fbefe9f9ef74ba418b5f515cb9d2316d4925c81edd29dc06e9979f5209ebf9b1e19600d3c0102ca8e0d41091d142
|
7
|
+
data.tar.gz: f8570e62e1984cdfa223c6ec3439cc8690c80305985b25afe5e7718ae1c15dc1dba32b5fec4a0ff92d6c5c9b6ec4f99b51baab96ec6dc455b3e5d31fd9eb1050
|
data/README.md
CHANGED
@@ -77,4 +77,4 @@ further documentation.
|
|
77
77
|
Please see [the Wiki page on contributing](https://github.com/spriteCloud/lapis-lazuli/wiki/Contributing)
|
78
78
|
|
79
79
|
## License
|
80
|
-
Copyright (c) 2013-
|
80
|
+
Copyright (c) 2013-2019 spriteCloud B.V. and other node-apinator contributors. See [the LICENSE file](LICENSE) for details.
|
data/lapis_lazuli.gemspec
CHANGED
@@ -31,21 +31,23 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
32
32
|
spec.require_paths = ["lib"]
|
33
33
|
|
34
|
-
spec.add_development_dependency "bundler", "~>
|
35
|
-
spec.add_development_dependency "rake", "~> 12.
|
36
|
-
spec.add_development_dependency "simplecov", "~> 0.
|
34
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
35
|
+
spec.add_development_dependency "rake", "~> 12.3"
|
36
|
+
spec.add_development_dependency "simplecov", "~> 0.17"
|
37
37
|
|
38
|
-
spec.add_dependency "faraday_middleware", "~> 0.
|
38
|
+
spec.add_dependency "faraday_middleware", "~> 0.13"
|
39
39
|
spec.add_dependency "faraday_json", "~> 0.1"
|
40
40
|
spec.add_dependency "multi_xml", "~> 0.6"
|
41
41
|
spec.add_dependency "teelogger", "~> 0.5"
|
42
|
-
spec.add_dependency "minitest", "~> 5.
|
43
|
-
spec.add_dependency "thor", "~> 0.
|
42
|
+
spec.add_dependency "minitest", "~> 5.11"
|
43
|
+
spec.add_dependency "thor", "~> 0.20" # Used in the cucumber project generator
|
44
44
|
spec.add_dependency "facets", "~> 3.1" # Used in the cucumber project generator
|
45
|
+
spec.add_dependency "deep_merge", "~> 1.2"
|
45
46
|
|
46
47
|
# webdriver specifics
|
47
|
-
spec.add_dependency "selenium-webdriver", "
|
48
|
+
spec.add_dependency "selenium-webdriver", ">= 2.0", '< 4'
|
48
49
|
spec.add_dependency "watir", "~> 6"
|
49
|
-
spec.add_dependency "
|
50
|
+
spec.add_dependency "ffi", "~> 1.11"
|
51
|
+
spec.add_dependency "cucumber", ">= 2.0", '< 4.0'
|
50
52
|
|
51
53
|
end
|
data/lib/lapis_lazuli/api.rb
CHANGED
data/lib/lapis_lazuli/browser.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# LapisLazuli
|
3
3
|
# https://github.com/spriteCloud/lapis-lazuli
|
4
4
|
#
|
5
|
-
# Copyright (c) 2013-
|
5
|
+
# Copyright (c) 2013-2019 spriteCloud B.V. and other LapisLazuli contributors.
|
6
6
|
# All rights reserved.
|
7
7
|
#
|
8
8
|
|
@@ -124,7 +124,7 @@ module LapisLazuli
|
|
124
124
|
# Add this browser to the list of all browsers
|
125
125
|
LapisLazuli::Browser.add_browser(self)
|
126
126
|
# Making sure all browsers are gracefully closed when the exit event is triggered.
|
127
|
-
at_exit {
|
127
|
+
at_exit {LapisLazuli::Browser::close_all 'exit event trigger'}
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
@@ -250,10 +250,10 @@ module LapisLazuli
|
|
250
250
|
if @@cached_browser_options.has_key?(:device)
|
251
251
|
optional_data[:device] = @@cached_browser_options[:device]
|
252
252
|
# Check if the ENV['DEVICE'] variable is set
|
253
|
-
elsif
|
253
|
+
elsif world.env_or_config('DEVICE', false)
|
254
254
|
optional_data[:device] = world.env_or_config('DEVICE')
|
255
255
|
# Else grab the default set device
|
256
|
-
elsif
|
256
|
+
elsif world.env_or_config('default_device', false)
|
257
257
|
optional_data[:device] = world.env_or_config('default_device')
|
258
258
|
else
|
259
259
|
warn 'No default device, nor a selected device was set. Browser default settings will be loaded. More info: http://testautomation.info/Lapis_Lazuli:Device_Simulation'
|
@@ -307,70 +307,46 @@ module LapisLazuli
|
|
307
307
|
raise LoadError, "#{err}: you need to add 'watir' to your Gemfile before using the browser."
|
308
308
|
end
|
309
309
|
|
310
|
-
# No browser? Does the config have a browser?
|
310
|
+
# No browser? Does the config have a browser?
|
311
311
|
if browser_wanted.nil?
|
312
|
-
browser_wanted = world.env_or_config('browser',
|
312
|
+
browser_wanted = world.env_or_config('browser', nil)
|
313
313
|
end
|
314
314
|
|
315
|
-
|
316
|
-
|
317
|
-
when 'chrome'
|
318
|
-
b = :chrome
|
319
|
-
when 'edge'
|
320
|
-
b = :edge
|
321
|
-
when 'safari'
|
322
|
-
b = :safari
|
323
|
-
when 'ie'
|
324
|
-
require 'rbconfig'
|
325
|
-
if (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
|
326
|
-
b = :ie
|
327
|
-
else
|
328
|
-
world.error("You can't run IE tests on non-Windows machine")
|
329
|
-
end
|
330
|
-
when 'ios'
|
331
|
-
if RUBY_PLATFORM.downcase.include?("darwin")
|
332
|
-
b = :iphone
|
333
|
-
else
|
334
|
-
world.error("You can't run IOS tests on non-mac machine")
|
335
|
-
end
|
336
|
-
when 'remote'
|
337
|
-
b = :remote
|
338
|
-
else
|
339
|
-
b = :firefox
|
340
|
-
end
|
315
|
+
b = browser_wanted
|
316
|
+
b = b.to_sym unless b.nil?
|
341
317
|
|
342
318
|
# Overwrite user-agent if a device simulation is set and it contains a user-agent
|
343
319
|
if !device_configuration.nil? and !device_configuration['user-agent'].nil?
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
warn "#{device} user agent cannot be set for #{b.to_s}. Only Chrome & Firefox are supported."
|
320
|
+
# Firefox user-agent settings
|
321
|
+
# Create a firefox profile if it does not exist yet
|
322
|
+
if optional_data[:profile].nil?
|
323
|
+
optional_data[:profile] = Selenium::WebDriver::Firefox::Profile.new
|
324
|
+
else
|
325
|
+
# If the profile already exists, we need to create a duplicate, so we don't overwrite any settings.
|
326
|
+
optional_data[:profile] = optional_data[:profile].dup
|
327
|
+
end
|
328
|
+
# Add the user agent to it if it has not been set yet
|
329
|
+
if optional_data[:profile].instance_variable_get(:@additional_prefs)['general.useragent.override'].nil?
|
330
|
+
optional_data[:profile]['general.useragent.override'] = device_configuration['user-agent']
|
331
|
+
else
|
332
|
+
world.log.debug "User-agent was already set in the :profile."
|
333
|
+
end
|
334
|
+
# Chrome user-agent settings
|
335
|
+
ua_string = "--user-agent=#{device_configuration['user-agent']}"
|
336
|
+
if optional_data[:switches].nil?
|
337
|
+
optional_data[:switches] = [ua_string]
|
338
|
+
elsif !optional_data[:switches].join(',').include? '--user-agent='
|
339
|
+
optional_data[:switches].push ua_string
|
340
|
+
else
|
341
|
+
world.log.debug "User-agent was already set in the :switches."
|
342
|
+
end
|
343
|
+
if b != :firefox and b != :chrome
|
344
|
+
warn "#{device} user agent cannot be set for #{b.to_s}. Only Chrome & Firefox are supported."
|
370
345
|
end
|
371
346
|
end
|
372
347
|
|
373
|
-
args = [
|
348
|
+
args = []
|
349
|
+
args = [b] unless b.nil?
|
374
350
|
@browser_name = b.to_s
|
375
351
|
if b == :remote
|
376
352
|
# Get the config
|
@@ -380,12 +356,12 @@ module LapisLazuli
|
|
380
356
|
remote_settings = {}
|
381
357
|
|
382
358
|
# Add the config to the settings using downcase string keys
|
383
|
-
remote_config.each {
|
359
|
+
remote_config.each {|k, v| remote_settings[k.to_s.downcase] = v}
|
384
360
|
|
385
361
|
if optional_data.is_a? Hash
|
386
362
|
# Convert the optional data to downcase string keys
|
387
363
|
string_hash = Hash.new
|
388
|
-
optional_data.each {
|
364
|
+
optional_data.each {|k, v| string_hash[k.to_s.downcase] = v}
|
389
365
|
|
390
366
|
# Merge them with the settings
|
391
367
|
remote_settings.merge! string_hash
|
@@ -7,87 +7,114 @@
|
|
7
7
|
#
|
8
8
|
|
9
9
|
module LapisLazuli
|
10
|
-
module BrowserModule
|
10
|
+
module BrowserModule
|
11
11
|
|
12
|
-
##
|
13
|
-
# Module with error handling related functionality (World)
|
14
|
-
module Error
|
15
12
|
##
|
16
|
-
#
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
errors
|
23
|
-
|
13
|
+
# Module with error handling related functionality (World)
|
14
|
+
module Error
|
15
|
+
##
|
16
|
+
# Does this page have errors?
|
17
|
+
# Checks the pagetext for error_strings that are specified in the config
|
18
|
+
def has_error?
|
19
|
+
errors = self.get_html_errors
|
20
|
+
js_errors = self.get_js_errors
|
21
|
+
if not js_errors.nil?
|
22
|
+
errors += js_errors
|
23
|
+
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
if errors.length > 0 or self.get_http_status.to_i > 299
|
26
|
+
errors.each do |error|
|
27
|
+
if error.is_a? Hash
|
28
|
+
world.log.debug("#{error["message"]} #{error["url"]} #{error["line"]} #{error["column"]}\n#{error["stack"]}")
|
29
|
+
else
|
30
|
+
world.log.debug("#{error}")
|
31
|
+
end
|
31
32
|
end
|
33
|
+
return true
|
32
34
|
end
|
33
|
-
return
|
35
|
+
return false
|
34
36
|
end
|
35
|
-
return false
|
36
|
-
end
|
37
37
|
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
39
|
+
##
|
40
|
+
# Retrieve errors from HTML elements, using the error_strings config
|
41
|
+
# variable
|
42
|
+
def get_html_errors
|
43
|
+
result = []
|
44
|
+
# Need some error strings
|
45
|
+
if world.has_env_or_config?("error_strings")
|
46
|
+
begin
|
47
|
+
# Get the HTML of the page
|
48
|
+
page_text = @browser.html
|
49
|
+
# Try to find all errors
|
50
|
+
world.env_or_config("error_strings").each {|error|
|
51
|
+
if page_text.include? error
|
52
|
+
# Add to the result list
|
53
|
+
result.push error
|
54
|
+
end
|
55
|
+
}
|
56
|
+
rescue RuntimeError => err
|
57
|
+
# An error?
|
58
|
+
world.log.debug "Cannot read the html for page #{@browser.url}: #{err}"
|
59
|
+
end
|
59
60
|
end
|
61
|
+
# By default we don't have errors
|
62
|
+
return result
|
60
63
|
end
|
61
|
-
# By default we don't have errors
|
62
|
-
return result
|
63
|
-
end
|
64
64
|
|
65
65
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
##
|
67
|
+
# If the proxy is supported, use it to retrieve JS errors.
|
68
|
+
def get_js_errors
|
69
|
+
return self.browser.execute_script <<-JS
|
70
70
|
try {
|
71
71
|
return lapis_lazuli.errors;
|
72
72
|
} catch(err){
|
73
73
|
return null;
|
74
74
|
}
|
75
|
-
|
76
|
-
|
75
|
+
JS
|
76
|
+
end
|
77
77
|
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
79
|
+
##
|
80
|
+
# If the proxy is supported, use it get the HTTP status code.
|
81
|
+
def get_http_status
|
82
|
+
return self.browser.execute_script('
|
83
|
+
function getReq() {
|
84
|
+
var req = false;
|
85
|
+
if(window.XMLHttpRequest) {
|
86
|
+
try {
|
87
|
+
req = new XMLHttpRequest();
|
88
|
+
} catch(e) {
|
89
|
+
req = false;
|
87
90
|
}
|
88
|
-
|
89
|
-
|
91
|
+
} else if(window.ActiveXObject) {
|
92
|
+
try {
|
93
|
+
req = new ActiveXObject("Microsoft.XMLHTTP");
|
94
|
+
} catch(e) {
|
95
|
+
req = false;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
if (! req) {
|
99
|
+
alert("Your browser does not support XMLHttpRequest.");
|
100
|
+
}
|
101
|
+
return req;
|
102
|
+
}
|
103
|
+
|
104
|
+
var req = getReq();
|
105
|
+
|
106
|
+
try {
|
107
|
+
req.open("GET", "' + self.browser.url + '", false);
|
108
|
+
req.send("");
|
109
|
+
} catch (e) {
|
110
|
+
success = false;
|
111
|
+
error_msg = "Error: " + e;
|
112
|
+
}
|
113
|
+
|
114
|
+
return req.status;
|
115
|
+
JS')
|
116
|
+
end
|
90
117
|
|
91
|
-
|
92
|
-
end # module BrowserModule
|
118
|
+
end # module Error
|
119
|
+
end # module BrowserModule
|
93
120
|
end # module LapisLazuli
|
data/lib/lapis_lazuli/cli.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# LapisLazuli
|
3
3
|
# https://github.com/spriteCloud/lapis-lazuli
|
4
4
|
#
|
5
|
-
# Copyright (c) 2013-
|
5
|
+
# Copyright (c) 2013-2019 spriteCloud B.V. and other LapisLazuli contributors.
|
6
6
|
# All rights reserved.
|
7
7
|
#
|
8
8
|
require 'thor'
|