ruby-mobile-appium-template 1.1.4 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/ruby-mobile-appium-template +3 -3
- data/lib/ruby_appium.rb +115 -116
- data/templates/.gitignore +256 -0
- data/templates/Gemfile +14 -14
- data/templates/config/android/appium.txt +18 -0
- data/templates/config/android/appium_farm.txt +21 -0
- data/templates/{appium.txt → config/ios/appium.txt} +0 -0
- data/templates/config/ios/appium_farm.txt +17 -0
- data/templates/cucumber.yml +6 -6
- data/templates/features/login/data/login.yaml +3 -310
- data/templates/features/login/elements/screen_mappings_home.yaml +35 -35
- data/templates/features/login/elements/screen_mappings_login.yaml +43 -43
- data/templates/features/login/elements/screen_mappings_organizadorhome.yaml +29 -29
- data/templates/features/login/elements/screen_mappings_token.yaml +30 -30
- data/templates/features/login/features/login.feature +16 -16
- data/templates/features/login/pageobjects/home.rb +24 -24
- data/templates/features/login/pageobjects/login.rb +51 -51
- data/templates/features/login/pageobjects/organizadorHome.rb +16 -16
- data/templates/features/login/pageobjects/token.rb +19 -19
- data/templates/features/login/steps/login_steps.rb +30 -30
- data/templates/features/support/appium_custom.rb +64 -64
- data/templates/features/support/env.rb +21 -21
- data/templates/features/support/hooks.rb +17 -17
- data/templates/features/support/utils.rb +84 -84
- metadata +6 -2
@@ -1,52 +1,52 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
class LoginPage
|
3
|
-
|
4
|
-
def initialize
|
5
|
-
get_screen_mappings 'login', 'login'
|
6
|
-
end
|
7
|
-
def login(cpf, senha)
|
8
|
-
preencheCPF(cpf)
|
9
|
-
continuar()
|
10
|
-
preencheSenha(senha)
|
11
|
-
continuar()
|
12
|
-
end
|
13
|
-
|
14
|
-
def preencheCPF cpf
|
15
|
-
wait_for_element_exist(@mappings['preencherCpf'])
|
16
|
-
send_keys_digital_keyboard(@mappings['preencherCpf'], cpf)
|
17
|
-
screenshot ('Page - Preenche CPF')
|
18
|
-
end
|
19
|
-
|
20
|
-
def preencheSenha senha
|
21
|
-
wait_for_element_exist(@mappings['preencherSenha'])
|
22
|
-
send_keys_digital_keyboard(@mappings['preencherSenha'], senha)
|
23
|
-
screenshot ('Page - Preenche Senha')
|
24
|
-
end
|
25
|
-
|
26
|
-
def continuar
|
27
|
-
screenshot('PAGE - Continuar')
|
28
|
-
find(@mappings['btnContinuar']).click
|
29
|
-
end
|
30
|
-
|
31
|
-
def clickCPF
|
32
|
-
if android?
|
33
|
-
wait_for_element_exist(@mappings['campoCPF'])
|
34
|
-
find(@mappings['campoCPF']).click
|
35
|
-
elsif ios?
|
36
|
-
wait_for_element_exist(@mappings['campoCPF'])
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def pulaBiometria
|
41
|
-
if android?
|
42
|
-
screenshot("Pular Biometria")
|
43
|
-
if wait_for_element_exist(@mappings['btnAtivarAcessoBio'])
|
44
|
-
puts("Biometria?#{wait_for_element_exist(@mappings['btnAtivarAcessoBio'])}")
|
45
|
-
wait_for_element_exist(@mappings['btnDeixarParaDepois'])
|
46
|
-
find(@mappings['btnDeixarParaDepois']).click
|
47
|
-
find(@mappings['btnOkEntendiBio']).click
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
class LoginPage
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
get_screen_mappings 'login', 'login'
|
6
|
+
end
|
7
|
+
def login(cpf, senha)
|
8
|
+
preencheCPF(cpf)
|
9
|
+
continuar()
|
10
|
+
preencheSenha(senha)
|
11
|
+
continuar()
|
12
|
+
end
|
13
|
+
|
14
|
+
def preencheCPF cpf
|
15
|
+
wait_for_element_exist(@mappings['preencherCpf'])
|
16
|
+
send_keys_digital_keyboard(@mappings['preencherCpf'], cpf)
|
17
|
+
screenshot ('Page - Preenche CPF')
|
18
|
+
end
|
19
|
+
|
20
|
+
def preencheSenha senha
|
21
|
+
wait_for_element_exist(@mappings['preencherSenha'])
|
22
|
+
send_keys_digital_keyboard(@mappings['preencherSenha'], senha)
|
23
|
+
screenshot ('Page - Preenche Senha')
|
24
|
+
end
|
25
|
+
|
26
|
+
def continuar
|
27
|
+
screenshot('PAGE - Continuar')
|
28
|
+
find(@mappings['btnContinuar']).click
|
29
|
+
end
|
30
|
+
|
31
|
+
def clickCPF
|
32
|
+
if android?
|
33
|
+
wait_for_element_exist(@mappings['campoCPF'])
|
34
|
+
find(@mappings['campoCPF']).click
|
35
|
+
elsif ios?
|
36
|
+
wait_for_element_exist(@mappings['campoCPF'])
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def pulaBiometria
|
41
|
+
if android?
|
42
|
+
screenshot("Pular Biometria")
|
43
|
+
if wait_for_element_exist(@mappings['btnAtivarAcessoBio'])
|
44
|
+
puts("Biometria?#{wait_for_element_exist(@mappings['btnAtivarAcessoBio'])}")
|
45
|
+
wait_for_element_exist(@mappings['btnDeixarParaDepois'])
|
46
|
+
find(@mappings['btnDeixarParaDepois']).click
|
47
|
+
find(@mappings['btnOkEntendiBio']).click
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
52
|
end
|
@@ -1,16 +1,16 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
class OrganizadorHomePage
|
3
|
-
|
4
|
-
def initialize
|
5
|
-
get_screen_mappings 'organizadorhome', 'login'
|
6
|
-
end
|
7
|
-
|
8
|
-
def is_page?
|
9
|
-
wait_for_element_exist(@mappings['perfil'])
|
10
|
-
wait_for_element_exist(@mappings['logo'])
|
11
|
-
screenshot('Home APP')
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
class OrganizadorHomePage
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
get_screen_mappings 'organizadorhome', 'login'
|
6
|
+
end
|
7
|
+
|
8
|
+
def is_page?
|
9
|
+
wait_for_element_exist(@mappings['perfil'])
|
10
|
+
wait_for_element_exist(@mappings['logo'])
|
11
|
+
screenshot('Home APP')
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
|
@@ -1,19 +1,19 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
class TokenPage
|
3
|
-
require 'pry'
|
4
|
-
require 'rest-client'
|
5
|
-
require 'json'
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
get_screen_mappings 'token', 'login'
|
9
|
-
end
|
10
|
-
|
11
|
-
def pularToken
|
12
|
-
if find(@mappings['btnDeixarParaDepois']).displayed?
|
13
|
-
@mappings['btnDeixarParaDepois'].click
|
14
|
-
screenshot('Page - Pular Token')
|
15
|
-
@mappings['vwIrTelaInicial'].click
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
class TokenPage
|
3
|
+
require 'pry'
|
4
|
+
require 'rest-client'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
get_screen_mappings 'token', 'login'
|
9
|
+
end
|
10
|
+
|
11
|
+
def pularToken
|
12
|
+
if find(@mappings['btnDeixarParaDepois']).displayed?
|
13
|
+
@mappings['btnDeixarParaDepois'].click
|
14
|
+
screenshot('Page - Pular Token')
|
15
|
+
@mappings['vwIrTelaInicial'].click
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -1,30 +1,30 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'rspec/expectations'
|
3
|
-
require 'pry'
|
4
|
-
|
5
|
-
Given('eu tenha as paginas necessárias iniciadas') do
|
6
|
-
@login = LoginPages.new
|
7
|
-
end
|
8
|
-
|
9
|
-
And('o arquivo de massa de dados') do
|
10
|
-
@datalogin = init_data("login")
|
11
|
-
end
|
12
|
-
|
13
|
-
Given(/^que estou na tela inicial$/) do
|
14
|
-
print "Entrou no step"
|
15
|
-
expect(@login.home.is_home?).to be true
|
16
|
-
@login.home.pulaWalkThrough
|
17
|
-
@login.login.clickCPF
|
18
|
-
end
|
19
|
-
|
20
|
-
When(/^insiro as minhas credenciais de acesso$/) do
|
21
|
-
@login.login.login(@datalogin["login"]["ativada"]["cpf"], @datalogin["login"]["ativada"]["senha"])
|
22
|
-
end
|
23
|
-
|
24
|
-
Then(/^sou direcionado a home de Conta$/) do
|
25
|
-
@login.login.pulaBiometria
|
26
|
-
if @login.token.pularToken
|
27
|
-
@login.organizadorHome.is_page?
|
28
|
-
end
|
29
|
-
@login.organizadorHome.is_page?
|
30
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'rspec/expectations'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
Given('eu tenha as paginas necessárias iniciadas') do
|
6
|
+
@login = LoginPages.new
|
7
|
+
end
|
8
|
+
|
9
|
+
And('o arquivo de massa de dados') do
|
10
|
+
@datalogin = init_data("login")
|
11
|
+
end
|
12
|
+
|
13
|
+
Given(/^que estou na tela inicial$/) do
|
14
|
+
print "Entrou no step"
|
15
|
+
expect(@login.home.is_home?).to be true
|
16
|
+
@login.home.pulaWalkThrough
|
17
|
+
@login.login.clickCPF
|
18
|
+
end
|
19
|
+
|
20
|
+
When(/^insiro as minhas credenciais de acesso$/) do
|
21
|
+
@login.login.login(@datalogin["login"]["ativada"]["cpf"], @datalogin["login"]["ativada"]["senha"])
|
22
|
+
end
|
23
|
+
|
24
|
+
Then(/^sou direcionado a home de Conta$/) do
|
25
|
+
@login.login.pulaBiometria
|
26
|
+
if @login.token.pularToken
|
27
|
+
@login.organizadorHome.is_page?
|
28
|
+
end
|
29
|
+
@login.organizadorHome.is_page?
|
30
|
+
end
|
@@ -1,65 +1,65 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
def wait_for_element_exist(el)
|
4
|
-
$wait.until { element_exists?(el) }
|
5
|
-
$logger.info("Aguardou a existência do elemento #{el['value']} usando o tipo de busca #{el['tipo_busca']}")
|
6
|
-
end
|
7
|
-
|
8
|
-
def element_exists?(el)
|
9
|
-
$logger.info("Verificando se existe o elemento #{el['value']} usando o tipo de busca #{el['tipo_busca']}")
|
10
|
-
$driver.find_elements(el['tipo_busca'], el['value']).count > 0
|
11
|
-
end
|
12
|
-
|
13
|
-
def find(el)
|
14
|
-
$driver.find_element(el['tipo_busca'], el['value'])
|
15
|
-
end
|
16
|
-
|
17
|
-
def hide_keyboard
|
18
|
-
if android?
|
19
|
-
$driver.hide_keyboard
|
20
|
-
elsif ios?
|
21
|
-
$driver.hide_keyboard :pressKey
|
22
|
-
end
|
23
|
-
$logger.info('Fechou o teclado virtual')
|
24
|
-
end
|
25
|
-
|
26
|
-
def send_keys_digital_keyboard el, text
|
27
|
-
text.to_s.strip.each_char do |c|
|
28
|
-
case $platform
|
29
|
-
when 'android'
|
30
|
-
$driver.execute_script("mobile: shell", {"command": "input text '#{c}'"})
|
31
|
-
when 'ios'
|
32
|
-
find(el).send_keys c
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def send_keys el,text
|
38
|
-
$driver.find_element(el['tipo_busca'], el['value']).send_keys(text)
|
39
|
-
end
|
40
|
-
|
41
|
-
#metodo para swipe criado como paleativo até que seja ajustado o elemento unico de tela
|
42
|
-
def swipe_orientation(el_from, el_to, orientation, max_swipes = 5)
|
43
|
-
screen = $driver.window_size
|
44
|
-
pos_el_from = find(el_from).location
|
45
|
-
start_x = (screen.width / 5 * 4).abs
|
46
|
-
end_x = (screen.width / 2).abs
|
47
|
-
start_y = (screen.height / 5 * 4).abs
|
48
|
-
end_y = (screen.height / 2).abs
|
49
|
-
$driver.manage.timeouts.implicit_wait = 0
|
50
|
-
swipes = 0
|
51
|
-
while ((!element_exists?(el_to)) || (!find(el_to).displayed?)) && (swipes <= max_swipes)
|
52
|
-
case orientation
|
53
|
-
when "left"
|
54
|
-
Appium::TouchAction.new.swipe(start_x: start_x, start_y: pos_el_from.y + 20, end_x: end_x, end_y: pos_el_from.y + 20, duration: 500).perform
|
55
|
-
when "right"
|
56
|
-
Appium::TouchAction.new.swipe(start_x: end_x, start_y: pos_el_from.y + 20, end_x: start_x, end_y: pos_el_from.y + 20, duration: 500).perform
|
57
|
-
when 'up'
|
58
|
-
Appium::TouchAction.new.swipe(start_x: pos_el_from.x + 20, start_y: start_y, end_x: pos_el_from.x + 20, end_y: end_y, duration: 500).perform
|
59
|
-
when 'down'
|
60
|
-
Appium::TouchAction.new.swipe(start_x: pos_el_from.x + 20, start_y: end_y, end_x: pos_el_from.x + 20, end_y: start_y, duration: 500).perform
|
61
|
-
end
|
62
|
-
swipes += 1
|
63
|
-
end
|
64
|
-
$driver.manage.timeouts.implicit_wait = 30
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
def wait_for_element_exist(el)
|
4
|
+
$wait.until { element_exists?(el) }
|
5
|
+
$logger.info("Aguardou a existência do elemento #{el['value']} usando o tipo de busca #{el['tipo_busca']}")
|
6
|
+
end
|
7
|
+
|
8
|
+
def element_exists?(el)
|
9
|
+
$logger.info("Verificando se existe o elemento #{el['value']} usando o tipo de busca #{el['tipo_busca']}")
|
10
|
+
$driver.find_elements(el['tipo_busca'], el['value']).count > 0
|
11
|
+
end
|
12
|
+
|
13
|
+
def find(el)
|
14
|
+
$driver.find_element(el['tipo_busca'], el['value'])
|
15
|
+
end
|
16
|
+
|
17
|
+
def hide_keyboard
|
18
|
+
if android?
|
19
|
+
$driver.hide_keyboard
|
20
|
+
elsif ios?
|
21
|
+
$driver.hide_keyboard :pressKey
|
22
|
+
end
|
23
|
+
$logger.info('Fechou o teclado virtual')
|
24
|
+
end
|
25
|
+
|
26
|
+
def send_keys_digital_keyboard el, text
|
27
|
+
text.to_s.strip.each_char do |c|
|
28
|
+
case $platform
|
29
|
+
when 'android'
|
30
|
+
$driver.execute_script("mobile: shell", {"command": "input text '#{c}'"})
|
31
|
+
when 'ios'
|
32
|
+
find(el).send_keys c
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def send_keys el,text
|
38
|
+
$driver.find_element(el['tipo_busca'], el['value']).send_keys(text)
|
39
|
+
end
|
40
|
+
|
41
|
+
#metodo para swipe criado como paleativo até que seja ajustado o elemento unico de tela
|
42
|
+
def swipe_orientation(el_from, el_to, orientation, max_swipes = 5)
|
43
|
+
screen = $driver.window_size
|
44
|
+
pos_el_from = find(el_from).location
|
45
|
+
start_x = (screen.width / 5 * 4).abs
|
46
|
+
end_x = (screen.width / 2).abs
|
47
|
+
start_y = (screen.height / 5 * 4).abs
|
48
|
+
end_y = (screen.height / 2).abs
|
49
|
+
$driver.manage.timeouts.implicit_wait = 0
|
50
|
+
swipes = 0
|
51
|
+
while ((!element_exists?(el_to)) || (!find(el_to).displayed?)) && (swipes <= max_swipes)
|
52
|
+
case orientation
|
53
|
+
when "left"
|
54
|
+
Appium::TouchAction.new.swipe(start_x: start_x, start_y: pos_el_from.y + 20, end_x: end_x, end_y: pos_el_from.y + 20, duration: 500).perform
|
55
|
+
when "right"
|
56
|
+
Appium::TouchAction.new.swipe(start_x: end_x, start_y: pos_el_from.y + 20, end_x: start_x, end_y: pos_el_from.y + 20, duration: 500).perform
|
57
|
+
when 'up'
|
58
|
+
Appium::TouchAction.new.swipe(start_x: pos_el_from.x + 20, start_y: start_y, end_x: pos_el_from.x + 20, end_y: end_y, duration: 500).perform
|
59
|
+
when 'down'
|
60
|
+
Appium::TouchAction.new.swipe(start_x: pos_el_from.x + 20, start_y: end_y, end_x: pos_el_from.x + 20, end_y: start_y, duration: 500).perform
|
61
|
+
end
|
62
|
+
swipes += 1
|
63
|
+
end
|
64
|
+
$driver.manage.timeouts.implicit_wait = 30
|
65
65
|
end
|
@@ -1,21 +1,21 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'appium_lib'
|
4
|
-
require 'pry'
|
5
|
-
require 'cucumber'
|
6
|
-
require 'selenium-webdriver'
|
7
|
-
require 'allure-cucumber'
|
8
|
-
require_relative 'utils'
|
9
|
-
|
10
|
-
verify_platform()
|
11
|
-
verify_where()
|
12
|
-
|
13
|
-
def load_appium_configuration
|
14
|
-
caps = Appium.load_appium_txt file: File.join("#{Dir.pwd}/config/#{$platform}/#{$where == 'farm' ? 'appium_farm.txt' : 'appium.txt'}")
|
15
|
-
caps[:caps][:oauthClientId] = 'oauth2-PFoYDkJ2wrTokwrS3l5Q@microfocus.com' #colocar valor do clientID gerado nas credenciais da Farm UFT
|
16
|
-
caps[:caps][:oauthClientSecret] = 'x1V3tLi5Mi1qMEqkJJGD' #colocar valor da ClienteSecret gerado nas credenciais da Farm UFT
|
17
|
-
return caps
|
18
|
-
end
|
19
|
-
|
20
|
-
$wait = Selenium::WebDriver::Wait.new(timeout: 60)
|
21
|
-
Appium::Driver.new(load_appium_configuration(), true)
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'appium_lib'
|
4
|
+
require 'pry'
|
5
|
+
require 'cucumber'
|
6
|
+
require 'selenium-webdriver'
|
7
|
+
require 'allure-cucumber'
|
8
|
+
require_relative 'utils'
|
9
|
+
|
10
|
+
verify_platform()
|
11
|
+
verify_where()
|
12
|
+
|
13
|
+
def load_appium_configuration
|
14
|
+
caps = Appium.load_appium_txt file: File.join("#{Dir.pwd}/config/#{$platform}/#{$where == 'farm' ? 'appium_farm.txt' : 'appium.txt'}")
|
15
|
+
caps[:caps][:oauthClientId] = 'oauth2-PFoYDkJ2wrTokwrS3l5Q@microfocus.com' #colocar valor do clientID gerado nas credenciais da Farm UFT
|
16
|
+
caps[:caps][:oauthClientSecret] = 'x1V3tLi5Mi1qMEqkJJGD' #colocar valor da ClienteSecret gerado nas credenciais da Farm UFT
|
17
|
+
return caps
|
18
|
+
end
|
19
|
+
|
20
|
+
$wait = Selenium::WebDriver::Wait.new(timeout: 60)
|
21
|
+
Appium::Driver.new(load_appium_configuration(), true)
|
@@ -1,18 +1,18 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'pry'
|
3
|
-
require_relative 'utils'
|
4
|
-
|
5
|
-
Before do
|
6
|
-
tempDirectories()
|
7
|
-
$driver.start_driver
|
8
|
-
end
|
9
|
-
|
10
|
-
After do
|
11
|
-
$driver.driver_quit
|
12
|
-
end
|
13
|
-
|
14
|
-
After do |scenario|
|
15
|
-
screenshot 'resultado'
|
16
|
-
$driver.close_app
|
17
|
-
$logger.info("Teste #{@scenario_name} finalizado")
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'pry'
|
3
|
+
require_relative 'utils'
|
4
|
+
|
5
|
+
Before do
|
6
|
+
tempDirectories()
|
7
|
+
$driver.start_driver
|
8
|
+
end
|
9
|
+
|
10
|
+
After do
|
11
|
+
$driver.driver_quit
|
12
|
+
end
|
13
|
+
|
14
|
+
After do |scenario|
|
15
|
+
screenshot 'resultado'
|
16
|
+
$driver.close_app
|
17
|
+
$logger.info("Teste #{@scenario_name} finalizado")
|
18
18
|
end
|
@@ -1,84 +1,84 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
|
-
def android?
|
4
|
-
$platform == 'android'
|
5
|
-
end
|
6
|
-
|
7
|
-
def ios?
|
8
|
-
$platform == 'ios'
|
9
|
-
end
|
10
|
-
|
11
|
-
def screenshot(step)
|
12
|
-
screenshot = $driver.screenshot("allure-results/#{$platform}/ss.png")
|
13
|
-
Allure.add_attachment(name: "#{@scenario_name} - #{step}", source: screenshot, type: Allure::ContentType::PNG)
|
14
|
-
File.delete("allure-results/#{$platform}/ss.png")
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
#necessário para anexar direto o binário da screenshot no relatório
|
19
|
-
module Allure
|
20
|
-
class FileWriter
|
21
|
-
def write(name, source)
|
22
|
-
filename = File.join(output_dir, name)
|
23
|
-
File.open(filename, "wb") { |file| file.write(source) }
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
Allure.configure do |c|
|
29
|
-
c.results_directory = './allure-results/'
|
30
|
-
c.clean_results_directory = false
|
31
|
-
end
|
32
|
-
|
33
|
-
def tempDirectories()
|
34
|
-
time = Time.new
|
35
|
-
time = time.strftime('%d-%m-%Y')
|
36
|
-
loggerPath = "#{Dir.pwd}/exec-logs"
|
37
|
-
allure = "#{Dir.pwd}/allure-results"
|
38
|
-
Dir.exists?(allure) ? cleanFolder("#{allure}/.") && Dir.mkdir("#{allure}/#{$platform}") : Dir.mkdir(allure) && Dir.mkdir("#{allure}/#{$platform}")
|
39
|
-
Dir.exists?(loggerPath) ? cleanFolder("#{loggerPath}/.") : Dir.mkdir(loggerPath)
|
40
|
-
$logger = Logger.new("#{loggerPath}/exec-log-#{time}.log")
|
41
|
-
end
|
42
|
-
|
43
|
-
def cleanFolder(folderPath)
|
44
|
-
FileUtils.rm_rf(folderPath, secure: false)
|
45
|
-
end
|
46
|
-
|
47
|
-
#Metodo para iniciar os arquivos datas das Features
|
48
|
-
def init_data(package)
|
49
|
-
dir = "#{Dir.pwd}/features/#{package}/data"
|
50
|
-
data = {}
|
51
|
-
Dir.foreach(dir) do |filename|
|
52
|
-
next if filename == '.' or filename == '..'
|
53
|
-
area = File.basename(filename, ".yaml").to_s
|
54
|
-
data["#{area}"] = YAML.load_file("#{dir}/#{filename}")
|
55
|
-
end
|
56
|
-
return data
|
57
|
-
end
|
58
|
-
|
59
|
-
#Metodo para iniciar os arquivos de mapeamento dos elementos
|
60
|
-
def get_screen_mappings(screen, package)
|
61
|
-
dir = "#{Dir.pwd}/features/#{package}/elements/screen_mappings_#{screen}.yaml"
|
62
|
-
screen_mappings = YAML.load_file(dir)
|
63
|
-
@mappings = screen_mappings[$platform]
|
64
|
-
end
|
65
|
-
|
66
|
-
#Metodo verifica se plataforma foi fornecida no inicio da execuçáo do teste
|
67
|
-
def verify_platform()
|
68
|
-
raise 'Por favor defina a plataforma (android|ios)' if ENV['PLATFORM'].nil?
|
69
|
-
if ENV['PLATFORM'].downcase == "android" || ENV['PLATFORM'].downcase == "ios"
|
70
|
-
$platform = ENV['PLATFORM'].downcase
|
71
|
-
else
|
72
|
-
raise("Testes não suportados para esta plataforma #{ENV['PLATFORM'].downcase}")
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
#Metodo verifica se foi informado que o teste rodará na farm ou localmente
|
77
|
-
def verify_where()
|
78
|
-
raise 'Por favor defina onde será executado o teste (local|farm)' if ENV['WHERE'].nil?
|
79
|
-
if ENV['WHERE'].downcase == "local" || ENV['WHERE'].downcase == "farm"
|
80
|
-
$where = ENV['WHERE'].downcase
|
81
|
-
else
|
82
|
-
raise("Não é possivel executar os testes em #{ENV['WHERE'].downcase}")
|
83
|
-
end
|
84
|
-
end
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
def android?
|
4
|
+
$platform == 'android'
|
5
|
+
end
|
6
|
+
|
7
|
+
def ios?
|
8
|
+
$platform == 'ios'
|
9
|
+
end
|
10
|
+
|
11
|
+
def screenshot(step)
|
12
|
+
screenshot = $driver.screenshot("allure-results/#{$platform}/ss.png")
|
13
|
+
Allure.add_attachment(name: "#{@scenario_name} - #{step}", source: screenshot, type: Allure::ContentType::PNG)
|
14
|
+
File.delete("allure-results/#{$platform}/ss.png")
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
#necessário para anexar direto o binário da screenshot no relatório
|
19
|
+
module Allure
|
20
|
+
class FileWriter
|
21
|
+
def write(name, source)
|
22
|
+
filename = File.join(output_dir, name)
|
23
|
+
File.open(filename, "wb") { |file| file.write(source) }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
Allure.configure do |c|
|
29
|
+
c.results_directory = './allure-results/'
|
30
|
+
c.clean_results_directory = false
|
31
|
+
end
|
32
|
+
|
33
|
+
def tempDirectories()
|
34
|
+
time = Time.new
|
35
|
+
time = time.strftime('%d-%m-%Y')
|
36
|
+
loggerPath = "#{Dir.pwd}/exec-logs"
|
37
|
+
allure = "#{Dir.pwd}/allure-results"
|
38
|
+
Dir.exists?(allure) ? cleanFolder("#{allure}/.") && Dir.mkdir("#{allure}/#{$platform}") : Dir.mkdir(allure) && Dir.mkdir("#{allure}/#{$platform}")
|
39
|
+
Dir.exists?(loggerPath) ? cleanFolder("#{loggerPath}/.") : Dir.mkdir(loggerPath)
|
40
|
+
$logger = Logger.new("#{loggerPath}/exec-log-#{time}.log")
|
41
|
+
end
|
42
|
+
|
43
|
+
def cleanFolder(folderPath)
|
44
|
+
FileUtils.rm_rf(folderPath, secure: false)
|
45
|
+
end
|
46
|
+
|
47
|
+
#Metodo para iniciar os arquivos datas das Features
|
48
|
+
def init_data(package)
|
49
|
+
dir = "#{Dir.pwd}/features/#{package}/data"
|
50
|
+
data = {}
|
51
|
+
Dir.foreach(dir) do |filename|
|
52
|
+
next if filename == '.' or filename == '..'
|
53
|
+
area = File.basename(filename, ".yaml").to_s
|
54
|
+
data["#{area}"] = YAML.load_file("#{dir}/#{filename}")
|
55
|
+
end
|
56
|
+
return data
|
57
|
+
end
|
58
|
+
|
59
|
+
#Metodo para iniciar os arquivos de mapeamento dos elementos
|
60
|
+
def get_screen_mappings(screen, package)
|
61
|
+
dir = "#{Dir.pwd}/features/#{package}/elements/screen_mappings_#{screen}.yaml"
|
62
|
+
screen_mappings = YAML.load_file(dir)
|
63
|
+
@mappings = screen_mappings[$platform]
|
64
|
+
end
|
65
|
+
|
66
|
+
#Metodo verifica se plataforma foi fornecida no inicio da execuçáo do teste
|
67
|
+
def verify_platform()
|
68
|
+
raise 'Por favor defina a plataforma (android|ios)' if ENV['PLATFORM'].nil?
|
69
|
+
if ENV['PLATFORM'].downcase == "android" || ENV['PLATFORM'].downcase == "ios"
|
70
|
+
$platform = ENV['PLATFORM'].downcase
|
71
|
+
else
|
72
|
+
raise("Testes não suportados para esta plataforma #{ENV['PLATFORM'].downcase}")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
#Metodo verifica se foi informado que o teste rodará na farm ou localmente
|
77
|
+
def verify_where()
|
78
|
+
raise 'Por favor defina onde será executado o teste (local|farm)' if ENV['WHERE'].nil?
|
79
|
+
if ENV['WHERE'].downcase == "local" || ENV['WHERE'].downcase == "farm"
|
80
|
+
$where = ENV['WHERE'].downcase
|
81
|
+
else
|
82
|
+
raise("Não é possivel executar os testes em #{ENV['WHERE'].downcase}")
|
83
|
+
end
|
84
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-mobile-appium-template
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roger Fernandes
|
@@ -146,9 +146,13 @@ extra_rdoc_files: []
|
|
146
146
|
files:
|
147
147
|
- bin/ruby-mobile-appium-template
|
148
148
|
- lib/ruby_appium.rb
|
149
|
+
- templates/.gitignore
|
149
150
|
- templates/Gemfile
|
150
151
|
- templates/Rakefile
|
151
|
-
- templates/appium.txt
|
152
|
+
- templates/config/android/appium.txt
|
153
|
+
- templates/config/android/appium_farm.txt
|
154
|
+
- templates/config/ios/appium.txt
|
155
|
+
- templates/config/ios/appium_farm.txt
|
152
156
|
- templates/cucumber.yml
|
153
157
|
- templates/features/login/data/login.yaml
|
154
158
|
- templates/features/login/elements/screen_mappings_home.yaml
|