lapis_lazuli 2.1.4 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +13 -0
  3. data/README.md +4 -1
  4. data/lapis_lazuli.gemspec +16 -15
  5. data/lib/lapis_lazuli.rb +0 -2
  6. data/lib/lapis_lazuli/api.rb +1 -1
  7. data/lib/lapis_lazuli/argparse.rb +1 -1
  8. data/lib/lapis_lazuli/ast.rb +2 -141
  9. data/lib/lapis_lazuli/browser.rb +50 -160
  10. data/lib/lapis_lazuli/browser/screenshots.rb +3 -4
  11. data/lib/lapis_lazuli/cli.rb +1 -1
  12. data/lib/lapis_lazuli/cucumber.rb +1 -1
  13. data/lib/lapis_lazuli/generators/cucumber.rb +1 -1
  14. data/lib/lapis_lazuli/generators/cucumber/template/config/config.yml +1 -1
  15. data/lib/lapis_lazuli/generators/cucumber/template/features/1_basic.feature +14 -7
  16. data/lib/lapis_lazuli/generators/cucumber/template/features/helpers/authentication_helper.rb +3 -3
  17. data/lib/lapis_lazuli/generators/cucumber/template/features/helpers/navigation_helper.rb +1 -1
  18. data/lib/lapis_lazuli/generators/cucumber/template/features/helpers/registration_helper.rb +16 -7
  19. data/lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/basic_steps.rb +7 -2
  20. data/lib/lapis_lazuli/generic/xpath.rb +1 -1
  21. data/lib/lapis_lazuli/options.rb +1 -1
  22. data/lib/lapis_lazuli/placeholders.rb +1 -1
  23. data/lib/lapis_lazuli/proxy.rb +1 -1
  24. data/lib/lapis_lazuli/runtime.rb +1 -1
  25. data/lib/lapis_lazuli/scenario.rb +1 -1
  26. data/lib/lapis_lazuli/storage.rb +1 -1
  27. data/lib/lapis_lazuli/version.rb +2 -2
  28. data/lib/lapis_lazuli/versions.rb +1 -1
  29. data/lib/lapis_lazuli/world/logging.rb +34 -33
  30. data/test/Gemfile +1 -3
  31. data/test/features/bindings.feature +6 -6
  32. data/test/features/browser.feature +10 -10
  33. data/test/features/button.feature +4 -3
  34. data/test/features/step_definitions/interaction_steps.rb +13 -24
  35. data/test/features/step_definitions/multifind_steps.rb +3 -3
  36. data/test/features/step_definitions/validation_steps.rb +2 -2
  37. data/test/features/support/env.rb +0 -1
  38. data/test/server/start.rb +1 -1
  39. metadata +55 -57
  40. data/lib/lapis_lazuli/browser/remote.rb +0 -140
  41. data/lib/lapis_lazuli/world/annotate.rb +0 -47
  42. data/test/features/annotation.feature +0 -23
@@ -6,6 +6,9 @@
6
6
  # All rights reserved.
7
7
  #
8
8
 
9
+ require 'cucumber/core/test/case'
10
+ require 'cucumber/core/test/step'
11
+
9
12
  module LapisLazuli
10
13
  module BrowserModule
11
14
 
@@ -82,10 +85,6 @@ module LapisLazuli
82
85
  end
83
86
  world.log.debug "Screenshot saved: #{fileloc}"
84
87
 
85
- # Try to store the screenshot name
86
- if world.respond_to? :annotate
87
- world.annotate :screenshot => fileloc
88
- end
89
88
  rescue RuntimeError => e
90
89
  world.log.debug "Failed to save screenshot to '#{fileloc}'. Error message #{e.message}"
91
90
  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
 
@@ -42,6 +42,6 @@ production:
42
42
  about-us: /about-us/
43
43
  testing: /testing/
44
44
  blog: /blog/
45
- functional-testing: /testing/functional/
45
+ functional-testing: /testing/functional-testing/
46
46
  jobs: /jobs
47
47
  training-page: http://training-page.testautomation.info/#
@@ -11,13 +11,20 @@ I want to run and adjust the tests below
11
11
  Then text "Open Source" should display somewhere on the page
12
12
 
13
13
  @basic_02
14
- Scenario: example02 - Going to a search result
15
- Given the user navigates to "https://spritecloud.com/?s=lapis+lazuli"
16
- When the user clicks on link "/announcing-lapislazuli/"
17
- Then text "Let's talk about testing" should display somewhere on the page
14
+ Scenario: example02 - scrolling down
15
+ Given the user navigates to "home"
16
+ When the user scrolls down
17
+ Then text "Project-based services are typically short-term" should display somewhere on the page
18
18
 
19
19
  @basic_03
20
- Scenario Outline: example03 - checking multiple pages for the logo
20
+ Scenario: example03 - Going to a search result
21
+ Given the user navigates to "https://www.spritecloud.com/?s=lapis+lazuli"
22
+ When the user scrolls down
23
+ And the user clicks on link "/announcing-lapislazuli/"
24
+ Then text "A few days later you are working" should display somewhere on the page
25
+
26
+ @basic_04
27
+ Scenario Outline: example04 - checking multiple pages for the logo
21
28
  Given the user navigates to "<page>"
22
29
  When the user clicks on the spritecloud logo
23
30
  Then the user should be on page "home"
@@ -35,8 +42,8 @@ I want to run and adjust the tests below
35
42
  # or, if you want to test it on a specific environment:
36
43
  # bundle exec cucumber -p production -p debug -t @basic_04
37
44
  # Good luck fixing the problems!
38
- @basic_04 @dev
39
- Scenario: example_04 - confirming there is a no results page
45
+ @basic_05 @dev
46
+ Scenario: example_05 - confirming there is a no results page
40
47
  Given the user navigates to "blog"
41
48
  When the user searches for "no_results_expected"
42
49
  Then the text "Nothing Found" should display on the blog page
@@ -104,8 +104,8 @@ module Auth
104
104
  # If user=nil, we expect that there already is user data loaded in a previous step.
105
105
  User.load_user_data(user) unless user.nil?
106
106
 
107
- Auth.username_field.to_subtype.set(User.get('username'))
108
- Auth.password_field.to_subtype.set(User.get('password'))
107
+ Auth.username_field.to_subtype.to_subtype.set(User.get('username'))
108
+ Auth.password_field.to_subtype.to_subtype.set(User.get('password'))
109
109
  Auth.login_button.click
110
110
 
111
111
  unless Auth.is_logged_in? user
@@ -114,7 +114,7 @@ module Auth
114
114
  error "Failed to log in user #{user}"
115
115
  else
116
116
  alert.flash
117
- error "Found error while logging in #{user}: `#{alert.text}`"
117
+ error "Found error while logging in #{user}: `#{alert.html}`"
118
118
  end
119
119
  end
120
120
  end
@@ -61,4 +61,4 @@ module Nav
61
61
  end
62
62
 
63
63
  end
64
- end
64
+ end
@@ -8,7 +8,7 @@ module Register
8
8
  # @formatter:off
9
9
  def form; browser.wait(:like => [:form, :id, 'form-register']); end
10
10
  def open_register_button; browser.find(:like => [:button, :id, 'button-register']); end
11
- def username_field; browser.find(:element => {:name => 'username'}, :context => Register.form); end
11
+ def username_field; browser.wait(:element => {:name => 'username'}, :context => Register.form); end
12
12
  def password_field; browser.find(:element => {:name => 'password'}, :context => Register.form); end
13
13
  def experience_field; browser.find(:like => [:select, :id, "register-experience"], :context => form); end
14
14
  def biography_field; browser.find(:like => [:textarea, :id, 'register-bio']); end
@@ -52,16 +52,25 @@ module Register
52
52
  end
53
53
 
54
54
  def fill_form
55
- Register.username_field.set(User.get('username'))
56
- Register.password_field.set(User.get('password'))
55
+ #the setter goes too fast sometimes not finishing the username, this will re-set the username when it does
56
+ browser.wait_until(timeout: 10, message: 'False did not become true withing 10 seconds') {
57
+ Register.username_field.to_subtype.set(User.get('username'))
58
+ Register.username_field.value == User.get('username')
59
+ }
60
+ Register.username_field.to_subtype.set(User.get('username'))
61
+ Register.password_field.to_subtype.set(User.get('password'))
57
62
  Register.gender_radio(User.get('gender')).click
58
63
  Register.select_experiences(User.get('experience').split(','))
59
- Register.biography_field.set(User.get('biography'))
60
- Register.policy_checkbox.set((User.get('complete_all').to_i == 1))
64
+ Register.biography_field.to_subtype.set(User.get('biography'))
65
+ Register.policy_checkbox.to_subtype.set((User.get('complete_all').to_i == 1))
61
66
  end
62
67
 
63
68
  def submit_form
64
69
  Register.submit_button.click
70
+ browser.wait(
71
+ :like => [:div, :class, 'modal-backdrop fade in'],
72
+ :condition => :while
73
+ )
65
74
  end
66
75
 
67
76
  def register_user
@@ -73,8 +82,8 @@ module Register
73
82
  alert = browser.wait(like: [:div, :class, 'alert'], timeout: 2, throw: false)
74
83
  if alert.nil?
75
84
  return false, 'No message was displayed after registering'
76
- elsif !alert.text.include? User.get('username')
77
- return false, "An error message did display, but didn't contain the expected text: `#{alert.text}`"
85
+ elsif !alert.html.include? User.get('username')
86
+ return false, "An error message did display, but didn't contain the expected text: `#{alert.html}`"
78
87
  end
79
88
  return true, 'Successfully found the success message'
80
89
  end
@@ -25,6 +25,10 @@ Given(/^the user searches for "(.*?)"$/) do |query|
25
25
  searchbox.send_keys(:enter)
26
26
  end
27
27
 
28
+ When(/^the user scrolls down$/) do
29
+ browser.driver.execute_script("window.scrollBy(0,400)")
30
+ end
31
+
28
32
  Then(/^text "([^"]*)" should display somewhere on the page$/) do |string|
29
33
  # Search for the text on the page
30
34
  browser.wait(:xpath => "//*[contains(text(),\"#{string}\")]")
@@ -32,6 +36,7 @@ end
32
36
 
33
37
  When(/^the user clicks on link "(.*?)"$/) do |url|
34
38
  # Search for the element that includes the expected text
39
+
35
40
  browser.wait(
36
41
  :like => {
37
42
  :element => :a,
@@ -44,8 +49,8 @@ end
44
49
  When(/^the user clicks on the spritecloud logo$/) do
45
50
  # Search for the logo
46
51
  logo = browser.find(
47
- :like => [:img, :id, 'logo'],
48
- :message => 'Unable to find the logo on this page.'
52
+ a: {class: ['logo']},
53
+ message: 'Unable to find the logo on this page.'
49
54
  )
50
55
  # And click the logo
51
56
  logo.click
@@ -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
  module LapisLazuli
@@ -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
  module LapisLazuli
@@ -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
  require 'singleton'
@@ -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 "securerandom"
@@ -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
  module LapisLazuli
@@ -2,9 +2,9 @@
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
  module LapisLazuli
9
- VERSION = "2.1.4"
9
+ VERSION = "3.0.2"
10
10
  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 'lapis_lazuli/api'
@@ -13,41 +13,42 @@ require "lapis_lazuli/runtime"
13
13
  require "lapis_lazuli/world/config"
14
14
 
15
15
  module LapisLazuli
16
- module WorldModule
17
- ##
18
- # Module for easy logging
19
- #
20
- # Manages the following:
21
- # @log - TeeLogger instances
22
- module Logging
23
- include LapisLazuli::WorldModule::Config
24
-
16
+ module WorldModule
25
17
  ##
26
- # Log "singleton"
27
- def log
28
- return Runtime.instance.set_if(self, :logger) do
29
- # Make log directory
30
- dir = env_or_config('log_dir')
31
- begin
32
- Dir.mkdir dir
33
- rescue SystemCallError => ex
34
- # Swallow this error; it occurs (amongst other situations) when the
35
- # directory exists. Checking for an existing directory beforehand is
36
- # not concurrency safe.
37
- end
18
+ # Module for easy logging
19
+ #
20
+ # Manages the following:
21
+ # @log - TeeLogger instances
22
+ module Logging
23
+ include LapisLazuli::WorldModule::Config
38
24
 
39
- # Start the logger with the config filename
40
- log_file = "#{dir}#{File::SEPARATOR}#{File.basename(Config.config_files[0], ".*")}.log"
41
- # Or a filename from the environment
42
- if has_env_or_config?("log_file")
43
- log_file = env_or_config("log_file")
44
- end
45
- l = TeeLogger::TeeLogger.new(log_file)
46
- l.level = env_or_config("log_level")
25
+ ##
26
+ # Log "singleton"
27
+ def log(msg = nil)
28
+ super(msg) if msg
29
+ return Runtime.instance.set_if(self, :logger) do
30
+ # Make log directory
31
+ dir = env_or_config('log_dir')
32
+ begin
33
+ Dir.mkdir dir
34
+ rescue SystemCallError => ex
35
+ # Swallow this error; it occurs (amongst other situations) when the
36
+ # directory exists. Checking for an existing directory beforehand is
37
+ # not concurrency safe.
38
+ end
47
39
 
48
- l
40
+ # Start the logger with the config filename
41
+ log_file = "#{dir}#{File::SEPARATOR}#{File.basename(Config.config_files[0], ".*")}.log"
42
+ # Or a filename from the environment
43
+ if has_env_or_config?("log_file")
44
+ log_file = env_or_config("log_file")
45
+ end
46
+ l = TeeLogger::TeeLogger.new(log_file)
47
+ l.level = env_or_config("log_level")
48
+
49
+ l
50
+ end
49
51
  end
50
- end
51
- end # module Logging
52
- end # module WorldModule
52
+ end # module Logging
53
+ end # module WorldModule
53
54
  end # module LapisLazuli
data/test/Gemfile CHANGED
@@ -3,11 +3,9 @@ source 'http://rubygems.org'
3
3
  # Build and include the LL gem from the parent directory
4
4
  gem "lapis_lazuli", path: './../'
5
5
 
6
- # Gem used to import results to calliope.pro
7
- gem 'cucumber-calliope_importer'
8
6
 
9
7
  # Project specific gems
10
- gem 'watir-scroll'
8
+ gem 'cucumber', '~> 6'
11
9
  gem 'xml-simple'
12
10
  gem 'mechanize'
13
11
  gem 'simplecov'
@@ -7,14 +7,14 @@ And test if I can parse bindings when starting the browsers
7
7
  @bindings_01
8
8
  Scenario: bindings_01 - Custom user-agent firefox
9
9
  Given I use browser bindings "1"
10
- And I navigate to URL "http://whatsmyua.com/"
10
+ And I navigate to URL "https://www.whatsmyua.info/"
11
11
  Then within 2 seconds I should see "CUSTOM-USER-AGENT"
12
12
  And I close the browser
13
13
 
14
14
  @bindings_02
15
15
  Scenario: bindings_02 - Custom user-agent chrome
16
16
  Given I use browser bindings "2"
17
- And I navigate to URL "http://whatsmyua.com/"
17
+ And I navigate to URL "https://www.whatsmyua.info/"
18
18
  Then within 2 seconds I should see "CUSTOM-CHROME-USER-AGENT"
19
19
  And I close the browser
20
20
 
@@ -22,22 +22,22 @@ And test if I can parse bindings when starting the browsers
22
22
  @bindings_03 @maximize_issue
23
23
  Scenario: bindings_03 - Custom user-agent chrome
24
24
  Given I use browser bindings "3"
25
- And I navigate to URL "http://whatsmyua.com/"
25
+ And I navigate to URL "https://www.whatsmyua.info/"
26
26
  Then the browser window size should be "full screen"
27
27
  And I close the browser
28
28
 
29
29
  @bindings_04
30
30
  Scenario: bindings_04 - Using a pre-defined device (iphone5)
31
31
  Given I restart the browser to device setting "iphone5"
32
- When I navigate to URL "http://whatsmyua.com"
33
- Then within 2 seconds I should see "CPU iPhone OS 5_0 like Mac OS X"
32
+ When I navigate to URL "https://www.whatsmyua.info/"
33
+ Then within 2 seconds I should see "AppleWebKit"
34
34
  And the browser window size should be "640x1136"
35
35
  And I close the browser
36
36
 
37
37
  @bindings_05
38
38
  Scenario: bindings_05 - Using a pre-defined device (desktop1080)
39
39
  Given I restart the browser to device setting "desktop1080"
40
- When I navigate to URL "http://whatsmyua.com"
40
+ When I navigate to URL "https://www.whatsmyua.info/"
41
41
  Then within 2 seconds I should see "Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3" disappear
42
42
  And the browser window size should be "1920x1080"
43
43
  And I close the browser
@@ -1,10 +1,10 @@
1
- @browser @p @ignore_on_remote
2
- Feature: Browsers
3
- When I want to test the Lapis Lazuli library
4
- And test if I can start a browser with options
5
-
6
- @browser_01
7
- Scenario: browser_01 - Firefox with proxy
8
- When I create a firefox browser named "test" with proxy to "localhost:8008"
9
- Then the firefox browser named "test" has a profile
10
- Then I close the browser named "test"
1
+ #@browser @p @ignore_on_remote
2
+ #Feature: Browsers
3
+ #When I want to test the Lapis Lazuli library
4
+ #And test if I can start a browser with options
5
+ #
6
+ #@browser_01
7
+ #Scenario: browser_01 - Firefox with proxy
8
+ # When I create a firefox browser named "test" with proxy to "localhost:8008"
9
+ # Then the firefox browser named "test" has a profile
10
+ # Then I close the browser named "test"