ruby_raider 0.3.9 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -1
  3. data/Rakefile +2 -2
  4. data/lib/commands/utility_commands.rb +2 -2
  5. data/lib/generators/automation_generator.rb +14 -10
  6. data/lib/generators/cucumber_generator.rb +10 -2
  7. data/lib/generators/menu_generator.rb +2 -2
  8. data/lib/generators/rspec_generator.rb +9 -1
  9. data/lib/generators/templates/automation/abstract_component.tt +2 -0
  10. data/lib/generators/templates/automation/abstract_page.tt +0 -1
  11. data/lib/generators/templates/automation/appium_settings.tt +5 -8
  12. data/lib/generators/templates/automation/component.tt +1 -1
  13. data/lib/generators/templates/automation/home_page.tt +9 -5
  14. data/lib/generators/templates/automation/login_page.tt +0 -2
  15. data/lib/generators/templates/automation/partials/android_settings.tt +8 -0
  16. data/lib/generators/templates/automation/partials/element.tt +3 -3
  17. data/lib/generators/templates/automation/partials/initialize_selector.tt +4 -0
  18. data/lib/generators/templates/automation/partials/ios_settings.tt +8 -0
  19. data/lib/generators/templates/automation/partials/selenium_login.tt +3 -3
  20. data/lib/generators/templates/automation/partials/watir_login.tt +3 -3
  21. data/lib/generators/templates/automation/pdp_page.tt +22 -0
  22. data/lib/generators/templates/cucumber/feature.tt +9 -0
  23. data/lib/generators/templates/cucumber/partials/appium_env.tt +7 -5
  24. data/lib/generators/templates/cucumber/partials/driver_world.tt +1 -0
  25. data/lib/generators/templates/cucumber/partials/mobile_steps.tt +8 -11
  26. data/lib/generators/templates/cucumber/partials/watir_world.tt +1 -0
  27. data/lib/generators/templates/cucumber/partials/web_steps.tt +1 -1
  28. data/lib/generators/templates/cucumber/world.tt +5 -0
  29. data/lib/generators/templates/helpers/driver_helper.tt +0 -1
  30. data/lib/generators/templates/helpers/partials/select_driver.tt +5 -4
  31. data/lib/generators/templates/rspec/spec.tt +8 -13
  32. data/ruby_raider.gemspec +1 -1
  33. data/spec/automation_generator_spec.rb +87 -84
  34. data/spec/rspec_generator_spec.rb +22 -3
  35. metadata +8 -4
  36. data/lib/generators/templates/automation/confirmation_page.tt +0 -19
  37. data/lib/generators/templates/automation/partials/appium_login.tt +0 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 142c09c13840d275edad19efb9ea01393831acdeb996848033af48624a535eb3
4
- data.tar.gz: 485fdcefeac72106e05027c452beedeef727ca63b105d7e4c8d63056f783c74a
3
+ metadata.gz: 717ea9978a9909bc5d4d78f717b8da94ebc7e76945ec638ceeb35bb9aa5a9281
4
+ data.tar.gz: f6f390ee74bc484a763e4e0daf8f4cd08a5e8ed630d5284656a18efc0bffe91d
5
5
  SHA512:
6
- metadata.gz: ac631cb2cb6b93ae71950f278c8b8306e4dae4170858c0b65e515ceebd763b93126ee6d8f45410633bc1ef3611d3ccdec0bb69e2f47137903dcd3ce1fc394131
7
- data.tar.gz: '05874e4a92b5e7c875b42ae27bbc5e5c937bf6ee5c5678ceb084ae76697b4e2e03f5227b51c6e0a9c925d1ae861952ae822ff375a96bab193c5e8246499ec92b'
6
+ metadata.gz: 61718cc0edcd9dd89d65d25e0aa80032351921495bdcb3b4f69808e93ba448c1c859f2289e8008a94d7efd5987524fc510c8e17bc3e6a19ffa7b0dfa7828aa2c
7
+ data.tar.gz: ce72aba02cf4813232ba7c3e4b0f5ec8d7688b56194ab066d32c8cd6a95c76f5395b16c5fece33150408191d4c95e15e66dd929d1eab497beb0bd28ed895c87f
data/README.md CHANGED
@@ -43,7 +43,11 @@ Ruby Raider is a generator and scaffolding gem to make UI test automation easier
43
43
 
44
44
  * Generating a framework with Cucumber and Appium for IOS
45
45
 
46
- ***In order to run the Appium tests, download the example [app](https://github.com/cloudgrey-io/the-app/releases/tag/v1.10.0).***
46
+ * Generating a framework with Rspec and Appium for Android
47
+
48
+ * Generating a framework with Cucumber and Appium for Android
49
+
50
+ ***In order to run the Appium tests, download the example [app](https://github.com/saucelabs/my-demo-app-rn).***
47
51
 
48
52
  This works in all the platforms (Tested on Mac OS, Linux and Windows).
49
53
 
data/Rakefile CHANGED
@@ -4,8 +4,8 @@ require_relative 'lib/ruby_raider'
4
4
  require_relative 'lib/commands/scaffolding_commands'
5
5
 
6
6
  desc 'Creates a new test project'
7
- task :new do
8
- RubyRaider.start
7
+ task :new, [:name] do |_t, args|
8
+ system "bin/raider -n #{args.name}"
9
9
  end
10
10
 
11
11
  desc 'Creates a page'
@@ -59,9 +59,9 @@ class UtilityCommands < Thor
59
59
 
60
60
  def raid
61
61
  if options[:parallel]
62
- Utilities.new.run(options[:opts])
63
- else
64
62
  Utilities.new.parallel_run(options[:opts])
63
+ else
64
+ Utilities.new.run(options[:opts])
65
65
  end
66
66
  end
67
67
 
@@ -4,6 +4,8 @@ require_relative 'generator'
4
4
 
5
5
  class AutomationGenerator < Generator
6
6
  def generate_login_page
7
+ return unless (@_initializer.first & %w[android ios]).empty?
8
+
7
9
  template('automation/login_page.tt', "#{name}/page_objects/pages/login_page.rb")
8
10
  end
9
11
 
@@ -12,30 +14,32 @@ class AutomationGenerator < Generator
12
14
  end
13
15
 
14
16
  def generate_home_page
15
- return unless @_initializer.first.include?('appium_ios')
17
+ return if (@_initializer.first & %w[android ios]).empty?
16
18
 
17
19
  template('automation/home_page.tt', "#{name}/page_objects/pages/home_page.rb")
18
20
  end
19
21
 
22
+ def generate_pdp_page
23
+ return if (@_initializer.first & %w[android ios]).empty?
24
+
25
+ template('automation/pdp_page.tt', "#{name}/page_objects/pages/pdp_page.rb")
26
+ end
27
+
20
28
  def generate_header_component
21
- return if @_initializer.first.include?('appium_ios')
29
+ return unless (@_initializer.first & %w[android ios]).empty?
22
30
 
23
31
  template('automation/component.tt', "#{name}/page_objects/components/header_component.rb")
24
32
  end
25
33
 
26
34
  def generate_abstract_component
27
- return if @_initializer.first.include?('appium_ios')
35
+ return unless (@_initializer.first & %w[android ios]).empty?
28
36
 
29
37
  template('automation/abstract_component.tt', "#{name}/page_objects/abstract/abstract_component.rb")
30
38
  end
31
39
 
32
- def generate_confirmation_page
33
- return unless @_initializer.first.include?('appium_ios')
34
-
35
- template('automation/confirmation_page.tt', "#{name}/page_objects/pages/confirmation_page.rb")
36
- end
37
-
38
40
  def generate_appium_settings
39
- template('automation/appium_settings.tt', "#{name}/appium.txt") if @_initializer.first.include?('appium_ios')
41
+ return if (@_initializer.first & %w[android ios]).empty?
42
+
43
+ template('automation/appium_settings.tt', "#{name}/appium.txt")
40
44
  end
41
45
  end
@@ -4,14 +4,22 @@ require_relative 'generator'
4
4
 
5
5
  class CucumberGenerator < Generator
6
6
  def generate_feature
7
- template('cucumber/feature.tt', "#{name}/features/login.feature")
7
+ template('cucumber/feature.tt', "#{name}/features/#{template_name}.feature")
8
8
  end
9
9
 
10
10
  def generate_steps
11
- template('cucumber/steps.tt', "#{name}/features/step_definitions/login_steps.rb")
11
+ template('cucumber/steps.tt', "#{name}/features/step_definitions/#{template_name}_steps.rb")
12
12
  end
13
13
 
14
14
  def generate_env_file
15
15
  template('cucumber/env.tt', "#{name}/features/support/env.rb")
16
16
  end
17
+
18
+ def generate_world
19
+ template('cucumber/world.tt', "#{name}/world.rb")
20
+ end
21
+
22
+ def template_name
23
+ @template_name ||= (@_initializer.first & %w[android ios]).empty? ? 'login' : 'home'
24
+ end
17
25
  end
@@ -39,8 +39,8 @@ class MenuGenerator
39
39
 
40
40
  def choose_mobile_platform
41
41
  prompt.select('Please select your mobile platform') do |menu|
42
- menu.choice :iOS, -> { choose_test_framework 'appium_ios' }
43
- menu.choice :Android, -> { error_handling('Android') }
42
+ menu.choice :iOS, -> { choose_test_framework 'ios' }
43
+ menu.choice :Android, -> { choose_test_framework 'android' }
44
44
  menu.choice :Cross_Platform, -> { error_handling('Cross Platform') }
45
45
  menu.choice :Quit, -> { exit }
46
46
  end
@@ -3,10 +3,18 @@
3
3
  require_relative 'generator'
4
4
 
5
5
  class RspecGenerator < Generator
6
- def generate_spec
6
+ def generate_login_spec
7
+ return unless (@_initializer.first & %w[android ios]).empty?
8
+
7
9
  template('rspec/spec.tt', "#{name}/spec/login_page_spec.rb")
8
10
  end
9
11
 
12
+ def generate_pdp_spec
13
+ return if (@_initializer.first & %w[android ios]).empty?
14
+
15
+ template('rspec/spec.tt', "#{name}/spec/pdp_page_spec.rb")
16
+ end
17
+
10
18
  def generate_base_spec
11
19
  template('rspec/base_spec.tt', "#{name}/spec/base_spec.rb")
12
20
  end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class AbstractComponent
4
+ attr_reader :component
5
+
4
6
  def initialize(component)
5
7
  @component = component
6
8
  end
@@ -1,4 +1,3 @@
1
- require 'yaml'
2
1
  <%= ERB.new(File.read(File.expand_path('./partials/require_raider.tt', __dir__)), nil, '-').result(binding) -%>
3
2
 
4
3
  class AbstractPage
@@ -1,8 +1,5 @@
1
- [caps]
2
- platformName = "iOS"
3
- platformVersion = "15.5"
4
- deviceName = "iPhone SE (3rd generation)"
5
- app = "TheApp.app"
6
-
7
- [appium_lib]
8
- server_url = "http://127.0.0.1:4723/wd/hub"
1
+ <% if automation == 'ios' %>
2
+ <%= ERB.new(File.read(File.expand_path('./partials/ios_settings.tt', __dir__))).result(binding) -%>
3
+ <% else %>
4
+ <%= ERB.new(File.read(File.expand_path('./partials/android_settings.tt', __dir__))).result(binding) -%>
5
+ <% end %>
@@ -4,6 +4,6 @@ require_relative '../abstract/abstract_component'
4
4
 
5
5
  class HeaderComponent < AbstractComponent
6
6
  def customer_name
7
- @component.text
7
+ component.text
8
8
  end
9
9
  end
@@ -4,17 +4,21 @@ require_relative '../abstract/abstract_page'
4
4
 
5
5
  class HomePage < AbstractPage
6
6
 
7
- #Actions
7
+ # Actions
8
8
 
9
- def go_to_login
10
- @driver.wait { login_button_navigator }.click
9
+ def go_to_backpack_pdp
10
+ driver.wait { backpack_image }.click
11
11
  end
12
12
 
13
13
  private
14
14
 
15
15
  # Elements
16
16
 
17
- def login_button_navigator
18
- @driver.find_element(accessibility_id: 'Login Screen')
17
+ def backpack_image
18
+ <% if automation == 'ios' %>
19
+ driver.find_element(predicate: 'label == "Sauce Labs Backpack"')
20
+ <% else %>
21
+ driver.find_element(xpath: '(//android.view.ViewGroup[@content-desc="store item"])[1]/android.view.ViewGroup[1]')
22
+ <% end %>
19
23
  end
20
24
  end
@@ -3,6 +3,4 @@
3
3
  <%= ERB.new(File.read(File.expand_path('./partials/selenium_login.tt', __dir__))).result(binding) %>
4
4
  <% when 'watir' -%>
5
5
  <%= ERB.new(File.read(File.expand_path('./partials/watir_login.tt', __dir__))).result(binding) %>
6
- <% else -%>
7
- <%= ERB.new(File.read(File.expand_path('./partials/appium_login.tt', __dir__))).result(binding) %>
8
6
  <% end -%>
@@ -0,0 +1,8 @@
1
+ [caps]
2
+ automationName = "UiAutomator2"
3
+ platformName = "Android"
4
+ deviceName = "Nexus_7_API_33"
5
+ app = "Android-MyDemoAppRN.1.3.0.build-244.apk"
6
+
7
+ [appium_lib]
8
+ server_url = "http://127.0.0.1:4723/wd/hub"
@@ -1,5 +1,5 @@
1
- <% if %w[selenium appium_ios].include?(automation) -%>
2
- @driver.find_element
1
+ <% if %w[selenium appium_ios appium_android].include?(automation) -%>
2
+ driver.find_element
3
3
  <% else -%>
4
- @browser.element
4
+ browser.element
5
5
  <% end -%>
@@ -1,8 +1,12 @@
1
1
  <% if automation == 'watir' %>
2
+ attr_reader :browser
3
+
2
4
  def initialize(browser)
3
5
  @browser = browser
4
6
  end
5
7
  <% else %>
8
+ attr_reader :driver
9
+
6
10
  def initialize(driver)
7
11
  @driver = driver
8
12
  end
@@ -0,0 +1,8 @@
1
+ [caps]
2
+ platformName = "iOS"
3
+ platformVersion = "16.0"
4
+ deviceName = "iPhone SE (3rd generation)"
5
+ app = "MyRNDemoApp.app"
6
+
7
+ [appium_lib]
8
+ server_url = "http://127.0.0.1:4723/wd/hub"
@@ -27,14 +27,14 @@ class LoginPage < AbstractPage
27
27
  # Elements
28
28
 
29
29
  def username_field
30
- @driver.find_element(id: 'loginFrm_loginname')
30
+ driver.find_element(id: 'loginFrm_loginname')
31
31
  end
32
32
 
33
33
  def password_field
34
- @driver.find_element(id: 'loginFrm_password')
34
+ driver.find_element(id: 'loginFrm_password')
35
35
  end
36
36
 
37
37
  def login_button
38
- @driver.find_element(xpath: "//button[@title='Login']")
38
+ driver.find_element(xpath: "//button[@title='Login']")
39
39
  end
40
40
  end
@@ -26,14 +26,14 @@ class LoginPage < AbstractPage
26
26
  # Elements
27
27
 
28
28
  def username_field
29
- @browser.text_field(id: 'loginFrm_loginname')
29
+ browser.text_field(id: 'loginFrm_loginname')
30
30
  end
31
31
 
32
32
  def password_field
33
- @browser.text_field(id: 'loginFrm_password')
33
+ browser.text_field(id: 'loginFrm_password')
34
34
  end
35
35
 
36
36
  def login_button
37
- @browser.button(xpath: "//button[@title='Login']")
37
+ browser.button(xpath: "//button[@title='Login']")
38
38
  end
39
39
  end
@@ -0,0 +1,22 @@
1
+ require_relative '../abstract/abstract_page'
2
+
3
+ class PdpPage < AbstractPage
4
+
5
+ # Actions
6
+
7
+ def add_to_cart_text
8
+ driver.wait { add_to_cart_button }.text
9
+ end
10
+
11
+ private
12
+
13
+ # Elements
14
+
15
+ def add_to_cart_button
16
+ <% if automation == 'ios' %>
17
+ driver.find_element(accessibility_id: 'Add To Cart button')
18
+ <% else %>
19
+ driver.find_element(xpath: '//android.view.ViewGroup[@content-desc="Add To Cart button"]/android.widget.TextView')
20
+ <% end %>
21
+ end
22
+ end
@@ -1,6 +1,15 @@
1
+ <% if %w[selenium watir].include? automation -%>
1
2
  Feature: Login Page
2
3
 
3
4
  Scenario: A user can login
4
5
  Given I'm a registered user on the login page
5
6
  When I login with my credentials
6
7
  Then I can see the main page
8
+ <% else -%>
9
+ Feature: Home Page
10
+
11
+ Scenario: A user can go to the product details page
12
+ Given I'm an anonymous user on the home page
13
+ When I select one of the products
14
+ Then I'm redirected to the product details page
15
+ <% end %>
@@ -1,13 +1,15 @@
1
1
  require_relative '../../helpers/driver_helper'
2
2
 
3
+ include Raider::DriverHelper
4
+
3
5
  Before do
4
6
  Raider::AllureHelper.configure
5
- @driver = Raider::DriverHelper.new_driver
6
- @driver.start_driver
7
+ new_driver
8
+ driver.start_driver
7
9
  end
8
10
 
9
11
  After do |scenario|
10
- @driver.screenshot("allure-results/screenshots/#{scenario.name}.png")
12
+ driver.screenshot("allure-results/screenshots/#{scenario.name}.png")
11
13
  Raider::AllureHelper.add_screenshot(scenario.name)
12
- @driver.quit_driver
13
- end
14
+ driver.quit_driver
15
+ end
@@ -0,0 +1 @@
1
+ World(DriverHelper)
@@ -1,20 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../page_objects/pages/confirmation_page'
4
3
  require_relative '../../page_objects/pages/home_page'
5
- require_relative '../../page_objects/pages/login_page'
4
+ require_relative '../../page_objects/pages/pdp_page'
6
5
 
7
- Given("I'm a registered user on the login page") do
8
- home_page = HomePage.new(@driver)
9
- home_page.go_to_login
6
+ Given("I'm an anonymous user on the home page") do
7
+ @home_page = HomePage.new(driver)
10
8
  end
11
9
 
12
- When('I login with my credentials') do
13
- login_page = LoginPage.new(@driver)
14
- login_page.login('alice', 'mypassword')
10
+ When('I select one of the products') do
11
+ @home_page.go_to_backpack_pdp
15
12
  end
16
13
 
17
- When('I can see the main page') do
18
- confirmation_page = ConfirmationPage.new(@driver)
19
- expect(confirmation_page.login_message).to eq 'You are logged in as alice'
14
+ When("I'm redirected to the product details page") do
15
+ pdp_page = PdpPage.new(driver)
16
+ expect(pdp_page.add_to_cart_text).to eq 'Add To Cart'
20
17
  end
@@ -0,0 +1 @@
1
+ World(BrowserHelper)
@@ -3,7 +3,7 @@
3
3
  require_relative '../../page_objects/pages/login_page'
4
4
 
5
5
  Given("I'm a registered user on the login page") do
6
- @login_page = LoginPage.new(<% if automation == 'watir'%>@browser<% else %>@driver<% end %>)
6
+ @login_page = LoginPage.new(<% if automation == 'watir'%>browser<% else %>driver<% end %>)
7
7
  @login_page.visit
8
8
  end
9
9
 
@@ -0,0 +1,5 @@
1
+ <% if %w[watir].include? automation -%>
2
+ <%= ERB.new(File.read(File.expand_path('./partials/watir_world.tt', __dir__))).result(binding).strip! -%>
3
+ <% else -%>
4
+ <%= ERB.new(File.read(File.expand_path('./partials/driver_world.tt', __dir__))).result(binding).strip! -%>
5
+ <% end -%>
@@ -6,7 +6,6 @@ require 'webdrivers'
6
6
  <% else -%>
7
7
  require 'appium_lib'
8
8
  <% end -%>
9
- require_relative 'driver_helper'
10
9
 
11
10
  module Raider
12
11
  module DriverHelper
@@ -1,8 +1,9 @@
1
- <% if automation == 'watir' %>
1
+ <% case automation
2
+ when 'selenium' %>
3
+ new_driver
4
+ <% when 'watir' %>
2
5
  new_browser
3
6
  <% else %>
4
7
  new_driver
5
- <% end %>
6
- <% if %w[appium_ios].include? automation %>
7
- start_driver
8
+ driver.start_driver
8
9
  <% end %>
@@ -29,24 +29,19 @@ describe 'Login' do
29
29
  end
30
30
  end
31
31
  <% else -%>
32
- require_relative '../page_objects/pages/confirmation_page'
33
32
  require_relative '../page_objects/pages/home_page'
34
33
  require_relative 'base_spec'
35
- require_relative '../page_objects/pages/login_page'
34
+ require_relative '../page_objects/pages/pdp_page'
36
35
 
37
- class LoginSpec < BaseSpec
38
- describe 'Login' do
36
+ class PdpSpec < BaseSpec
37
+ describe 'PDP page' do
39
38
 
40
- let(:user_name) { 'alice' }
41
- let(:password) { 'mypassword' }
42
- let(:login_page) { LoginPage.new(@driver) }
43
- let(:home_page) { HomePage.new(@driver) }
44
- let(:confirmation_page) { ConfirmationPage.new(@driver) }
39
+ let(:home_page) { HomePage.new(driver) }
40
+ let(:pdp_page) { PdpPage.new(driver) }
45
41
 
46
- it 'can login' do
47
- home_page.go_to_login
48
- login_page.login(user_name, password)
49
- expect(confirmation_page.login_message).to eq 'You are logged in as alice'
42
+ it 'shows add to cart button' do
43
+ home_page.go_to_backpack_pdp
44
+ expect(pdp_page.add_to_cart_text).to eq 'Add To Cart'
50
45
  end
51
46
  end
52
47
  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.3.9'
5
+ s.version = '0.4.1'
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']
@@ -58,34 +58,49 @@ describe AutomationGenerator do
58
58
  end
59
59
  end
60
60
 
61
- context 'with appium' do
61
+ context 'with rspec and appium on ios' do
62
62
  before(:all) do
63
- @name = 'rspec-appium'
64
- AutomationGenerator.new(['appium_ios', 'rspec', @name]).invoke_all
63
+ @name = 'rspec-appium-ios'
64
+ AutomationGenerator.new(['ios', 'rspec', @name]).invoke_all
65
65
  end
66
66
 
67
- it 'creates a login page file' do
68
- expect(File.exist?("#{@name}/page_objects/pages/login_page.rb")).to be_truthy
67
+ it 'creates a home page file' do
68
+ expect(File.exist?("#{@name}/page_objects/pages/home_page.rb")).to be_truthy
69
69
  end
70
70
 
71
71
  it 'creates an abstract page file' do
72
72
  expect(File.exist?("#{@name}/page_objects/abstract/abstract_page.rb")).to be_truthy
73
73
  end
74
74
 
75
- it "doesn't creates an abstract component file" do
76
- expect(File.exist?("#{@name}/page_objects/abstract/abstract_component.rb")).to be_falsey
75
+ it 'creates a pdp page file' do
76
+ expect(File.exist?("#{@name}/page_objects/pages/pdp_page.rb")).to be_truthy
77
77
  end
78
78
 
79
- it "doesn't creates a component file" do
80
- expect(File.exist?("#{@name}/page_objects/components/header_component.rb")).to be_falsey
79
+ it 'creates an appium config file' do
80
+ expect(File.exist?("#{@name}/appium.txt")).to be_truthy
81
81
  end
82
82
 
83
- it 'creates a login page file' do
83
+ after(:all) do
84
+ FileUtils.rm_rf(@name)
85
+ end
86
+ end
87
+
88
+ context 'with rspec and appium on android' do
89
+ before(:all) do
90
+ @name = 'rspec-appium-android'
91
+ AutomationGenerator.new(['android', 'rspec', @name]).invoke_all
92
+ end
93
+
94
+ it 'creates a home page file' do
84
95
  expect(File.exist?("#{@name}/page_objects/pages/home_page.rb")).to be_truthy
85
96
  end
86
97
 
87
- it 'creates a confirmation page file' do
88
- expect(File.exist?("#{@name}/page_objects/pages/confirmation_page.rb")).to be_truthy
98
+ it 'creates an abstract page file' do
99
+ expect(File.exist?("#{@name}/page_objects/abstract/abstract_page.rb")).to be_truthy
100
+ end
101
+
102
+ it 'creates a pdp page file' do
103
+ expect(File.exist?("#{@name}/page_objects/pages/pdp_page.rb")).to be_truthy
89
104
  end
90
105
 
91
106
  it 'creates an appium config file' do
@@ -95,98 +110,86 @@ describe AutomationGenerator do
95
110
  after(:all) do
96
111
  FileUtils.rm_rf(@name)
97
112
  end
113
+ end
98
114
 
99
- context 'with cucumber and selenium' do
100
- before(:all) do
101
- @name = 'cucumber-selenium'
102
- AutomationGenerator.new(['selenium', 'cucumber', @name]).invoke_all
103
- end
104
-
105
- it 'creates a login page file' do
106
- expect(File.exist?("#{@name}/page_objects/pages/login_page.rb")).to be_truthy
107
- end
108
-
109
- it 'creates an abstract page file' do
110
- expect(File.exist?("#{@name}/page_objects/abstract/abstract_page.rb")).to be_truthy
111
- end
112
-
113
- it 'creates an abstract component file' do
114
- expect(File.exist?("#{@name}/page_objects/abstract/abstract_component.rb")).to be_truthy
115
- end
115
+ context 'with cucumber and selenium' do
116
+ before(:all) do
117
+ @name = 'cucumber-selenium'
118
+ AutomationGenerator.new(['selenium', 'cucumber', @name]).invoke_all
119
+ end
116
120
 
117
- it 'creates a component file' do
118
- expect(File.exist?("#{@name}/page_objects/components/header_component.rb")).to be_truthy
119
- end
121
+ it 'creates a login page file' do
122
+ expect(File.exist?("#{@name}/page_objects/pages/login_page.rb")).to be_truthy
123
+ end
120
124
 
121
- after(:all) do
122
- FileUtils.rm_rf(@name)
123
- end
125
+ it 'creates an abstract page file' do
126
+ expect(File.exist?("#{@name}/page_objects/abstract/abstract_page.rb")).to be_truthy
124
127
  end
125
128
 
126
- context 'with cucumber and watir' do
127
- before(:all) do
128
- @name = 'cucumber-watir'
129
- AutomationGenerator.new(['watir', 'cucumber', @name]).invoke_all
130
- end
129
+ it 'creates an abstract component file' do
130
+ expect(File.exist?("#{@name}/page_objects/abstract/abstract_component.rb")).to be_truthy
131
+ end
131
132
 
132
- it 'creates a login page file' do
133
- expect(File.exist?("#{@name}/page_objects/pages/login_page.rb")).to be_truthy
134
- end
133
+ it 'creates a component file' do
134
+ expect(File.exist?("#{@name}/page_objects/components/header_component.rb")).to be_truthy
135
+ end
135
136
 
136
- it 'creates an abstract page file' do
137
- expect(File.exist?("#{@name}/page_objects/abstract/abstract_page.rb")).to be_truthy
138
- end
137
+ after(:all) do
138
+ FileUtils.rm_rf(@name)
139
+ end
140
+ end
139
141
 
140
- it 'creates an abstract component file' do
141
- expect(File.exist?("#{@name}/page_objects/abstract/abstract_component.rb")).to be_truthy
142
- end
142
+ context 'with cucumber and watir' do
143
+ before(:all) do
144
+ @name = 'cucumber-watir'
145
+ AutomationGenerator.new(['watir', 'cucumber', @name]).invoke_all
146
+ end
143
147
 
144
- it 'creates a component file' do
145
- expect(File.exist?("#{@name}/page_objects/components/header_component.rb")).to be_truthy
146
- end
148
+ it 'creates a login page file' do
149
+ expect(File.exist?("#{@name}/page_objects/pages/login_page.rb")).to be_truthy
150
+ end
147
151
 
148
- after(:all) do
149
- FileUtils.rm_rf(@name)
150
- end
152
+ it 'creates an abstract page file' do
153
+ expect(File.exist?("#{@name}/page_objects/abstract/abstract_page.rb")).to be_truthy
151
154
  end
152
155
 
153
- context 'with cucumber and appium' do
154
- before(:all) do
155
- @name = 'cucumber-appium'
156
- AutomationGenerator.new(['appium_ios', 'cucumber', @name]).invoke_all
157
- end
156
+ it 'creates an abstract component file' do
157
+ expect(File.exist?("#{@name}/page_objects/abstract/abstract_component.rb")).to be_truthy
158
+ end
158
159
 
159
- it 'creates a login page file' do
160
- expect(File.exist?("#{@name}/page_objects/pages/login_page.rb")).to be_truthy
161
- end
160
+ it 'creates a component file' do
161
+ expect(File.exist?("#{@name}/page_objects/components/header_component.rb")).to be_truthy
162
+ end
162
163
 
163
- it 'creates an abstract page file' do
164
- expect(File.exist?("#{@name}/page_objects/abstract/abstract_page.rb")).to be_truthy
165
- end
164
+ after(:all) do
165
+ FileUtils.rm_rf(@name)
166
+ end
167
+ end
166
168
 
167
- it "doesn't creates an abstract component file" do
168
- expect(File.exist?("#{@name}/page_objects/abstract/abstract_component.rb")).to be_falsey
169
- end
169
+ context 'with cucumber and appium' do
170
+ before(:all) do
171
+ @name = 'cucumber-appium'
172
+ AutomationGenerator.new(['ios', 'cucumber', @name]).invoke_all
173
+ end
170
174
 
171
- it "doesn't creates a component file" do
172
- expect(File.exist?("#{@name}/page_objects/components/header_component.rb")).to be_falsey
173
- end
175
+ it 'creates a home page file' do
176
+ expect(File.exist?("#{@name}/page_objects/pages/home_page.rb")).to be_truthy
177
+ end
174
178
 
175
- it 'creates a login page file' do
176
- expect(File.exist?("#{@name}/page_objects/pages/home_page.rb")).to be_truthy
177
- end
179
+ it 'creates an abstract page file' do
180
+ expect(File.exist?("#{@name}/page_objects/abstract/abstract_page.rb")).to be_truthy
181
+ end
178
182
 
179
- it 'creates a confirmation page file' do
180
- expect(File.exist?("#{@name}/page_objects/pages/confirmation_page.rb")).to be_truthy
181
- end
183
+ it 'creates a pdp page file' do
184
+ expect(File.exist?("#{@name}/page_objects/pages/pdp_page.rb")).to be_truthy
185
+ end
182
186
 
183
- it 'creates an appium config file' do
184
- expect(File.exist?("#{@name}/appium.txt")).to be_truthy
185
- end
187
+ it 'creates an appium config file' do
188
+ expect(File.exist?("#{@name}/appium.txt")).to be_truthy
189
+ end
186
190
 
187
- after(:all) do
188
- FileUtils.rm_rf(@name)
189
- end
191
+ after(:all) do
192
+ FileUtils.rm_rf(@name)
190
193
  end
191
194
  end
192
195
  end
@@ -42,14 +42,33 @@ describe RspecGenerator do
42
42
  end
43
43
  end
44
44
 
45
- context 'with appium' do
45
+ context 'with ios appium' do
46
46
  before(:all) do
47
47
  @name = 'rspec-appium'
48
- RspecGenerator.new(['appium_ios', 'rspec', @name]).invoke_all
48
+ RspecGenerator.new(['ios', 'rspec', @name]).invoke_all
49
49
  end
50
50
 
51
51
  it 'creates a spec file' do
52
- expect(File.exist?("#{@name}/spec/login_page_spec.rb")).to be_truthy
52
+ expect(File.exist?("#{@name}/spec/pdp_page_spec.rb")).to be_truthy
53
+ end
54
+
55
+ it 'creates the base spec file' do
56
+ expect(File.exist?("#{@name}/spec/base_spec.rb")).to be_truthy
57
+ end
58
+
59
+ after(:all) do
60
+ FileUtils.rm_rf(@name)
61
+ end
62
+ end
63
+
64
+ context 'with android appium' do
65
+ before(:all) do
66
+ @name = 'rspec-appium'
67
+ RspecGenerator.new(['android', 'rspec', @name]).invoke_all
68
+ end
69
+
70
+ it 'creates a spec file' do
71
+ expect(File.exist?("#{@name}/spec/pdp_page_spec.rb")).to be_truthy
53
72
  end
54
73
 
55
74
  it 'creates the base spec file' do
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.3.9
4
+ version: 0.4.1
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-09-16 00:00:00.000000000 Z
11
+ date: 2022-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -143,17 +143,18 @@ files:
143
143
  - lib/generators/templates/automation/abstract_page.tt
144
144
  - lib/generators/templates/automation/appium_settings.tt
145
145
  - lib/generators/templates/automation/component.tt
146
- - lib/generators/templates/automation/confirmation_page.tt
147
146
  - lib/generators/templates/automation/home_page.tt
148
147
  - lib/generators/templates/automation/login_page.tt
149
- - lib/generators/templates/automation/partials/appium_login.tt
148
+ - lib/generators/templates/automation/partials/android_settings.tt
150
149
  - lib/generators/templates/automation/partials/element.tt
151
150
  - lib/generators/templates/automation/partials/initialize_selector.tt
151
+ - lib/generators/templates/automation/partials/ios_settings.tt
152
152
  - lib/generators/templates/automation/partials/require_raider.tt
153
153
  - lib/generators/templates/automation/partials/selenium_login.tt
154
154
  - lib/generators/templates/automation/partials/url_methods.tt
155
155
  - lib/generators/templates/automation/partials/visit_method.tt
156
156
  - lib/generators/templates/automation/partials/watir_login.tt
157
+ - lib/generators/templates/automation/pdp_page.tt
157
158
  - lib/generators/templates/common/config.tt
158
159
  - lib/generators/templates/common/gemfile.tt
159
160
  - lib/generators/templates/common/partials/automation_gems.tt
@@ -162,11 +163,14 @@ files:
162
163
  - lib/generators/templates/cucumber/env.tt
163
164
  - lib/generators/templates/cucumber/feature.tt
164
165
  - lib/generators/templates/cucumber/partials/appium_env.tt
166
+ - lib/generators/templates/cucumber/partials/driver_world.tt
165
167
  - lib/generators/templates/cucumber/partials/mobile_steps.tt
166
168
  - lib/generators/templates/cucumber/partials/selenium_appium_env.tt
167
169
  - lib/generators/templates/cucumber/partials/watir_env.tt
170
+ - lib/generators/templates/cucumber/partials/watir_world.tt
168
171
  - lib/generators/templates/cucumber/partials/web_steps.tt
169
172
  - lib/generators/templates/cucumber/steps.tt
173
+ - lib/generators/templates/cucumber/world.tt
170
174
  - lib/generators/templates/helpers/allure_helper.tt
171
175
  - lib/generators/templates/helpers/browser_helper.tt
172
176
  - lib/generators/templates/helpers/driver_helper.tt
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../abstract/abstract_page'
4
-
5
- class ConfirmationPage < AbstractPage
6
- #Values
7
-
8
- def login_message
9
- @driver.wait { message_element }.text
10
- end
11
-
12
- private
13
-
14
- # Elements
15
-
16
- def message_element
17
- @driver.find_element(accessibility_id: 'You are logged in as alice')
18
- end
19
- end
@@ -1,28 +0,0 @@
1
- require_relative '../abstract/abstract_page'
2
-
3
- class LoginPage < AbstractPage
4
-
5
- # Actions
6
-
7
- def login(username, password)
8
- username_field.send_keys username
9
- password_field.send_keys password
10
- login_button.click
11
- end
12
-
13
- private
14
-
15
- # Elements
16
-
17
- def username_field
18
- @driver.find_element(xpath: "//XCUIElementTypeTextField[@name=\"username\"]")
19
- end
20
-
21
- def password_field
22
- @driver.find_element(xpath: "//XCUIElementTypeSecureTextField[@name=\"password\"]")
23
- end
24
-
25
- def login_button
26
- @driver.find_elements(xpath: "//XCUIElementTypeOther[@name=\"loginBtn\"]").last
27
- end
28
- end