ruby_raider 0.4.3 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/lib/commands/utility_commands.rb +19 -1
  3. data/lib/generators/automation_generator.rb +14 -0
  4. data/lib/generators/common_generator.rb +2 -2
  5. data/lib/generators/generator.rb +1 -0
  6. data/lib/generators/helper_generator.rb +18 -2
  7. data/lib/generators/menu_generator.rb +19 -7
  8. data/lib/generators/templates/automation/abstract_page.tt +9 -6
  9. data/lib/generators/templates/automation/app_page.tt +11 -0
  10. data/lib/generators/templates/automation/home_page.tt +1 -1
  11. data/lib/generators/templates/automation/login_page.tt +5 -4
  12. data/lib/generators/templates/automation/partials/home_page_selector.tt +8 -8
  13. data/lib/generators/templates/automation/partials/pdp_page_selector.tt +8 -8
  14. data/lib/generators/templates/automation/partials/require_raider.tt +3 -3
  15. data/lib/generators/templates/automation/partials/visual_login.tt +25 -0
  16. data/lib/generators/templates/automation/pdp_page.tt +1 -1
  17. data/lib/generators/templates/automation/visual_options.tt +16 -0
  18. data/lib/generators/templates/common/gemfile.tt +7 -0
  19. data/lib/generators/templates/common/partials/web_config.tt +5 -1
  20. data/lib/generators/templates/helpers/appium_helper.tt +1 -1
  21. data/lib/generators/templates/helpers/driver_helper.tt +4 -3
  22. data/lib/generators/templates/helpers/partials/driver_and_options.tt +25 -25
  23. data/lib/generators/templates/helpers/raider_helper.tt +5 -0
  24. data/lib/generators/templates/helpers/visual_helper.tt +66 -0
  25. data/lib/generators/templates/helpers/visual_spec_helper.tt +30 -0
  26. data/lib/generators/templates/rspec/spec.tt +23 -1
  27. data/lib/utilities/utilities.rb +36 -1
  28. data/ruby_raider.gemspec +1 -1
  29. data/spec/automation_generator_spec.rb +0 -4
  30. data/spec/common_generator_spec.rb +1 -1
  31. data/spec/spec_helper.rb +1 -1
  32. metadata +8 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1179dcf5f2664b6adea02db8af1b33883f18d095f9c9b57acf3fa2bb56d68c49
4
- data.tar.gz: ad8dc4b695f154191047406e882029b063c4147987adf369c018063d38b414c9
3
+ metadata.gz: f7b2c000c852222f35914766b001264de3988fc1d4c2baa7b28504c885dad43a
4
+ data.tar.gz: d791271be3eb3118dfde048a732a672f5c5a65b80975ce7ea9f061504ca7b594
5
5
  SHA512:
6
- metadata.gz: d052c0513c67e27313cdcff208ab5ed54a6606722480ab3534b2c84976b0fffd0a8675367b278575ec1181b7a48f695ed08643cee5bf5229c317c136359fc171
7
- data.tar.gz: 1130758fd998eecfb68f320968c3993ea5d026c362ebcc22068ae28c4b0301084e0fb9b6d116a8e2f06e14cecba91b25d37d0e4d81595a1e565cc3917c3de512
6
+ metadata.gz: 162584ae4fed3dacba0ee826fd707243d4150f1cfbabf00a40d1de0dd1433ac52e38157a9d553fef2d192ff31e7c8203b89d77cbfe8ea1bd709a479e4082d51c
7
+ data.tar.gz: 328caadb18a48ae8f103b79e91cf12b365139d5854e3f4e1a28bd27436de8bf04f5270e51a6aeddc9c4c19df1c55c97251e3bc2f20e5f5fdc8f7f24798502463
@@ -55,7 +55,7 @@ class UtilityCommands < Thor
55
55
  option :parallel,
56
56
  type: :boolean, required: false, desc: 'It runs the tests in parallel', aliases: '-p'
57
57
  option :opts,
58
- type: :array, required: false, desc: 'The options you your parallelization to run with', aliases: '-o'
58
+ type: :array, required: false, desc: 'The options that your run will run with', aliases: '-o'
59
59
 
60
60
  def raid
61
61
  if options[:parallel]
@@ -80,4 +80,22 @@ class UtilityCommands < Thor
80
80
  end
81
81
 
82
82
  map '-pl' => 'platform'
83
+
84
+ desc 'download_builds [build_type]', 'It downloads the example builds for appium projects'
85
+ def download_builds(build_type)
86
+ if %w[android, ios, both].include?(build_type)
87
+ raise 'Please select one of the following build types: android, ios, both'
88
+ end
89
+
90
+ Utilities.new.download_builds build_type
91
+ end
92
+
93
+ map '-d' => 'download_builds'
94
+
95
+ desc 'version', 'It shows the version of Ruby Raider you are currently using'
96
+ def version
97
+ Utilities.new.version
98
+ end
99
+
100
+ map '-v' => 'version'
83
101
  end
@@ -27,12 +27,14 @@ class AutomationGenerator < Generator
27
27
 
28
28
  def generate_header_component
29
29
  return unless (@_initializer.first & %w[android ios cross_platform]).empty?
30
+ return if @_initializer.first.last
30
31
 
31
32
  template('automation/component.tt', "#{name}/page_objects/components/header_component.rb")
32
33
  end
33
34
 
34
35
  def generate_abstract_component
35
36
  return unless (@_initializer.first & %w[android ios cross_platform]).empty?
37
+ return if @_initializer.first.last
36
38
 
37
39
  template('automation/abstract_component.tt', "#{name}/page_objects/abstract/abstract_component.rb")
38
40
  end
@@ -42,4 +44,16 @@ class AutomationGenerator < Generator
42
44
 
43
45
  template('automation/appium_caps.tt', "#{name}/config/capabilities.yml")
44
46
  end
47
+
48
+ def generate_app_page
49
+ return unless @_initializer.first.last
50
+
51
+ template('automation/app_page.tt', "#{name}/page_objects/pages/app_page.rb")
52
+ end
53
+
54
+ def generate_visual_options
55
+ return unless @_initializer.first.last
56
+
57
+ template('automation/visual_options.tt', "#{name}/config/options.yml")
58
+ end
45
59
  end
@@ -22,10 +22,10 @@ class CommonGenerator < Generator
22
22
  end
23
23
 
24
24
  def create_allure_folder
25
- empty_directory "#{name}/allure-results"
25
+ empty_directory "#{name}/allure-results" unless @_initializer.first.last
26
26
  end
27
27
 
28
28
  def create_screenshots_folder
29
- empty_directory "#{name}/allure-results/screenshots"
29
+ empty_directory "#{name}/allure-results/screenshots" unless @_initializer.first.last
30
30
  end
31
31
  end
@@ -8,6 +8,7 @@ class Generator < Thor::Group
8
8
  argument :automation
9
9
  argument :framework
10
10
  argument :name
11
+ argument :visual_automation, optional: true
11
12
 
12
13
  def self.source_root
13
14
  "#{File.dirname(__FILE__)}/templates"
@@ -8,6 +8,8 @@ class HelpersGenerator < Generator
8
8
  end
9
9
 
10
10
  def generate_allure_helper
11
+ return if @_initializer.first.last
12
+
11
13
  template('helpers/allure_helper.tt', "#{name}/helpers/allure_helper.rb")
12
14
  end
13
15
 
@@ -16,6 +18,8 @@ class HelpersGenerator < Generator
16
18
  end
17
19
 
18
20
  def generate_spec_helper
21
+ return if @_initializer.first.last
22
+
19
23
  template('helpers/spec_helper.tt', "#{name}/helpers/spec_helper.rb") if @_initializer.first.include?('rspec')
20
24
  end
21
25
 
@@ -31,9 +35,21 @@ class HelpersGenerator < Generator
31
35
  template('helpers/driver_helper.tt', "#{name}/helpers/driver_helper.rb")
32
36
  end
33
37
 
34
- def generate_pdp_page
35
- return unless (@_initializer.first.include?('cross_platform'))
38
+ def generate_appium_helper
39
+ return unless @_initializer.first.include?('cross_platform')
36
40
 
37
41
  template('helpers/appium_helper.tt', "#{name}/helpers/appium_helper.rb")
38
42
  end
43
+
44
+ def generate_visual_helper
45
+ return unless @_initializer.first.last
46
+
47
+ template('helpers/visual_helper.tt', "#{name}/helpers/visual_helper.rb")
48
+ end
49
+
50
+ def generate_visual_spec_helper
51
+ return unless @_initializer.first.last
52
+
53
+ template('helpers/visual_spec_helper.tt', "#{name}/helpers/spec_helper.rb")
54
+ end
39
55
  end
@@ -25,14 +25,22 @@ class MenuGenerator
25
25
  end
26
26
  end
27
27
 
28
+ def choose_visual_automation
29
+ prompt.select('Do you want to add visual automation with applitools?') do |menu|
30
+ menu.choice :Yes, -> { true }
31
+ menu.choice :No, -> { false }
32
+ menu.choice :Quit, -> { exit }
33
+ end
34
+ end
35
+
28
36
  def choose_test_framework(automation)
29
37
  return choose_mobile_platform if automation == 'appium'
30
38
 
31
39
  select_test_framework(automation)
32
40
  end
33
41
 
34
- def set_up_framework(automation, framework)
35
- generate_framework(automation, framework)
42
+ def set_up_framework(automation, framework, visual_automation)
43
+ generate_framework(automation, framework, visual_automation)
36
44
  system "cd #{name} && gem install bundler && bundle install"
37
45
  end
38
46
 
@@ -45,9 +53,9 @@ class MenuGenerator
45
53
  end
46
54
  end
47
55
 
48
- def generate_framework(automation, framework)
56
+ def generate_framework(automation, framework, visual_automation)
49
57
  add_generator framework.capitalize
50
- generators.each { |generator| invoke_generator(automation, framework, generator) }
58
+ generators.each { |generator| invoke_generator(automation, framework, generator, visual_automation) }
51
59
  end
52
60
 
53
61
  protected
@@ -59,7 +67,11 @@ class MenuGenerator
59
67
  private
60
68
 
61
69
  def framework_choice(framework, automation_type)
62
- set_up_framework(automation_type, framework.downcase)
70
+ visual_automation = if automation_type == 'selenium' && framework == 'Rspec'
71
+ choose_visual_automation
72
+ end
73
+
74
+ set_up_framework(automation_type, framework.downcase, visual_automation)
63
75
  prompt.say("You have chosen to use #{framework} with #{automation_type}")
64
76
  end
65
77
 
@@ -75,7 +87,7 @@ class MenuGenerator
75
87
  end
76
88
  end
77
89
 
78
- def invoke_generator(automation, framework, generator)
79
- Object.const_get("#{generator}Generator").new([automation, framework, name]).invoke_all
90
+ def invoke_generator(automation, framework, generator, visual_automation)
91
+ Object.const_get("#{generator}Generator").new([automation, framework, name, visual_automation]).invoke_all
80
92
  end
81
93
  end
@@ -1,11 +1,14 @@
1
- <%= ERB.new(File.read(File.expand_path('./partials/require_raider.tt', __dir__)), nil, '-').result(binding) -%>
1
+ <%= ERB.new(File.read(File.expand_path('./partials/require_raider.tt', __dir__)), trim_mode: '-').result(binding) -%>
2
2
 
3
3
  class AbstractPage
4
- <% if automation == 'cross_platform' %>
4
+ <% if automation == 'cross_platform' -%>
5
5
  include Raider::AppiumHelper
6
- <% end %>
6
+ <% end -%>
7
+ <%= ERB.new(File.read(File.expand_path('./partials/initialize_selector.tt', __dir__))).result(binding) -%>
8
+ <%= ERB.new(File.read(File.expand_path('./partials/visit_method.tt', __dir__))).result(binding) -%>
9
+ <%= ERB.new(File.read(File.expand_path('./partials/url_methods.tt', __dir__))).result(binding) -%>
7
10
 
8
- <%= ERB.new(File.read(File.expand_path('./partials/initialize_selector.tt', __dir__))).result(binding) -%>
9
- <%= ERB.new(File.read(File.expand_path('./partials/visit_method.tt', __dir__))).result(binding) -%>
10
- <%= ERB.new(File.read(File.expand_path('./partials/url_methods.tt', __dir__))).result(binding) -%>
11
+ def to_s
12
+ self.class.to_s.sub('Page', ' Page')
13
+ end
11
14
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../abstract/abstract_page'
4
+
5
+ class AppPage < AbstractPage
6
+ using Raider::SeleniumHelper
7
+
8
+ def url(_page)
9
+ 'app.html#'
10
+ end
11
+ end
@@ -15,6 +15,6 @@ class HomePage < AbstractPage
15
15
  # Elements
16
16
 
17
17
  def backpack_image
18
- <%= ERB.new(File.read(File.expand_path('./partials/home_page_selector.tt', __dir__))).result(binding) %>
18
+ <%= ERB.new(File.read(File.expand_path('./partials/home_page_selector.tt', __dir__)), trim_mode: '-').result(binding) %>
19
19
  end
20
20
  end
@@ -1,6 +1,7 @@
1
- <% case automation
2
- when 'selenium' -%>
1
+ <% if automation == 'selenium' && visual_automation == true %>
2
+ <%= ERB.new(File.read(File.expand_path('./partials/visual_login.tt', __dir__))).result(binding) %>
3
+ <% elsif automation == 'selenium' %>
3
4
  <%= ERB.new(File.read(File.expand_path('./partials/selenium_login.tt', __dir__))).result(binding) %>
4
- <% when 'watir' -%>
5
+ <% elsif automation == 'watir' %>
5
6
  <%= ERB.new(File.read(File.expand_path('./partials/watir_login.tt', __dir__))).result(binding) %>
6
- <% end -%>
7
+ <% end %>
@@ -1,8 +1,8 @@
1
- <% if automation == 'ios' %>
2
- driver.find_element(predicate: 'label == "Sauce Labs Backpack"')
3
- <% elsif automation == 'android' %>
4
- driver.find_element(xpath: '(//android.view.ViewGroup[@content-desc="store item"])[1]/android.view.ViewGroup[1]')
5
- <% else %>
6
- element(ios: { predicate: 'label == "Sauce Labs Backpack"' },
7
- android: { xpath: '(//android.view.ViewGroup[@content-desc="store item"])[1]/android.view.ViewGroup[1]' })
8
- <% end %>
1
+ <% if automation == 'ios' -%>
2
+ driver.find_element(predicate: 'label == "Sauce Labs Backpack"')
3
+ <% elsif automation == 'android' -%>
4
+ driver.find_element(xpath: '(//android.view.ViewGroup[@content-desc="store item"])[1]/android.view.ViewGroup[1]')
5
+ <% else -%>
6
+ element(ios: { predicate: 'label == "Sauce Labs Backpack"' },
7
+ android: { xpath: '(//android.view.ViewGroup[@content-desc="store item"])[1]/android.view.ViewGroup[1]' })
8
+ <% end -%>
@@ -1,8 +1,8 @@
1
- <% if automation == 'ios' %>
2
- driver.find_element(accessibility_id: 'Add To Cart button')
3
- <% elsif automation == 'android' %>
4
- driver.find_element(xpath: '//android.view.ViewGroup[@content-desc="Add To Cart button"]/android.widget.TextView')
5
- <% else %>
6
- element(ios: { accessibility_id: 'Add To Cart button' },
7
- android: { xpath: '//android.view.ViewGroup[@content-desc="Add To Cart button"]/android.widget.TextView' })
8
- <% end %>
1
+ <% if automation == 'ios' -%>
2
+ driver.find_element(accessibility_id: 'Add To Cart button')
3
+ <% elsif automation == 'android' -%>
4
+ driver.find_element(xpath: '//android.view.ViewGroup[@content-desc="Add To Cart button"]/android.widget.TextView')
5
+ <% else -%>
6
+ element(ios: { accessibility_id: 'Add To Cart button' },
7
+ android: { xpath: '//android.view.ViewGroup[@content-desc="Add To Cart button"]/android.widget.TextView' })
8
+ <% end -%>
@@ -1,5 +1,5 @@
1
- <% if framework == 'rspec' %>
1
+ <% if framework == 'rspec' -%>
2
2
  require_relative '../../helpers/raider'
3
- <% else %>
3
+ <% else -%>
4
4
  require_relative '../../helpers/raider'
5
- <% end %>
5
+ <% end -%>
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../abstract/abstract_page'
4
+
5
+ class LoginPage < AbstractPage
6
+ using Raider::SeleniumHelper
7
+
8
+ def url(_page)
9
+ 'index.html'
10
+ end
11
+
12
+ # Actions
13
+
14
+ def login
15
+ login_button.click_when_present
16
+ end
17
+
18
+ private
19
+
20
+ # Elements
21
+
22
+ def login_button
23
+ driver.find_element(:id, 'log-in')
24
+ end
25
+ end
@@ -13,6 +13,6 @@ class PdpPage < AbstractPage
13
13
  # Elements
14
14
 
15
15
  def add_to_cart_button
16
- <%= ERB.new(File.read(File.expand_path('./partials/pdp_page_selector.tt', __dir__))).result(binding) %>
16
+ <%= ERB.new(File.read(File.expand_path('./partials/pdp_page_selector.tt', __dir__)), trim_mode: '-').result(binding) %>
17
17
  end
18
18
  end
@@ -0,0 +1,16 @@
1
+ :batch_name: test_batch
2
+ :app_name: test_app
3
+ :test_name: app_test
4
+
5
+ :viewport_size:
6
+ :height: 800
7
+ :width: 600
8
+
9
+ :browsers:
10
+ - :name: chrome
11
+ :height: 800
12
+ :width: 600
13
+
14
+ :devices:
15
+ - :name: IPhoneX
16
+ :orientation: PORTRAIT
@@ -1,13 +1,20 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'activesupport'
4
+ <% unless visual_automation -%>
4
5
  gem 'allure-rspec'
5
6
  gem 'allure-ruby-commons'
7
+ <% end -%>
6
8
  <% if framework == 'cucumber' -%>
7
9
  gem 'allure-cucumber'
8
10
  <% end -%>
11
+ <% if visual_automation -%>
12
+ gem 'eyes_selenium'
13
+ <% end -%>
14
+ <% unless visual_automation -%>
9
15
  gem 'parallel_split_test'
10
16
  gem 'parallel_tests'
17
+ <% end -%>
11
18
  gem 'rake'
12
19
  gem '<%= framework %>'
13
20
  <% if framework == 'cucumber' -%>
@@ -1,2 +1,6 @@
1
1
  browser: :chrome
2
- url: 'https://automationteststore.com/'
2
+ <% if visual_automation == true %>
3
+ url: 'https://demo.applitools.com/'
4
+ <% else %>
5
+ url: 'https://automationteststore.com/'
6
+ <% end %>
@@ -26,4 +26,4 @@ module Raider
26
26
  opts[os][strategy(opts)]
27
27
  end
28
28
  end
29
- end
29
+ end
@@ -11,7 +11,7 @@ module Raider
11
11
  module DriverHelper
12
12
  attr_reader :driver
13
13
 
14
- <%= ERB.new(File.read(File.expand_path('./partials/driver_and_options.tt', __dir__))).result(binding).strip! %>
14
+ <%= ERB.new(File.read(File.expand_path('./partials/driver_and_options.tt', __dir__)), trim_mode: '-').result(binding).strip! %>
15
15
 
16
16
  <% if automation == 'cross_platform' -%>
17
17
  private
@@ -21,9 +21,10 @@ module Raider
21
21
  end
22
22
  <% end -%>
23
23
  <% if automation != 'selenium' -%>
24
+
24
25
  def caps
25
26
  YAML.load_file('config/capabilities.yml')
26
27
  end
27
- <% end -%>
28
- end
28
+ <% end -%>
29
+ end
29
30
  end
@@ -1,28 +1,28 @@
1
- <% if automation == 'selenium' %>
1
+ <% if automation == 'selenium' -%>
2
2
  def new_driver(*opts)
3
- @config = YAML.load_file('config/config.yml')
4
- browser = @config['browser'].to_sym
5
- @driver = Selenium::WebDriver.for(browser, capabilities: browser_options(*opts))
6
- end
3
+ @config = YAML.load_file('config/config.yml')
4
+ browser = @config['browser'].to_sym
5
+ @driver = Selenium::WebDriver.for(browser, capabilities: browser_options(*opts))
6
+ end
7
7
 
8
- def browser_options(*opts)
9
- opts = opts.empty? ? @config['browser_options'] : opts
10
- create_options(*opts)
11
- end
8
+ def browser_options(*opts)
9
+ opts = opts.empty? ? @config['browser_options'] : opts
10
+ create_options(*opts)
11
+ end
12
12
 
13
- def create_options(*opts)
14
- browser = @config['browser'] == :ie ? @config['browser'].to_s.upcase : @config['browser'].to_s.capitalize
15
- caps = "Selenium::WebDriver::#{browser}::Options".constantize.new
16
- opts.each {|option| caps.add_argument(option) }
17
- caps
18
- end
19
- <% elsif automation == 'cross_platform' %>
20
- def new_driver
21
- platform = config['platform'].to_s
22
- @driver = Appium::Driver.new({ caps: caps[platform] })
23
- end
24
- <% else %>
25
- def new_driver
26
- @driver = Appium::Driver.new({ caps: caps })
27
- end
28
- <% end %>
13
+ def create_options(*opts)
14
+ browser = @config['browser'] == :ie ? @config['browser'].to_s.upcase : @config['browser'].to_s.capitalize
15
+ caps = "Selenium::WebDriver::#{browser}::Options".constantize.new
16
+ opts.each { |option| caps.add_argument(option) }
17
+ caps
18
+ end
19
+ <% elsif automation == 'cross_platform' -%>
20
+ def new_driver
21
+ platform = config['platform'].to_s
22
+ @driver = Appium::Driver.new({ caps: caps[platform] })
23
+ end
24
+ <% else -%>
25
+ def new_driver
26
+ @driver = Appium::Driver.new({ caps: caps })
27
+ end
28
+ <% end -%>
@@ -10,8 +10,13 @@ module Raider
10
10
  <% else -%>
11
11
  require_relative 'driver_helper'
12
12
  <% end -%>
13
+ <% unless visual_automation -%>
13
14
  require_relative 'allure_helper'
15
+ <% end -%>
14
16
  <% if automation == 'cross_platform' -%>
15
17
  require_relative 'appium_helper'
16
18
  <% end -%>
19
+ <% if visual_automation -%>
20
+ require_relative 'visual_helper'
21
+ <% end -%>
17
22
  end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eyes_selenium'
4
+ require 'yaml'
5
+
6
+ module Raider
7
+ module VisualHelper
8
+ attr_reader :eyes
9
+
10
+ SELENIUM = Applitools::Selenium
11
+ VISUAL_GRID = SELENIUM::VisualGridRunner
12
+ EYES = SELENIUM::Eyes
13
+ TARGET = SELENIUM::Target
14
+ BATCHINFO = Applitools::BatchInfo
15
+ REGTANGLE_SIZE = Applitools::RectangleSize
16
+
17
+ def create_grid_runner(concurrency = 1)
18
+ VISUAL_GRID.new(concurrency)
19
+ end
20
+
21
+ def create_eyes(grid_runner)
22
+ EYES.new(runner: grid_runner)
23
+ end
24
+
25
+ def check_page(page)
26
+ page = format_page(page)
27
+ @eyes.check(page, TARGET.window.fully)
28
+ end
29
+
30
+ def configure_eyes(eyes, options = nil)
31
+ options ||= YAML.load_file('config/options.yml')
32
+
33
+ eyes.configure do |conf|
34
+ # You can get your api key from the Applitools dashboard
35
+ general_config(options, conf)
36
+ add_browsers(options[:browsers], conf)
37
+ add_devices(options[:devices], conf)
38
+ end
39
+ end
40
+
41
+ def format_page(page)
42
+ page.instance_of?(String) ? page : page.to_s
43
+ end
44
+
45
+ def add_browsers(browsers, conf)
46
+ browsers.each do |browser|
47
+ conf.add_browser(browser[:height], browser[:width], "BrowserType::#{browser[:name].upcase}".constantize)
48
+ end
49
+ end
50
+
51
+ def add_devices(devices, conf)
52
+ devices.each do |device|
53
+ conf.add_device_emulation("Devices::#{device[:name]}".constantize,
54
+ "Orientation::#{device[:orientation]}".constantize)
55
+ end
56
+ end
57
+
58
+ def general_config(options, conf)
59
+ conf.api_key = ENV['APPLITOOLS_API_KEY']
60
+ conf.batch = BATCHINFO.new(options[:batch_name])
61
+ conf.app_name = options[:app_name]
62
+ conf.test_name = options[:test_name]
63
+ conf.viewport_size = REGTANGLE_SIZE.new(options[:viewport_size][:height], options[:viewport_size][:width])
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rspec'
4
+ require 'eyes_selenium'
5
+ require_relative 'driver_helper'
6
+ require_relative 'visual_helper'
7
+
8
+ module Raider
9
+ module SpecHelper
10
+ RSpec.configure do |config|
11
+ config.include(DriverHelper)
12
+ config.include(VisualHelper)
13
+ config.before(:each) do
14
+ OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
15
+ @grid_runner = create_grid_runner
16
+ @eyes = create_eyes(@grid_runner)
17
+ configure_eyes @eyes
18
+ @driver = @eyes.open(driver: new_driver)
19
+ end
20
+
21
+ config.after(:each) do
22
+ @eyes.close
23
+ @driver.quit
24
+ @eyes.abort_async
25
+ results = @grid_runner.get_all_test_results
26
+ puts results
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,4 +1,26 @@
1
- <% if %w[selenium watir].include? automation -%>
1
+ <% if automation == 'selenium' && visual_automation == true %>
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'base_spec'
5
+ require_relative '../page_objects/pages/login_page'
6
+ require_relative '../page_objects/pages/app_page'
7
+
8
+ describe 'Login Page' do
9
+ let(:app_page) { AppPage.new(@driver) }
10
+ let(:login_page) { LoginPage.new(@driver) }
11
+
12
+ before(:example) do
13
+ login_page.visit
14
+ end
15
+
16
+ it 'looks as expected' do
17
+ check_page login_page
18
+ login_page.login
19
+ check_page app_page
20
+ end
21
+ end
22
+
23
+ <% elsif %w[selenium watir].include? automation -%>
2
24
  require_relative 'base_spec'
3
25
  require_relative '../page_objects/pages/login_page'
4
26
 
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'yaml'
4
+ require 'open-uri'
4
5
 
5
6
  class Utilities
6
7
  def initialize
@@ -58,7 +59,7 @@ class Utilities
58
59
  system "#{command} #{opts}"
59
60
  end
60
61
 
61
- def parallel_run(opts = nil)
62
+ def parallel_run(opts = nil, _settings = nil)
62
63
  command = File.directory?('spec') ? 'parallel_rspec spec/' : 'parallel_cucumber features'
63
64
  system "#{command} #{opts}"
64
65
  end
@@ -66,4 +67,38 @@ class Utilities
66
67
  def overwrite_yaml
67
68
  File.open(@path, 'w') { |file| YAML.dump(@config, file) }
68
69
  end
70
+
71
+ def version
72
+ spec_version = Gem::Specification.load('ruby_raider.gemspec').version
73
+ puts "The Ruby Raider version is #{spec_version}, Happy testing!"
74
+ end
75
+
76
+ def download_builds(build_type)
77
+ case build_type
78
+ when 'android'
79
+ download_android_build
80
+ when 'ios'
81
+ download_ios_build
82
+ else
83
+ download_android_build
84
+ download_ios_build
85
+ end
86
+ end
87
+
88
+ private
89
+
90
+ def download_android_build
91
+ download_build('Android-MyDemoAppRN.1.3.0.build-244.apk',
92
+ 'https://github.com/saucelabs/my-demo-app-rn/releases/download/v1.3.0/Android-MyDemoAppRN.1.3.0.build-244.apk')
93
+ end
94
+
95
+ def download_ios_build
96
+ download_build('iOS-Simulator-MyRNDemoApp.1.3.0-162.zip',
97
+ 'https://github.com/saucelabs/my-demo-app-rn/releases/download/v1.3.0/iOS-Simulator-MyRNDemoApp.1.3.0-162.zip')
98
+ end
99
+ def download_build(name, url)
100
+ open(name, 'wb') do |file|
101
+ file << open(url).read
102
+ end
103
+ end
69
104
  end
data/ruby_raider.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'ruby_raider'
5
- s.version = '0.4.3'
5
+ s.version = '0.4.5'
6
6
  s.summary = 'A gem to make setup and start of UI automation projects easier'
7
7
  s.description = 'This gem has everything you need to start working with test automation'
8
8
  s.authors = ['Agustin Pequeno']
@@ -71,8 +71,4 @@ describe AutomationGenerator do
71
71
  context 'with cucumber and appium cross platform' do
72
72
  include_examples 'creates mobile automation files', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.last}"
73
73
  end
74
-
75
- context 'with cucumber and appium cross platform' do
76
- include_examples 'creates mobile automation files', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.last}"
77
- end
78
74
  end
@@ -32,7 +32,7 @@ describe CommonGenerator do
32
32
 
33
33
  shared_examples "doesn't create a config file" do |name|
34
34
  it "doesn't create a config file" do
35
- expect(File).to_not exist("#{name}/config/config.yml")
35
+ expect(File).not_to exist("#{name}/config/config.yml")
36
36
  end
37
37
  end
38
38
 
data/spec/spec_helper.rb CHANGED
@@ -11,7 +11,7 @@ RSpec.configure do |config|
11
11
  config.before(:all) do
12
12
  FRAMEWORKS.each do |framework|
13
13
  AUTOMATION_TYPES.each do |automation|
14
- MenuGenerator.new("#{framework}_#{automation}").generate_framework(automation, framework)
14
+ MenuGenerator.new("#{framework}_#{automation}").generate_framework(automation, framework, false)
15
15
  end
16
16
  end
17
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_raider
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Agustin Pequeno
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-25 00:00:00.000000000 Z
11
+ date: 2022-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -155,6 +155,7 @@ files:
155
155
  - lib/generators/rspec_generator.rb
156
156
  - lib/generators/templates/automation/abstract_component.tt
157
157
  - lib/generators/templates/automation/abstract_page.tt
158
+ - lib/generators/templates/automation/app_page.tt
158
159
  - lib/generators/templates/automation/appium_caps.tt
159
160
  - lib/generators/templates/automation/component.tt
160
161
  - lib/generators/templates/automation/home_page.tt
@@ -170,8 +171,10 @@ files:
170
171
  - lib/generators/templates/automation/partials/selenium_login.tt
171
172
  - lib/generators/templates/automation/partials/url_methods.tt
172
173
  - lib/generators/templates/automation/partials/visit_method.tt
174
+ - lib/generators/templates/automation/partials/visual_login.tt
173
175
  - lib/generators/templates/automation/partials/watir_login.tt
174
176
  - lib/generators/templates/automation/pdp_page.tt
177
+ - lib/generators/templates/automation/visual_options.tt
175
178
  - lib/generators/templates/common/config.tt
176
179
  - lib/generators/templates/common/gemfile.tt
177
180
  - lib/generators/templates/common/partials/automation_gems.tt
@@ -204,6 +207,8 @@ files:
204
207
  - lib/generators/templates/helpers/raider_helper.tt
205
208
  - lib/generators/templates/helpers/selenium_helper.tt
206
209
  - lib/generators/templates/helpers/spec_helper.tt
210
+ - lib/generators/templates/helpers/visual_helper.tt
211
+ - lib/generators/templates/helpers/visual_spec_helper.tt
207
212
  - lib/generators/templates/rspec/base_spec.tt
208
213
  - lib/generators/templates/rspec/spec.tt
209
214
  - lib/ruby_raider.rb
@@ -240,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
245
  - !ruby/object:Gem::Version
241
246
  version: '0'
242
247
  requirements: []
243
- rubygems_version: 3.3.7
248
+ rubygems_version: 3.3.3
244
249
  signing_key:
245
250
  specification_version: 4
246
251
  summary: A gem to make setup and start of UI automation projects easier