lapis_lazuli 2.0.1 → 2.1.3

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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/lapis_lazuli.gemspec +3 -2
  3. data/lib/lapis_lazuli/browser.rb +36 -60
  4. data/lib/lapis_lazuli/browser/error.rb +89 -62
  5. data/lib/lapis_lazuli/generators/cucumber/template/README.md +2 -0
  6. data/lib/lapis_lazuli/generators/cucumber/template/config/config.yml +5 -20
  7. data/lib/lapis_lazuli/generators/cucumber/template/config/cucumber.yml +42 -13
  8. data/lib/lapis_lazuli/generators/cucumber/template/config/users.yml +21 -0
  9. data/lib/lapis_lazuli/generators/cucumber/template/features/1_basic.feature +42 -0
  10. data/lib/lapis_lazuli/generators/cucumber/template/features/2_account.feature +38 -0
  11. data/lib/lapis_lazuli/generators/cucumber/template/features/3_todo_list.feature +23 -0
  12. data/lib/lapis_lazuli/generators/cucumber/template/features/helpers/authentication_helper.rb +122 -0
  13. data/lib/lapis_lazuli/generators/cucumber/template/features/helpers/navigation_helper.rb +64 -0
  14. data/lib/lapis_lazuli/generators/cucumber/template/features/helpers/registration_helper.rb +93 -0
  15. data/lib/lapis_lazuli/generators/cucumber/template/features/helpers/user_helper.rb +74 -0
  16. data/lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/account_steps.rb +60 -0
  17. data/lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/basic_steps.rb +65 -0
  18. data/lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/todo_steps.rb +27 -0
  19. data/lib/lapis_lazuli/generators/cucumber/template/features/support/env.rb +3 -2
  20. data/lib/lapis_lazuli/options.rb +2 -1
  21. data/lib/lapis_lazuli/version.rb +1 -1
  22. data/lib/lapis_lazuli/world/config.rb +348 -334
  23. data/lib/lapis_lazuli/world/hooks.rb +85 -84
  24. data/lib/lapis_lazuli/world/logging.rb +1 -1
  25. data/test/config/config.yml +7 -6
  26. data/test/config/cucumber.yml +6 -8
  27. data/test/features/bindings.feature +1 -1
  28. data/test/features/browser.feature +1 -1
  29. data/test/features/step_definitions/interaction_steps.rb +5 -2
  30. data/test/features/step_definitions/validation_steps.rb +2 -2
  31. data/test/features/support/env.rb +22 -1
  32. data/test/results/latest_results.json +0 -0
  33. metadata +49 -16
  34. data/lib/lapis_lazuli/generators/cucumber/template/features/account.feature +0 -26
  35. data/lib/lapis_lazuli/generators/cucumber/template/features/example.feature +0 -30
  36. data/lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/interaction_steps.rb +0 -165
  37. data/lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/precondition_steps.rb +0 -63
  38. data/lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/validation_steps.rb +0 -67
  39. data/lib/lapis_lazuli/generators/cucumber/template/features/support/functions.rb +0 -68
@@ -7,112 +7,113 @@
7
7
  #
8
8
 
9
9
  module LapisLazuli
10
- module WorldModule
11
- ##
12
- # Module with cucumber hooks
13
- #
14
- # The module is special in that it does not include other modules. Instead it
15
- # always tests whether World responds to a function before calling it.
16
- module Hooks
10
+ module WorldModule
17
11
  ##
18
- # Add hooks to one of the four queues :before, :after, :start or :end.
19
- HOOK_QUEUES = [
20
- :before,
21
- :after,
22
- :start,
12
+ # Module with cucumber hooks
13
+ #
14
+ # The module is special in that it does not include other modules. Instead it
15
+ # always tests whether World responds to a function before calling it.
16
+ module Hooks
17
+ ##
18
+ # Add hooks to one of the four queues :before, :after, :start or :end.
19
+ HOOK_QUEUES = [
20
+ :before,
21
+ :after,
22
+ :start,
23
23
  # :end # FIXME hard to implement. See issue #13
24
- ]
25
- def self.add_hook(queue, hook)
26
- if not HOOK_QUEUES.include?(queue)
27
- raise "Invalid hook queue #{queue}"
28
- end
24
+ ]
29
25
 
30
- @@hooks ||= {}
31
- @@hooks[queue] ||= []
32
- @@hooks[queue] << hook
33
- end
26
+ def self.add_hook(queue, hook)
27
+ if not HOOK_QUEUES.include?(queue)
28
+ raise "Invalid hook queue #{queue}"
29
+ end
34
30
 
35
- ##
36
- # Hook invoked in BeforeScenario
37
- def before_scenario_hook(cuke_scenario)
38
- # Update the scenario informaton
39
- if respond_to? :scenario
40
- scenario.running = true
41
- scenario.update(cuke_scenario)
31
+ @@hooks ||= {}
32
+ @@hooks[queue] ||= []
33
+ @@hooks[queue] << hook
42
34
  end
43
35
 
44
- # Show the name
45
- if respond_to? :log
46
- log.info("Starting Scenario: #{scenario.id}")
47
- end
36
+ ##
37
+ # Hook invoked in BeforeScenario
38
+ def before_scenario_hook(cuke_scenario)
39
+ # Update the scenario informaton
40
+ if respond_to? :scenario
41
+ scenario.running = true
42
+ scenario.update(cuke_scenario)
43
+ end
48
44
 
49
- # Run 'start' queue once.
50
- @@started ||= false
51
- if not @@started
52
- @@started = true
53
- run_queue(:start, cuke_scenario)
54
- end
45
+ # Show the name
46
+ if respond_to? :log
47
+ log.info("Starting Scenario: #{scenario.id}")
48
+ end
55
49
 
56
- # Run 'before' queue
57
- run_queue(:before, cuke_scenario)
58
- end
50
+ # Run 'start' queue once.
51
+ @@started ||= false
52
+ if not @@started
53
+ @@started = true
54
+ run_queue(:start, cuke_scenario)
55
+ end
59
56
 
60
- ##
61
- # Hook invoked in AfterScenario
62
- def after_scenario_hook(cuke_scenario)
63
- # Run 'after' queue
64
- run_queue(:after, cuke_scenario)
57
+ # Run 'before' queue
58
+ run_queue(:before, cuke_scenario)
59
+ end
65
60
 
66
- # Run 'end' queue
67
- # FIXME hard to implement; see issue #13
61
+ ##
62
+ # Hook invoked in AfterScenario
63
+ def after_scenario_hook(cuke_scenario)
64
+ # Run 'after' queue
65
+ run_queue(:after, cuke_scenario)
68
66
 
69
- # The current scenario has finished
70
- if respond_to? :scenario
71
- scenario.running = false
72
- end
67
+ # Run 'end' queue
68
+ # FIXME hard to implement; see issue #13
73
69
 
74
- # Sleep if needed
75
- if respond_to? :config and has_env_or_config?("step_pause_time")
76
- sleep env_or_config("step_pause_time")
77
- end
70
+ # The current scenario has finished
71
+ if respond_to? :scenario
72
+ scenario.running = false
73
+ end
74
+
75
+ # Sleep if needed
76
+ if respond_to? :config and has_env_or_config?("step_pause_time")
77
+ sleep env_or_config("step_pause_time")
78
+ end
78
79
 
79
- # Did we fail?
80
- if respond_to? :scenario and respond_to? :has_browser? and respond_to? :browser and respond_to? :config
81
- if has_browser? and (cuke_scenario.failed? or (scenario.check_browser_errors and browser.has_error?))
82
- # Take a screenshot if needed
83
- if has_env_or_config?('screenshot_on_failure')
84
- if env_or_config("screenshot_scheme") == "new"
85
- # Take screenshots on all active browsers
86
- LapisLazuli::Browser.browsers.each do |b|
87
- fileloc = b.take_screenshot()
80
+ # Did we fail?
81
+ if respond_to? :scenario and respond_to? :has_browser? and respond_to? :browser and respond_to? :config
82
+ if has_browser? and (cuke_scenario.failed? or (scenario.check_browser_errors and browser.has_error?))
83
+ # Take a screenshot if needed
84
+ if has_env_or_config?('screenshot_on_failure')
85
+ if env_or_config("screenshot_scheme") == "new"
86
+ # Take screenshots on all active browsers
87
+ LapisLazuli::Browser.browsers.each do |b|
88
+ fileloc = b.take_screenshot()
89
+ end
90
+ else
91
+ browser.take_screenshot()
88
92
  end
89
- else
90
- browser.take_screenshot()
91
93
  end
92
94
  end
93
95
  end
94
- end
95
96
 
96
- # Close browser if needed
97
- if respond_to? :has_browser? and respond_to? :browser
98
- if has_browser?
99
- browser.close_after_scenario(cuke_scenario)
97
+ # Close browser if needed
98
+ if respond_to? :has_browser? and respond_to? :browser
99
+ if has_browser?
100
+ browser.close_after_scenario(cuke_scenario)
101
+ end
100
102
  end
101
103
  end
102
- end
103
104
 
104
- private
105
- def run_queue(queue, cuke_scenario)
106
- @@hooks ||= {}
105
+ private
106
+ def run_queue(queue, cuke_scenario)
107
+ @@hooks ||= {}
107
108
 
108
- if @@hooks[queue].nil?
109
- return
110
- end
109
+ if @@hooks[queue].nil?
110
+ return
111
+ end
111
112
 
112
- @@hooks[queue].each do |hook|
113
- self.instance_exec(cuke_scenario, &hook)
113
+ @@hooks[queue].each do |hook|
114
+ self.instance_exec(cuke_scenario, &hook)
115
+ end
114
116
  end
115
- end
116
- end # module Hooks
117
- end # module WorldModule
117
+ end # module Hooks
118
+ end # module WorldModule
118
119
  end # module LapisLazuli
@@ -37,7 +37,7 @@ module WorldModule
37
37
  end
38
38
 
39
39
  # Start the logger with the config filename
40
- log_file = "#{dir}#{File::SEPARATOR}#{File.basename(Config.config_file, ".*")}.log"
40
+ log_file = "#{dir}#{File::SEPARATOR}#{File.basename(Config.config_files[0], ".*")}.log"
41
41
  # Or a filename from the environment
42
42
  if has_env_or_config?("log_file")
43
43
  log_file = env_or_config("log_file")
@@ -8,7 +8,7 @@
8
8
 
9
9
  ################################################################################
10
10
  # Set the global variables
11
- default_env: production # defines the environment
11
+ default_env: local # defines the environment
12
12
  default_device: desktop720 # set the default browser dimensions and/or user agent (See devices.yml)
13
13
  screenshots_dir: screenshots # where to save the screenshots
14
14
  screenshots_height: full # When 'full' the window will be resized to max height before taking a screenshot
@@ -29,11 +29,12 @@ error_strings:
29
29
 
30
30
  ################################################################################
31
31
  # Environment specific variables
32
- test:
33
-
34
- uat:
32
+ remote:
33
+ close_browser_after: feature
34
+ server:
35
+ url: local_path
35
36
 
36
- production:
37
+ local:
37
38
  close_browser_after: feature
38
39
  server:
39
- url: http://localhost:9090/
40
+ url: http://localhost:9090/
@@ -24,13 +24,11 @@ chrome: BROWSER=chrome
24
24
  ie: BROWSER=ie
25
25
  safari: BROWSER=safari
26
26
 
27
- ################################################################################
28
- # Listed environments (default is set in config.yml)
29
- t: TEST_ENV=test -t @t,@test
30
- test: TEST_ENV=test -t @t,@test
27
+ local: TEST_ENV=local -t @p,@prod
31
28
 
32
- u: TEST_ENV=acceptatie -t @u,@uat
33
- uat: TEST_ENV=acceptatie -t @u,@uat
29
+ remote: SELENIUM_ENV=remote -t ~@ignore_on_remote TEST_ENV=remote
34
30
 
35
- p: TEST_ENV=production -t @p,@prod
36
- production: TEST_ENV=production -t @p,@prod
31
+ ################################################################################
32
+ # Calliope.pro settings
33
+ calliope_key: API_KEY=
34
+ calliope_import: -p calliope_key -c -f pretty -f calliope_import --out ./results/latest_results.json
@@ -1,4 +1,4 @@
1
- @bindings @p
1
+ @bindings @p @ignore_on_remote
2
2
  Feature: binding
3
3
  When I want to test the Lapis Lazuli library
4
4
  I want to run a webserver with some test files
@@ -1,4 +1,4 @@
1
- @browser @p
1
+ @browser @p @ignore_on_remote
2
2
  Feature: Browsers
3
3
  When I want to test the Lapis Lazuli library
4
4
  And test if I can start a browser with options
@@ -11,6 +11,9 @@ Given(/^I navigate to the (.*) test page$/) do |page|
11
11
  config = "server.url"
12
12
  if has_env?(config)
13
13
  url = env(config)
14
+ if url == 'local_path'
15
+ url = 'file://' + File.expand_path(File.dirname(File.dirname(__FILE__))) + '/../server/www/'
16
+ end
14
17
  browser.goto "#{url}#{page.downcase.gsub(" ", "_")}.html"
15
18
  else
16
19
  error(:env => config)
@@ -43,9 +46,9 @@ Given(/I click (the|a) (first|last|random|[0-9]+[a-z]+) (.*)$/) do |arg1, index,
43
46
  end
44
47
 
45
48
 
46
- Given(/^I create a firefox browser named "(.*?)"( with proxy to "(.*?)")$/) do |name, proxy, proxy_url|
49
+ Given(/^I create a firefox browser named "(.*?)"(?: with proxy to "(.*?)")?$/) do |name, proxy_url|
47
50
  b = nil
48
- if proxy
51
+ if proxy_url
49
52
  log.debug("Starting with profile")
50
53
  require 'selenium-webdriver'
51
54
  profile = Selenium::WebDriver::Firefox::Profile.new
@@ -126,11 +126,11 @@ Then(/^within (\d+) seconds I should see added elements with matching$/) do |tim
126
126
  elems = browser.multi_wait_all(
127
127
  :timeout => timeout,
128
128
  :condition => :until,
129
- :mode => :match_all,
129
+ :mode => :match_any,
130
130
  :groups => ["wait"],
131
131
  :selectors => [
132
132
  {:tag_name => 'span', :class => /foo/, :text => /foo/},
133
- {:tag_name => 'div', :id => 'bar', :html => "bar"}
133
+ {:tag_name => 'div', :id => 'bar', :text => "bar"}
134
134
  ]
135
135
  )
136
136
  assert (2 == elems.length), "Expected two elements, found #{elems.length}"
@@ -4,6 +4,7 @@
4
4
  # Author: "spriteCloud" <info@spritecloud.com>
5
5
  require 'lapis_lazuli'
6
6
  require 'lapis_lazuli/cucumber'
7
+ require 'cucumber/calliope_importer'
7
8
 
8
9
  module TestModule
9
10
  def test_func
@@ -11,7 +12,7 @@ module TestModule
11
12
  end
12
13
  end
13
14
 
14
- LapisLazuli::WorldModule::Config.config_file = "config/config.yml"
15
+ LapisLazuli::WorldModule::Config.add_config "config/config.yml"
15
16
  World(LapisLazuli, TestModule)
16
17
 
17
18
  LapisLazuli::WorldModule::Browser.browser_module(TestModule)
@@ -22,7 +23,27 @@ LapisLazuli.Start do
22
23
  print "Lapis Lazuli: #{Gem.loaded_specs['lapis_lazuli'].version}\n"
23
24
  print "Selenium webdriver: #{Gem.loaded_specs['selenium-webdriver'].version}\n"
24
25
  print "Watir: #{Gem.loaded_specs['watir'].version}\n"
26
+ print "Cucumber: #{Gem.loaded_specs['cucumber'].version}\n"
25
27
  print "---- VERSION INFO ----\n\n"
28
+
29
+ if ENV['SELENIUM_ENV'] == 'remote'
30
+ require 'selenium-webdriver'
31
+ if ENV['BROWSER'] == 'firefox'
32
+ remote_url = 'http://selenium__standalone-firefox:4444/wd/hub/'
33
+ caps = Selenium::WebDriver::Remote::Capabilities.firefox
34
+ else
35
+ remote_url = 'http://selenium__standalone-chrome:4444/wd/hub/'
36
+ caps = Selenium::WebDriver::Remote::Capabilities.chrome
37
+ end
38
+ client = Selenium::WebDriver::Remote::Http::Default.new
39
+ client.timeout = 120
40
+
41
+ browser :remote, {desired_capabilities: caps, http_client: client, url: remote_url}
42
+ end
43
+
44
+ ENV['TA_OS'] = RUBY_PLATFORM
45
+ ENV['TA_PLATFORM'] = "#{browser.driver.browser} #{browser.driver.capabilities.version}"
46
+ ENV['TA_BUILD'] = "Lapis Lazuli #{Gem.loaded_specs['lapis_lazuli'].version}"
26
47
  end
27
48
 
28
49
  # Transition function from old codebase to new
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lapis_lazuli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Onno Steenbergen
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2017-11-13 00:00:00.000000000 Z
14
+ date: 2018-02-07 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -154,19 +154,39 @@ dependencies:
154
154
  - !ruby/object:Gem::Version
155
155
  version: '3.1'
156
156
  - !ruby/object:Gem::Dependency
157
- name: selenium-webdriver
157
+ name: deep_merge
158
158
  requirement: !ruby/object:Gem::Requirement
159
159
  requirements:
160
160
  - - "~>"
161
161
  - !ruby/object:Gem::Version
162
- version: '3'
162
+ version: '1.2'
163
163
  type: :runtime
164
164
  prerelease: false
165
165
  version_requirements: !ruby/object:Gem::Requirement
166
166
  requirements:
167
167
  - - "~>"
168
168
  - !ruby/object:Gem::Version
169
- version: '3'
169
+ version: '1.2'
170
+ - !ruby/object:Gem::Dependency
171
+ name: selenium-webdriver
172
+ requirement: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: '2.0'
177
+ - - "<"
178
+ - !ruby/object:Gem::Version
179
+ version: '4'
180
+ type: :runtime
181
+ prerelease: false
182
+ version_requirements: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: '2.0'
187
+ - - "<"
188
+ - !ruby/object:Gem::Version
189
+ version: '4'
170
190
  - !ruby/object:Gem::Dependency
171
191
  name: watir
172
192
  requirement: !ruby/object:Gem::Requirement
@@ -185,16 +205,22 @@ dependencies:
185
205
  name: cucumber
186
206
  requirement: !ruby/object:Gem::Requirement
187
207
  requirements:
188
- - - "~>"
208
+ - - ">="
209
+ - !ruby/object:Gem::Version
210
+ version: '2.0'
211
+ - - "<"
189
212
  - !ruby/object:Gem::Version
190
- version: '2'
213
+ version: '4.0'
191
214
  type: :runtime
192
215
  prerelease: false
193
216
  version_requirements: !ruby/object:Gem::Requirement
194
217
  requirements:
195
- - - "~>"
218
+ - - ">="
219
+ - !ruby/object:Gem::Version
220
+ version: '2.0'
221
+ - - "<"
196
222
  - !ruby/object:Gem::Version
197
- version: '2'
223
+ version: '4.0'
198
224
  description: "\n LapisLazuli provides cucumber helper functions and scaffolding
199
225
  for easier (web)\n test automation suite development.\n\n A lot of functionality
200
226
  is aimed at dealing better with [Watir](http://watir.com/),\n such as:\n\n -
@@ -235,13 +261,18 @@ files:
235
261
  - lib/lapis_lazuli/generators/cucumber/template/config/config.yml
236
262
  - lib/lapis_lazuli/generators/cucumber/template/config/cucumber.yml
237
263
  - lib/lapis_lazuli/generators/cucumber/template/config/devices.yml
238
- - lib/lapis_lazuli/generators/cucumber/template/features/account.feature
239
- - lib/lapis_lazuli/generators/cucumber/template/features/example.feature
240
- - lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/interaction_steps.rb
241
- - lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/precondition_steps.rb
242
- - lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/validation_steps.rb
264
+ - lib/lapis_lazuli/generators/cucumber/template/config/users.yml
265
+ - lib/lapis_lazuli/generators/cucumber/template/features/1_basic.feature
266
+ - lib/lapis_lazuli/generators/cucumber/template/features/2_account.feature
267
+ - lib/lapis_lazuli/generators/cucumber/template/features/3_todo_list.feature
268
+ - lib/lapis_lazuli/generators/cucumber/template/features/helpers/authentication_helper.rb
269
+ - lib/lapis_lazuli/generators/cucumber/template/features/helpers/navigation_helper.rb
270
+ - lib/lapis_lazuli/generators/cucumber/template/features/helpers/registration_helper.rb
271
+ - lib/lapis_lazuli/generators/cucumber/template/features/helpers/user_helper.rb
272
+ - lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/account_steps.rb
273
+ - lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/basic_steps.rb
274
+ - lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/todo_steps.rb
243
275
  - lib/lapis_lazuli/generators/cucumber/template/features/support/env.rb
244
- - lib/lapis_lazuli/generators/cucumber/template/features/support/functions.rb
245
276
  - lib/lapis_lazuli/generic/assertions.rb
246
277
  - lib/lapis_lazuli/generic/xpath.rb
247
278
  - lib/lapis_lazuli/options.rb
@@ -287,6 +318,7 @@ files:
287
318
  - test/features/timing.feature
288
319
  - test/features/variable.feature
289
320
  - test/features/xpath.feature
321
+ - test/results/latest_results.json
290
322
  - test/server/start.rb
291
323
  - test/server/www/button.html
292
324
  - test/server/www/error_html.html
@@ -316,7 +348,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
316
348
  version: '0'
317
349
  requirements: []
318
350
  rubyforge_project:
319
- rubygems_version: 2.6.12
351
+ rubygems_version: 2.6.14
320
352
  signing_key:
321
353
  specification_version: 4
322
354
  summary: Cucumber helper functions and scaffolding for easier test automation suite
@@ -348,6 +380,7 @@ test_files:
348
380
  - test/features/timing.feature
349
381
  - test/features/variable.feature
350
382
  - test/features/xpath.feature
383
+ - test/results/latest_results.json
351
384
  - test/server/start.rb
352
385
  - test/server/www/button.html
353
386
  - test/server/www/error_html.html