ruby-mobile-appium-template 1.1.6 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ruby-mobile-appium-template +3 -3
- data/lib/ruby_appium.rb +115 -115
- data/templates/.gitignore +255 -255
- data/templates/Gemfile +14 -14
- data/templates/config/android/appium.txt +17 -17
- data/templates/config/android/appium_farm.txt +21 -21
- data/templates/cucumber.yml +6 -6
- data/templates/features/login/data/login.yaml +3 -4
- 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 +1 -1
@@ -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
|