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.
Files changed (54) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +1 -1
  3. data/lapis_lazuli.gemspec +10 -8
  4. data/lib/lapis_lazuli/api.rb +1 -1
  5. data/lib/lapis_lazuli/argparse.rb +1 -1
  6. data/lib/lapis_lazuli/browser.rb +37 -61
  7. data/lib/lapis_lazuli/browser/error.rb +89 -62
  8. data/lib/lapis_lazuli/browser/find.rb +1 -2
  9. data/lib/lapis_lazuli/cli.rb +1 -1
  10. data/lib/lapis_lazuli/cucumber.rb +1 -1
  11. data/lib/lapis_lazuli/generators/cucumber.rb +1 -1
  12. data/lib/lapis_lazuli/generators/cucumber/template/README.md +2 -0
  13. data/lib/lapis_lazuli/generators/cucumber/template/config/config.yml +6 -21
  14. data/lib/lapis_lazuli/generators/cucumber/template/config/cucumber.yml +42 -13
  15. data/lib/lapis_lazuli/generators/cucumber/template/config/users.yml +21 -0
  16. data/lib/lapis_lazuli/generators/cucumber/template/features/1_basic.feature +49 -0
  17. data/lib/lapis_lazuli/generators/cucumber/template/features/2_account.feature +38 -0
  18. data/lib/lapis_lazuli/generators/cucumber/template/features/3_todo_list.feature +23 -0
  19. data/lib/lapis_lazuli/generators/cucumber/template/features/helpers/authentication_helper.rb +122 -0
  20. data/lib/lapis_lazuli/generators/cucumber/template/features/helpers/navigation_helper.rb +64 -0
  21. data/lib/lapis_lazuli/generators/cucumber/template/features/helpers/registration_helper.rb +102 -0
  22. data/lib/lapis_lazuli/generators/cucumber/template/features/helpers/user_helper.rb +74 -0
  23. data/lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/account_steps.rb +60 -0
  24. data/lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/basic_steps.rb +70 -0
  25. data/lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/todo_steps.rb +27 -0
  26. data/lib/lapis_lazuli/generators/cucumber/template/features/support/env.rb +3 -2
  27. data/lib/lapis_lazuli/generic/xpath.rb +1 -1
  28. data/lib/lapis_lazuli/options.rb +3 -2
  29. data/lib/lapis_lazuli/placeholders.rb +1 -1
  30. data/lib/lapis_lazuli/proxy.rb +1 -1
  31. data/lib/lapis_lazuli/runtime.rb +1 -1
  32. data/lib/lapis_lazuli/scenario.rb +1 -1
  33. data/lib/lapis_lazuli/storage.rb +1 -1
  34. data/lib/lapis_lazuli/version.rb +2 -2
  35. data/lib/lapis_lazuli/versions.rb +1 -1
  36. data/lib/lapis_lazuli/world/config.rb +348 -334
  37. data/lib/lapis_lazuli/world/hooks.rb +85 -84
  38. data/lib/lapis_lazuli/world/logging.rb +1 -1
  39. data/test/Gemfile +2 -16
  40. data/test/config/config.yml +7 -6
  41. data/test/config/cucumber.yml +6 -8
  42. data/test/features/bindings.feature +1 -1
  43. data/test/features/browser.feature +1 -1
  44. data/test/features/step_definitions/interaction_steps.rb +5 -2
  45. data/test/features/step_definitions/validation_steps.rb +2 -2
  46. data/test/features/support/env.rb +21 -1
  47. data/test/results/latest_results.json +0 -0
  48. metadata +74 -28
  49. data/lib/lapis_lazuli/generators/cucumber/template/features/account.feature +0 -26
  50. data/lib/lapis_lazuli/generators/cucumber/template/features/example.feature +0 -30
  51. data/lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/interaction_steps.rb +0 -165
  52. data/lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/precondition_steps.rb +0 -63
  53. data/lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/validation_steps.rb +0 -67
  54. data/lib/lapis_lazuli/generators/cucumber/template/features/support/functions.rb +0 -68
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5ba7d3bc93d8cc88cf24da242e8ce8d9fac690e1
4
- data.tar.gz: 547f0135054b8d4751a01df27842e9d1d679959e
2
+ SHA256:
3
+ metadata.gz: 1cb9d8e7f2c00b9ac46c3878aa10a7adcc92d844755a3a5d765c8c83fa89bdab
4
+ data.tar.gz: 18c87f3db4b6c4b5e160c25437749f2ce01d182001403d1b5a84bfb0a415da15
5
5
  SHA512:
6
- metadata.gz: d7b214da9b4862efb132d7aa529bb69cd46c7bcc6af194c95d8eff6a2bb0900eaea16206f28a128fa8cc23e71f5040512e22ec91f5bde2d999a199610eec37c1
7
- data.tar.gz: 4ecc7e7c7512f976240242843ae9666c1bcba998ad3afc9b1b591e5c85abbb89c238e609d1ef0a3f5da107c4b91ac8dfee87cd590c12d751a457e966708c705c
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-2017 spriteCloud B.V. and other node-apinator contributors. See [the LICENSE file](LICENSE) for details.
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", "~> 1.6"
35
- spec.add_development_dependency "rake", "~> 12.0"
36
- spec.add_development_dependency "simplecov", "~> 0.12"
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.10"
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.10"
43
- spec.add_dependency "thor", "~> 0.19" # Used in the cucumber project generator
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", "~> 3"
48
+ spec.add_dependency "selenium-webdriver", ">= 2.0", '< 4'
48
49
  spec.add_dependency "watir", "~> 6"
49
- spec.add_dependency "cucumber", "~> 2"
50
+ spec.add_dependency "ffi", "~> 1.11"
51
+ spec.add_dependency "cucumber", ">= 2.0", '< 4.0'
50
52
 
51
53
  end
@@ -2,7 +2,7 @@
2
2
  # LapisLazuli
3
3
  # https://github.com/spriteCloud/lapis-lazuli
4
4
  #
5
- # Copyright (c) 2013-2017 spriteCloud B.V. and other LapisLazuli contributors.
5
+ # Copyright (c) 2013-2019 spriteCloud B.V. and other LapisLazuli contributors.
6
6
  # All rights reserved.
7
7
  #
8
8
 
@@ -2,7 +2,7 @@
2
2
  # LapisLazuli
3
3
  # https://github.com/spriteCloud/lapis-lazuli
4
4
  #
5
- # Copyright (c) 2013-2017 spriteCloud B.V. and other LapisLazuli contributors.
5
+ # Copyright (c) 2013-2019 spriteCloud B.V. and other LapisLazuli contributors.
6
6
  # All rights reserved.
7
7
  #
8
8
 
@@ -2,7 +2,7 @@
2
2
  # LapisLazuli
3
3
  # https://github.com/spriteCloud/lapis-lazuli
4
4
  #
5
- # Copyright (c) 2013-2017 spriteCloud B.V. and other LapisLazuli contributors.
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 { LapisLazuli::Browser::close_all 'exit event trigger' }
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 !world.env_or_config('DEVICE').nil?
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 !world.env_or_config('default_device').nil?
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? Default to firefox
310
+ # No browser? Does the config have a browser?
311
311
  if browser_wanted.nil?
312
- browser_wanted = world.env_or_config('browser', 'firefox')
312
+ browser_wanted = world.env_or_config('browser', nil)
313
313
  end
314
314
 
315
- # Select the correct browser
316
- case browser_wanted.to_s.downcase
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
- case b
345
- when :firefox
346
- # Create a firefox profile if it does not exist yet
347
- if optional_data[:profile].nil?
348
- optional_data[:profile] = Selenium::WebDriver::Firefox::Profile.new
349
- else
350
- # If the profile already exists, we need to create a duplicate, so we don't overwrite any settings.
351
- optional_data[:profile] = optional_data[:profile].dup
352
- end
353
- # Add the user agent to it if it has not been set yet
354
- if optional_data[:profile].instance_variable_get(:@additional_prefs)['general.useragent.override'].nil?
355
- optional_data[:profile]['general.useragent.override'] = device_configuration['user-agent']
356
- else
357
- world.log.debug "User-agent was already set in the :profile."
358
- end
359
- when :chrome
360
- ua_string = "--user-agent=#{device_configuration['user-agent']}"
361
- if optional_data[:switches].nil?
362
- optional_data[:switches] = [ua_string]
363
- elsif !optional_data[:switches].join(',').include? '--user-agent='
364
- optional_data[:switches].push ua_string
365
- else
366
- world.log.debug "User-agent was already set in the :switches."
367
- end
368
- else
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 = [b]
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 { |k, v| remote_settings[k.to_s.downcase] = v }
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 { |k, v| string_hash[k.to_s.downcase] = v }
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
- # 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
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
- 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}")
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 true
35
+ return false
34
36
  end
35
- return false
36
- end
37
37
 
38
38
 
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}"
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
- # If the proxy is supported, use it to retrieve JS errors.
68
- def get_js_errors
69
- return self.browser.execute_script <<-JS
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
- JS
76
- end
75
+ JS
76
+ end
77
77
 
78
78
 
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 <<-JS
83
- try{
84
- return lapis_lazuli.http.statusCode;
85
- } catch(err){
86
- return null;
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
- JS
89
- end
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
- end # module Error
92
- end # module BrowserModule
118
+ end # module Error
119
+ end # module BrowserModule
93
120
  end # module LapisLazuli
@@ -401,8 +401,7 @@ module BrowserModule
401
401
  # Create the XPath query
402
402
  return options, lambda {
403
403
  context.elements(
404
- :xpath,
405
- xpath
404
+ xpath: xpath
406
405
  )
407
406
  }
408
407
  end
@@ -2,7 +2,7 @@
2
2
  # LapisLazuli
3
3
  # https://github.com/spriteCloud/lapis-lazuli
4
4
  #
5
- # Copyright (c) 2013-2017 spriteCloud B.V. and other LapisLazuli contributors.
5
+ # Copyright (c) 2013-2019 spriteCloud B.V. and other LapisLazuli contributors.
6
6
  # All rights reserved.
7
7
  #
8
8
  require 'thor'
@@ -2,7 +2,7 @@
2
2
  # LapisLazuli
3
3
  # https://github.com/spriteCloud/lapis-lazuli
4
4
  #
5
- # Copyright (c) 2013-2017 spriteCloud B.V. and other LapisLazuli contributors.
5
+ # Copyright (c) 2013-2019 spriteCloud B.V. and other LapisLazuli contributors.
6
6
  # All rights reserved.
7
7
  #
8
8
 
@@ -2,7 +2,7 @@
2
2
  # LapisLazuli
3
3
  # https://github.com/spriteCloud/lapis-lazuli
4
4
  #
5
- # Copyright (c) 2013-2017 spriteCloud B.V. and other LapisLazuli contributors.
5
+ # Copyright (c) 2013-2019 spriteCloud B.V. and other LapisLazuli contributors.
6
6
  # All rights reserved.
7
7
  #
8
8
 
@@ -4,6 +4,8 @@ Author: "<%= config[:user] %>" <<%= config[:email] %>>
4
4
 
5
5
  # Setup
6
6
 
7
+ See: www.testautomation.info/index.php?title=Installing_ruby_with_cucumber
8
+
7
9
  ## General
8
10
 
9
11
  - Make sure you have ruby 2.0 or later installed.