diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..64cecf1 Binary files /dev/null and b/.DS_Store differ diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..a5b9911 --- /dev/null +++ b/Gemfile @@ -0,0 +1,11 @@ +# frozen_string_literal: true +source "https://rubygems.org" + +gem 'appium_lib' +gem 'appium_console' +gem 'pry' +gem 'cucumber' +gem 'multi_xml' +gem 'httparty' +gem 'rspec' +gem 'rest-client' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..0310fd4 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,116 @@ +GEM + remote: https://rubygems.org/ + specs: + appium_console (2.12.0) + appium_lib (~> 10.0) + bond (~> 0.5) + pry (~> 0.12.0) + spec (~> 5.3, >= 5.3.1) + thor (~> 0.19) + appium_lib (10.1.0) + appium_lib_core (~> 3.0) + nokogiri (~> 1.8, >= 1.8.1) + tomlrb (~> 1.1) + appium_lib_core (3.0.1) + faye-websocket (~> 0.10.0) + selenium-webdriver (~> 3.14, >= 3.14.1) + backports (3.12.0) + bond (0.5.1) + builder (3.2.3) + childprocess (0.9.0) + ffi (~> 1.0, >= 1.0.11) + chronic_duration (0.10.6) + numerizer (~> 0.1.1) + coderay (1.1.2) + cucumber (3.1.2) + builder (>= 2.1.2) + cucumber-core (~> 3.2.0) + cucumber-expressions (~> 6.0.1) + cucumber-wire (~> 0.0.1) + diff-lcs (~> 1.3) + gherkin (~> 5.1.0) + multi_json (>= 1.7.5, < 2.0) + multi_test (>= 0.1.2) + cucumber-core (3.2.1) + backports (>= 3.8.0) + cucumber-tag_expressions (~> 1.1.0) + gherkin (~> 5.0) + cucumber-expressions (6.0.1) + cucumber-tag_expressions (1.1.1) + cucumber-wire (0.0.1) + diff-lcs (1.3) + domain_name (0.5.20180417) + unf (>= 0.0.5, < 1.0.0) + eventmachine (1.2.7) + faye-websocket (0.10.7) + eventmachine (>= 0.12.0) + websocket-driver (>= 0.5.1) + ffi (1.10.0) + gherkin (5.1.0) + http-cookie (1.0.3) + domain_name (~> 0.5) + httparty (0.16.4) + mime-types (~> 3.0) + multi_xml (>= 0.5.2) + method_source (0.9.2) + mime-types (3.2.2) + mime-types-data (~> 3.2015) + mime-types-data (3.2018.0812) + mini_portile2 (2.4.0) + multi_json (1.13.1) + multi_test (0.1.2) + multi_xml (0.6.0) + netrc (0.11.0) + nokogiri (1.10.1) + mini_portile2 (~> 2.4.0) + numerizer (0.1.1) + pry (0.12.2) + coderay (~> 1.1.0) + method_source (~> 0.9.0) + rest-client (2.0.2) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 4.0) + netrc (~> 0.8) + rspec (3.8.0) + rspec-core (~> 3.8.0) + rspec-expectations (~> 3.8.0) + rspec-mocks (~> 3.8.0) + rspec-core (3.8.0) + rspec-support (~> 3.8.0) + rspec-expectations (3.8.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.8.0) + rspec-mocks (3.8.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.8.0) + rspec-support (3.8.0) + rubyzip (1.2.2) + selenium-webdriver (3.141.0) + childprocess (~> 0.5) + rubyzip (~> 1.2, >= 1.2.2) + spec (5.3.4) + chronic_duration (~> 0.10.2) + thor (0.20.3) + tomlrb (1.2.8) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.5) + websocket-driver (0.7.0) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.3) + +PLATFORMS + ruby + +DEPENDENCIES + appium_console + appium_lib + cucumber + httparty + multi_xml + pry + rest-client + rspec + +BUNDLED WITH + 2.0.1 diff --git a/Prova_QA.pdf b/Prova_QA.pdf index 027589d..0613650 100644 Binary files a/Prova_QA.pdf and b/Prova_QA.pdf differ diff --git a/README.md b/README.md index 7fc0c66..3d44fe0 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,46 @@ -# Show me the code +# Santander +Teste Santander Fev/2019 -### # DESAFIO: +Projeto de testes para Santander Android utilizando `Appium`, `Cucumber`, `Capybara` e `Ruby`. -Utilizando o App Cálculo Preço e Prazos Correios (https://play.google.com/store/apps/details?id=br.com.correios.calculaprecoprazo), crie testes automatizado para um dos dois fluxo (Novo Cálculo ou Cálculo Internacional) este fluxo deve ir até salvar o cálculo e consultar se o cálculo foi salvo, deve conter ao menos dois casos de sucesso e três casos de execeção (ex. validação de campos). -Tambem é necessario responder ao arquivo "Prova" que esta no repo. +# Instalação das Gems -### # Avaliação +Acessar via terminal a pasta do projeto `/automation-android` -Você será avaliado pela usabilidade, por respeitar o design e pela arquitetura dos testes. É esperado que você consiga explicar as decisões que tomou durante o desenvolvimento através de commits. +Excutar o comando: -* Ruby (gems a gosto) -* BDD, boa organização dos steps é um diferencial (ferramenta para utilizar o gherkin a seu criterio) -* Appium (ou qualquer outra, desde que justificado seu uso) -* Page Objects é um padrão obrigatório -* Uso do git +``` +bundle install +``` -### # Observações gerais -Adicione um arquivo [README.md](http://README.md) com os procedimentos para executar o projeto. -Pedimos que trabalhe sozinho e não divulgue o resultado na internet. +# Configuração do arquivo appium.txt -Faça um fork desse desse repositório em seu Github e nos envie um Pull Request com o resultado, por favor informe por qual empresa você esta se candidatando. +Altere o parametro `app` para o caminho completo do app, como em `/Users/felipefogal/workspace/Tests/Santander_TesteQA_FelipeFogal/TesteQA/calculaprecoprazo.apk`. -### # Importante: não há prazo de entrega, faça com qualidade! -# BOA SORTE! +# Execução dos Testes + +1. Iniciar o Appium +2. Abrir emulador do Android (ex: Gennymotion, Android AVD..) +3. Abrir o terminal na pasta do projeto /automation-android +4. Executar o comando: + +``` +bundle exec cucumber +``` + +# Reports + +Os relatórios são criados automaticamente na pasta `/reports` + + +# Prova QA + +As anotações dos bugs estão descritas no próprio arquivo. + + +# Commits do projeto + +Os `commits` deste projeto estão no repositório `https://github.com/felipefogal/Santander.git` \ No newline at end of file diff --git a/calculaprecoprazo.apk b/calculaprecoprazo.apk new file mode 100644 index 0000000..5c2467f Binary files /dev/null and b/calculaprecoprazo.apk differ diff --git a/caps/appium.txt b/caps/appium.txt new file mode 100644 index 0000000..826d03a --- /dev/null +++ b/caps/appium.txt @@ -0,0 +1,7 @@ +[caps] +deviceName = "emulator-5554" +platformName = "Android" +automationName = "UiAutomator" +app = "/Users/felipefogal/workspace/Tests/Santander_TesteQA_FelipeFogal/TesteQA/calculaprecoprazo.apk" + +no_reset = "false" \ No newline at end of file diff --git a/features/.DS_Store b/features/.DS_Store new file mode 100644 index 0000000..f24a525 Binary files /dev/null and b/features/.DS_Store differ diff --git a/features/screens/base_screen.rb b/features/screens/base_screen.rb new file mode 100644 index 0000000..8500e28 --- /dev/null +++ b/features/screens/base_screen.rb @@ -0,0 +1,137 @@ +#enconding: uft-8 + +class BaseScreen + def catch_for_id(id, timeout) + $driver.wait_true(timeout) { $driver.exists { $driver.find_element :id, id } } + rescue + raise "Elemento de id '#{id}' nao encontrado" + end + + def catch_for_class(class_name, timeout) + $driver.wait_true(timeout) { $driver.exists { $driver.find_element :class, class_name} } + rescue + raise "Elemento de class '#{class_name}' nao encontrado" + end + + def catch_for_name(name, timeout) + $driver.wait_true(timeout) { $driver.exists { $driver.find_element :name, name } } + rescue + raise "Elemento de name '#{name}' nao encontrado" + end + + def catch_for_xpathName(xpathName, timeout) + $driver.wait_true(timeout) { $driver.exists { $driver.find_element :xpath, "//*[@name='#{xpathName}]" } } + rescue + raise "Elemento de name '#{xpathName}' nao encontrado" + end + + def catch_for_xpath(xpath, timeout) + $driver.wait_true(timeout) { $driver.exists { $driver.find_element :xpath, xpath } } + rescue + raise "Elemento de xpath '#{xpath}' nao encontrado" + end + + def catch_for_accessibility_id(accessibility_id, timeout) + $driver.wait_true(timeout) { $driver.exists { $driver.find_elements :accessibility_id, accessibility_id } } + rescue + raise "Elemento de accessibility_id '#{accessibility_id}' nao encontrado" + end + + # VALIDACAO DE IDS QUE NAO DEVEM EXISTIR EM TELA + # COMO VARIAVEIS, INFORMAR PRIMEIRO O TIMEOUT E DEPOIS O ID DO ELEMENTO QUE NAO DEVE EXISTIR EM TELA + # EXIBE MENSAGEM DE ERRO INFORMANDO O ID QUE EH ENCONTRADO + def id_not_exists_in_screen(timeout, id) + fail("Elemento de id '#{id}' encontrado") if $driver.exists(timeout) {$driver.find_element(id: id)} == true + end + + # TESTE DE ELEMENTOS ENCADEADOS: + # 1. CHILDREN_TYPE: O TIPO DO ELEMENTO FILHO, QUE EH VALIDADO POR ULTIMO. P.EX: ID, CLASS, TEXT, ETC + # 2. CHILDREN_ELEMENT: O ELEMENTO FILHO, QUE EH VALIDADO POR ULTIMO. P.EX: dash_board_button + # 3. FATHER_TYPE: O TIPO DO ELEMENTO PAI, QUE EH VALIDADO PRIMEIRO. P.EX: ID, CLASS, TEXT, ETC + # 4. CHILDREN_ELEMENT: O ELEMENTO PAI, QUE EH VALIDADO PRIMEIRO. P.EX: dash_board_button + def test_chain_elements(children_type, children_element, father_type, father_element) + $driver.find_element("#{children_type}": children_element).find_element("#{father_type}": father_element) + end + + + def swipe_to_find_element_by_id(id, direction_to_swipe, times_to_find_element) + contador = 0 + element_already_exists = false + while ( element_already_exists == false ) + $driver.swipe direction: "#{direction_to_swipe}" + element_already_exists = $driver.exists { $driver.find_element :id, id } + if ( contador >= times_to_find_element ) + break + end + contador = (contador + 1) + end + $driver.wait_true(1) { $driver.exists { $driver.find_element :id, id} } + rescue + raise "Elemento de id '#{id}' nao encontrado depois de '#{times_to_find_element}' tentativas" + end + + def clear_element(id) + $driver.find_element(:id, id).clear + end + + def touch_element_for_class(class_name) + $driver.find_element(:class, class_name).click + end + + def touch_element_for_id(id) + $driver.find_element(:id, id).click + end + + def touch_element_for_name(name) + $driver.find_element(:name, name).click + end + + def touch_element_for_xpath(xpath) + $driver.find_element(:xpath, xpath).click + end + + def catch_id(id) + $driver.find_element :id, id + rescue + raise "Elemento de id '#{id}' nao encontrado" + end + + def catch_name(name) + $driver.find_element :name, name + rescue + raise "Elemento de name '#{name}' nao encontrado" + end + + def type_into_text_field_for_id(id, text_to_type) + @text_to_catch = catch_id id + @text_to_catch.send_keys text_to_type + end + + def type_into_text_field_for_name(name, text_to_type) + @text_to_catch = catch_name name + @text_to_catch.send_keys text_to_type + end + + # CHECAR SE ESTE METODO SO FUNCIONA EM DEVICES FISICOS + # NAO FOI POSIVEL CONCLUIR O TESTE EM SIMULADORES DO IOS + # def check_app_is_installed(bundleId, timeout) + # $driver.wait_true(timeout) { $driver.exists { $driver.app_installed? :bundleId, bundleId } } + # rescue + # raise "Elemento de name '#{bundleId}' nao encontrado" + # end + + # IMPLEMENTACAO NAO TESTADA DE ARRAYS DE IDS PARA VALIDACAO + # BY FELIPE SIMOES + # def wait_for_arrays_of_id(id, timeout) + # id.each do |nome_qualquer| + # $driver.wait_true(timeout) { $driver.exists { $driver.find_element :id, nome_qualquer } } + # end + # rescue + # raise "Elemento de id '#{id}' nao encontrado" + # end + + def test_chain_elements(children_type, children_element, father_type, father_element) + $driver.find_element("#{children_type}": children_element).find_element("#{father_type}": father_element) + end + +end diff --git a/features/screens/calc_save_screen.rb b/features/screens/calc_save_screen.rb new file mode 100644 index 0000000..aa440be --- /dev/null +++ b/features/screens/calc_save_screen.rb @@ -0,0 +1,26 @@ +class CalcSaveScreen < BaseScreen + def initialize(seconds = 5) + catch_for_accessibility_id('Teste', seconds) + catch_for_accessibility_id('Origem: 04306-020', seconds) + catch_for_accessibility_id('Destino: 05065-080', seconds) + catch_for_id('chk_selecao', seconds) + catch_for_id('action_delete', seconds) + end + + def select_save_option + touch_element_for_id('chk_selecao') + end + + def tap_delete_option + touch_element_for_id('action_delete') + end + + def delete_saved_calc + self.select_save_option + self.tap_delete_option + end + + def no_saved_calc_exists(seconds = 5) + catch_for_accessibility_id('Nenhum cálculo realizado foi salvo.', seconds) + end +end \ No newline at end of file diff --git a/features/screens/calc_screen.rb b/features/screens/calc_screen.rb new file mode 100644 index 0000000..a32229b --- /dev/null +++ b/features/screens/calc_screen.rb @@ -0,0 +1,46 @@ +class CalcScreen < BaseScreen + def initialize(seconds = 4) + catch_for_id('lbl_mensagem_ori_dest', seconds) + catch_for_id('txt_data', seconds) + catch_for_id('txt_cep_ori', seconds) + catch_for_id('txt_cep_dest', seconds) + catch_for_id('checkSoPrazo', seconds) + catch_for_id('button_prox', seconds) + end + + def tap_origem_textField + touch_element_for_id('txt_cep_ori') + end + + def tap_detino_testField + touch_element_for_id('txt_cep_dest') + end + + def input_number_in_origem_testField(cep_origin) + sleep(1) + clear_element('txt_cep_ori') + sleep(1) + type_into_text_field_for_id('txt_cep_ori', "#{cep_origin}") + end + + def input_number_in_destino_testField(cep_destinity) + sleep(1) + clear_element('txt_cep_dest') + sleep(1) + type_into_text_field_for_id('txt_cep_dest', "#{cep_destinity}") + end + + def tap_somentePrazo_checkbox + touch_element_for_id('checkSoPrazo') + end + + def tap_proximo_button + touch_element_for_id('button_prox') + sleep(15) + end + + def cep_origem_error(seconds = 5) + id_not_exists_in_screen(seconds, 'action_salvar') + end + +end \ No newline at end of file diff --git a/features/screens/home_screen.rb b/features/screens/home_screen.rb new file mode 100644 index 0000000..d6618be --- /dev/null +++ b/features/screens/home_screen.rb @@ -0,0 +1,21 @@ +class HomeScreen < BaseScreen + def initialize(seconds = 5) + catch_for_id('up', seconds) + end + + def tap_menuOptions_button + touch_element_for_id('up') + end + + def go_to_newCalcs_page + touch_element_for_xpath('/hierarchy/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.view.ViewGroup/android.widget.FrameLayout/android.widget.ListView/android.widget.LinearLayout[1]/android.widget.TextView') + end + + def go_to_saveCalcs_page + touch_element_for_xpath('/hierarchy/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.view.ViewGroup/android.widget.FrameLayout/android.widget.ListView/android.widget.LinearLayout[2]/android.widget.TextView') + end + + def go_to_internationalCalcs_page + touch_element_for_xpath('/hierarchy/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.view.ViewGroup/android.widget.FrameLayout/android.widget.ListView/android.widget.LinearLayout[3]/android.widget.TextView') + end +end \ No newline at end of file diff --git a/features/screens/result_screen.rb b/features/screens/result_screen.rb new file mode 100644 index 0000000..c32ccf0 --- /dev/null +++ b/features/screens/result_screen.rb @@ -0,0 +1,34 @@ +class ResultScreen < BaseScreen + def initialize(seconds = 5) + catch_for_id('lbl_data', seconds) + catch_for_id('lbl_origem', seconds) + catch_for_id('tv_origem', seconds) + catch_for_id('lbl_destino', seconds) + catch_for_id('tv_destino', seconds) + catch_for_id('lbl_mensagem_prazo', seconds) + catch_for_id('lbl_mensagem_form', seconds) + catch_for_id('action_salvar', seconds) + catch_for_xpath('/hierarchy/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.view.ViewGroup/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.ListView/android.widget.RelativeLayout[1]/android.widget.ImageView', seconds) + catch_for_xpath('/hierarchy/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.view.ViewGroup/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.ListView/android.widget.RelativeLayout[1]/android.widget.TextView', seconds) + end + + def tap_salvar_button + touch_element_for_id('action_salvar') + end + + def show_modal_salvar(seconds = 5) + catch_for_id('title', seconds) + catch_for_id('tv_nome_calculo', seconds) + catch_for_id('ed_nome_calculo', seconds) + catch_for_id('bt_ok', seconds) + catch_for_id('bt_cancelar', seconds) + end + + def put_calcName(calcName) + type_into_text_field_for_id('ed_nome_calculo', "#{calcName}") + end + + def tap_button_ok + touch_element_for_id('bt_ok') + end +end \ No newline at end of file diff --git a/features/specs/novo_calculo.feature b/features/specs/novo_calculo.feature new file mode 100644 index 0000000..276ce22 --- /dev/null +++ b/features/specs/novo_calculo.feature @@ -0,0 +1,43 @@ +# language: pt + +Funcionalidade: Realizar novos calculos no app + +@first_scenario +Cenario: Realizar um novo calculo de prazo com sucesso + Dado que estou na tela inicial do app + E clico em Novo calculo + Quando preencho os dados de calculo + E seleciono a opcao de Calcular somente o prazo + Entao devo ver os prazos exibidos na tela do app + E devo conseguir visualizar o meu calculo salvo + +@creating_data +Cenario: Acessar calculo salvo + Dado que estou na tela inicial do app + E clico em Calculos Salvos + Quando seleciono e apago o meu calculo salvo anteriormente + Entao devo deixar de ver o calculo salvo + +@negative_test_1 +Cenario: Realizar um novo calculo sem preencher cep origem + Dado que estou na tela inicial do app + E clico em Novo calculo + Mas nao preencho o cep de origem + Quando tento salvar o calculo + Entao nao devo conseguir salvar o cadastro + +@negative_test_2 +Cenario: Realizar um novo calculo sem preencher cep destino + Dado que estou na tela inicial do app + E clico em Novo calculo + Mas nao preencho o cep de destino + Quando tento salvar o calculo + Entao nao devo conseguir salvar o cadastro + +@negative_test_3 +Cenario: Realizar um novo calculo sem preencher cep nenhum + Dado que estou na tela inicial do app + E clico em Novo calculo + Mas nao preencho nenhum cep + Quando tento salvar o calculo + Entao nao devo conseguir salvar o cadastro \ No newline at end of file diff --git a/features/step_definitions/apagar_calculo_steps.rb b/features/step_definitions/apagar_calculo_steps.rb new file mode 100644 index 0000000..20ccb89 --- /dev/null +++ b/features/step_definitions/apagar_calculo_steps.rb @@ -0,0 +1,14 @@ +Dado("clico em Calculos Salvos") do + @homescreen.tap_menuOptions_button + @homescreen.go_to_saveCalcs_page +end + +Quando("seleciono e apago o meu calculo salvo anteriormente") do + @calc_save_screen = CalcSaveScreen.new(5) + @calc_save_screen.select_save_option + @calc_save_screen.tap_delete_option +end + +Entao("devo deixar de ver o calculo salvo") do + @calc_save_screen.no_saved_calc_exists +end \ No newline at end of file diff --git a/features/step_definitions/fluxos_negativos_steps.rb b/features/step_definitions/fluxos_negativos_steps.rb new file mode 100644 index 0000000..d7f1b8e --- /dev/null +++ b/features/step_definitions/fluxos_negativos_steps.rb @@ -0,0 +1,20 @@ +Dado("nao preencho o cep de origem") do + @calc_screen = CalcScreen.new(5) + @calc_screen.input_number_in_destino_testField('05065080') + @calc_screen.tap_somentePrazo_checkbox +end + +Quando("tento salvar o calculo") do + @calc_screen.tap_proximo_button +end + +Entao("nao devo conseguir salvar o cadastro") do + @calc_screen = CalcScreen.new(5) + @calc_screen.cep_origem_error +end + +Dado("nao preencho o cep de destino") do + @calc_screen = CalcScreen.new(5) + @calc_screen.input_number_in_origem_testField('04306020') + @calc_screen.tap_somentePrazo_checkbox +end diff --git a/features/step_definitions/novo_calculo_steps.rb b/features/step_definitions/novo_calculo_steps.rb new file mode 100644 index 0000000..c8b485b --- /dev/null +++ b/features/step_definitions/novo_calculo_steps.rb @@ -0,0 +1,34 @@ +Dado(/^que estou na tela inicial do app$/) do + sleep(10) + @homescreen = HomeScreen.new(5) +end + +Quando(/^clico em Novo calculo$/) do + @homescreen.go_to_newCalcs_page +end + +Quando(/^preencho os dados de calculo$/) do + @calc_screen = CalcScreen.new(5) + @calc_screen.tap_origem_textField + @calc_screen.input_number_in_origem_testField('04306020') + @calc_screen.input_number_in_destino_testField('05065080') +end + +Quando(/^seleciono a opcao de Calcular somente o prazo$/) do + @calc_screen.tap_somentePrazo_checkbox + @calc_screen.tap_proximo_button +end + +Entao(/^devo ver os prazos exibidos na tela do app$/) do + @result_screen = ResultScreen.new(5) + @result_screen.tap_salvar_button +end + +Entao("devo conseguir visualizar o meu calculo salvo") do + @result_screen.show_modal_salvar(5) + @result_screen.put_calcName('Teste') + @result_screen.tap_button_ok + @homescreen.tap_menuOptions_button + @homescreen.go_to_saveCalcs_page + @calc_save_screen = CalcSaveScreen.new(5) +end \ No newline at end of file diff --git a/features/support/.DS_Store b/features/support/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/features/support/.DS_Store differ diff --git a/features/support/env.rb b/features/support/env.rb new file mode 100644 index 0000000..477e6a0 --- /dev/null +++ b/features/support/env.rb @@ -0,0 +1,85 @@ +#!/usr/bin/env ruby + +require 'appium_lib' +require 'pry' +require 'logger' +require 'httparty' +require 'json' +require 'rest-client' +require 'rspec/expectations' + +# Create a custom World class so we don't pollute `Object` with Appium methods +class AppiumWorld +end + +# # Load the desired configuration from appium.txt, create a driver then +# # Add the methods to the world +# caps_path = File.join(File.dirname(__FILE__), 'appium.txt') +# caps = Appium.load_appium_txt file: caps_path, verbose: true +# Appium::Driver.new(caps, true) + +# Load the desired configuration from appium.txt, create a driver then +# Add the methods to the world +# arquivo antigo funcionando anteriormente +caps_path = File.join(File.dirname(__FILE__), '..', '..', 'caps') +caps_file = File.join(caps_path, "appium.txt") +caps = Appium.load_appium_txt file: caps_file, verbose: true +Appium::Driver.new(caps, true) +Appium.promote_appium_methods AppiumWorld + +# Before do |scenario| +# $driver.start_driver + +# scenario_tags = scenario.source_tag_names +# if scenario_tags.include?('@creating_data') +# steps %{ +# Dado que estou na tela inicial do app +# Quando clico em Novo calculo +# E preencho os dados de calculo +# E seleciono a opcao de Calcular somente o prazo +# Entao devo ver os prazos exibidos na tela do app +# E devo conseguir visualizar o meu calculo salvo +# } +# end +# end + +# After do |scenario| + +# if scenario.passed? +# screenshot_date = Time.now.strftime("%Y-%m-%d_%H-%M-%S") + +# unless File.directory?("reports/screenshots/#{scenario.feature.name}_screenshots_#{screenshot_date}") +# FileUtils.mkdir_p("reports/screenshots/#{scenario.feature.name}_screenshots_#{screenshot_date}") +# end + +# time_stamp = Time.now.strftime("%Y-%m-%d_%H.%M.%S") + +# screenshot_name = "#{time_stamp}.png" +# screenshot_file = File.join("reports/screenshots/#{scenario.feature.name}_screenshots_#{screenshot_date}", screenshot_name) +# $driver.screenshot(screenshot_file) +# embed("#{screenshot_file}", "image/png") + +# else +# screenshot_date = Time.now.strftime("%Y-%m-%d_%H-%M-%S") + +# unless File.directory?("reports/screenshots/#{scenario.feature.name}_screenshots_#{screenshot_date}") +# FileUtils.mkdir_p("reports/screenshots/#{scenario.feature.name}_screenshots_#{screenshot_date}") +# end + +# time_stamp = Time.now.strftime("%Y-%m-%d_%H.%M.%S") + +# screenshot_name = "#{time_stamp}.png" +# screenshot_file = File.join("reports/screenshots/#{scenario.feature.name}_screenshots_#{screenshot_date}", screenshot_name) +# $driver.screenshot(screenshot_file) +# embed("#{screenshot_file}", "image/png") + +# end + +# $driver.driver_quit + + +# end + +# at_exit do +# system "reports/report_builder.rb" +# end diff --git a/features/support/hook.rb b/features/support/hook.rb new file mode 100644 index 0000000..619e796 --- /dev/null +++ b/features/support/hook.rb @@ -0,0 +1,65 @@ +require 'appium_lib' +require 'pry' +require 'logger' +require 'httparty' +require 'json' +require 'rest-client' +require 'rspec/expectations' + + +Before do |scenario| + $driver.start_driver + + scenario_tags = scenario.source_tag_names + if scenario_tags.include?('@creating_data') + steps %{ + Dado que estou na tela inicial do app + Quando clico em Novo calculo + E preencho os dados de calculo + E seleciono a opcao de Calcular somente o prazo + Entao devo ver os prazos exibidos na tela do app + E devo conseguir visualizar o meu calculo salvo + } + end +end + +After do |scenario| + + if scenario.passed? + screenshot_date = Time.now.strftime("%Y-%m-%d_%H-%M-%S") + + unless File.directory?("reports/screenshots/#{scenario.feature.name}_screenshots_#{screenshot_date}") + FileUtils.mkdir_p("reports/screenshots/#{scenario.feature.name}_screenshots_#{screenshot_date}") + end + + time_stamp = Time.now.strftime("%Y-%m-%d_%H.%M.%S") + + screenshot_name = "#{time_stamp}.png" + screenshot_file = File.join("reports/screenshots/#{scenario.feature.name}_screenshots_#{screenshot_date}", screenshot_name) + $driver.screenshot(screenshot_file) + embed("#{screenshot_file}", "image/png") + + else + screenshot_date = Time.now.strftime("%Y-%m-%d_%H-%M-%S") + + unless File.directory?("reports/screenshots/#{scenario.feature.name}_screenshots_#{screenshot_date}") + FileUtils.mkdir_p("reports/screenshots/#{scenario.feature.name}_screenshots_#{screenshot_date}") + end + + time_stamp = Time.now.strftime("%Y-%m-%d_%H.%M.%S") + + screenshot_name = "#{time_stamp}.png" + screenshot_file = File.join("reports/screenshots/#{scenario.feature.name}_screenshots_#{screenshot_date}", screenshot_name) + $driver.screenshot(screenshot_file) + embed("#{screenshot_file}", "image/png") + + end + + $driver.driver_quit + + +end + +at_exit do + system "reports/report_builder.rb" +end \ No newline at end of file diff --git a/reports/.DS_Store b/reports/.DS_Store new file mode 100644 index 0000000..aa42b67 Binary files /dev/null and b/reports/.DS_Store differ diff --git a/reports/screenshots/.DS_Store b/reports/screenshots/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/reports/screenshots/.DS_Store differ