ruby-mobile-appium-template 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7d32efb696b9b84bc25d4756ffbf854ca90d5c9ed74ce013c22ac2a60c8b004a
4
+ data.tar.gz: 733fb67acf84d2381d94bf86e659e1cc1b1b7fc0523576524484cc5360051511
5
+ SHA512:
6
+ metadata.gz: 4f83cab52dbaa2921f5d4d9186654080623a3fab315093b807ce57c2d6302b5118dd07442fb0375a4b40282fb686b50c3bdde2826a05dbbb026d47c350764e20
7
+ data.tar.gz: 141339ec936f1076e568561418e1ef2c00d8cc7d88be15bdd910a65eed2fd68d0679e6bea0806d1c5a25e51de7f27ef78ec97d22fe99b10270ddda4bf29b9ac0
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'ruby_appium'
4
+ RubyAppium.start
@@ -0,0 +1,87 @@
1
+ require 'thor'
2
+ require 'thor/group'
3
+ require 'fileutils'
4
+
5
+ class RubyAppium < Thor::Group
6
+ include Thor::Actions
7
+
8
+ VERSION = "1.0.0"
9
+
10
+ argument :dir_name
11
+
12
+ def self.source_root
13
+ File.join(File.dirname(__FILE__), '..', 'templates')
14
+ end
15
+
16
+ def create_new_cucumber_directory
17
+ self.destination_root = File.expand_path(dir_name, destination_root)
18
+ make_empty_directory
19
+ FileUtils.cd(destination_root)
20
+ gemfile_rakefile_cukeyml
21
+ directory_and_files
22
+ end
23
+
24
+ protected
25
+
26
+ def make_empty_directory
27
+ empty_directory '.'
28
+ end
29
+
30
+ def directory_and_files
31
+ empty_directory 'app'
32
+ empty_directory 'config'
33
+ empty_directory 'features'
34
+
35
+ inside 'app' do
36
+ empty_directory 'ios'
37
+ empty_directory 'android'
38
+ end
39
+
40
+ inside 'config' do
41
+ empty_directory 'ios'
42
+ empty_directory 'android'
43
+ template 'ios/appium.txt', 'ios/appium.txt'
44
+ template 'ios/appium_farm.txt', 'ios/appium_farm.txt'
45
+ template 'android/appium.txt', 'android/appium.txt'
46
+ template 'android/appium_farm.txt', 'android/appium_farm.txt'
47
+ end
48
+
49
+ inside 'features' do
50
+ empty_directory 'login'
51
+ empty_directory 'support'
52
+ template 'support/env.rb', 'support/env.rb'
53
+ template 'support/hooks.rb', 'support/hooks.rb'
54
+ template 'support/utils.rb', 'support/utils.rb'
55
+ template 'support/appium_custom.rb', 'support/appium_custom.rb'
56
+ end
57
+
58
+ inside 'features/login' do
59
+ empty_directory 'features'
60
+ template 'features/login.feature', 'features/login.feature'
61
+ empty_directory 'data'
62
+ template 'data/login.yaml','data/login.yaml'
63
+ empty_directory 'elements'
64
+ template 'elements/screen_mappings_home.yaml','elements/screen_mappings_home.yaml'
65
+ template 'elements/screen_mappings_login.yaml','elements/screen_mappings_login.yaml'
66
+ template 'elements/screen_mappings_organizadorhome.yaml','elements/screen_mappings_organizadorhome.yaml'
67
+ template 'elements/screen_mappings_token.yaml','elements/screen_mappings_token.yaml'
68
+ empty_directory 'pageobjects'
69
+ template 'pageobjects/home.rb','pageobjects/home.rb'
70
+ template 'pageobjects/login.rb','pageobjects/login.rb'
71
+ template 'pageobjects/loginPages.rb','pageobjects/loginPages.rb'
72
+ template 'pageobjects/organizadorHome.rb','pageobjects/organizadorHome.rb'
73
+ template 'pageobjects/token.rb','pageobjects/token.rb'
74
+ empty_directory 'steps'
75
+ template 'steps/login_steps.rb','steps/login_steps.rb'
76
+ end
77
+ end
78
+
79
+ def gemfile_rakefile_cukeyml
80
+ inside destination_root do
81
+ template 'Gemfile'
82
+ template 'Rakefile'
83
+ template 'cucumber.yml'
84
+ end
85
+ end
86
+
87
+ end
data/templates/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # frozen_string_literal: true
4
+
5
+ gem 'allure-cucumber'
6
+ gem 'appium_console'
7
+ gem 'appium_lib'
8
+ gem 'cucumber'
9
+ gem 'capybara'
10
+ gem 'pry'
11
+ gem 'rake'
12
+ gem 'selenium-webdriver'
13
+ gem 'rspec'
14
+ gem 'eventmachine'
15
+ gem 'rest-client'
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cucumber'
4
+ require 'cucumber/rake/task'
5
+
6
+ desc 'Testes com android local'
7
+ task :android_local,:tags do |t, args|
8
+ sh "bundle exec cucumber -p android_local -t #{args[:tags]}"
9
+ end
10
+
11
+ desc 'Testes com iOS local'
12
+ task :ios_local,:tags do |t, args|
13
+ sh "bundle exec cucumber -p ios_local -t #{args[:tags]}"
14
+ end
15
+
16
+ desc 'Testes com android farm'
17
+ task :android_farm,:tags do |t, args|
18
+ sh "bundle exec cucumber -p android_farm -t #{args[:tags]}"
19
+ end
20
+
21
+ desc 'Testes com iOS farm'
22
+ task :ios_farm,:tags do |t, args|
23
+ sh "bundle exec cucumber -p ios_farm -t #{args[:tags]}"
24
+ end
25
+
26
+
27
+
28
+
29
+
@@ -0,0 +1,6 @@
1
+
2
+ android_local: PLATFORM='android' WHERE='local' --format AllureCucumber::CucumberFormatter --out allure-results/android/
3
+ ios_local: PLATFORM='ios' WHERE='local' --format AllureCucumber::CucumberFormatter --out allure-results/ios/
4
+ android_farm: PLATFORM='android' WHERE='farm' --format AllureCucumber::CucumberFormatter --out allure-results/android/
5
+ ios_farm: PLATFORM='ios' WHERE='farm' --format AllureCucumber::CucumberFormatter --out allure-results/ios/
6
+ report: --format AllureCucumber::CucumberFormatter --out allure-results/android/
@@ -0,0 +1,310 @@
1
+ sucesso:
2
+ cpf: 57497189808
3
+ senha: 11223344
4
+ # cpf: 13226509004
5
+ # senha: 123456
6
+ invalido:
7
+ cpf: 12326509004
8
+ senha: 654321
9
+
10
+ ativacao:
11
+ cpf: 26862202014
12
+ senha: 123123
13
+
14
+ dxcAtivada:
15
+ cpf: 34297733692
16
+ senha: 103050
17
+ senhaCartao: 9800
18
+
19
+ ativada:
20
+ cpf: 37725787801
21
+ senha: 12341234
22
+ #cpf: 08948687212
23
+ #senha: 103050
24
+
25
+ cartaoPuro:
26
+ cpf: 80406360863
27
+ 4digitos: 6246
28
+ senhaCompra: 9377
29
+ novaSenha: 103050
30
+ repetirSenha: 103050
31
+ senha: 103050
32
+
33
+ reneg:
34
+ cpf: 72114606953
35
+ senha: 103050
36
+
37
+ negadaCartonista:
38
+ cpf: 34297733692
39
+ senha: 103050
40
+
41
+ negadaFinanciamento:
42
+ cpf: 54503709704
43
+ senha: 103050
44
+
45
+ aprovada:
46
+ cpf: 57439248139
47
+ senha: 103050
48
+
49
+ inconclusivoCartRG:
50
+ cpf: 14705214749
51
+ senha: 091017
52
+
53
+ inconclusivoCartCNH:
54
+ cpf: 82278534718
55
+ senha: 103050
56
+
57
+ inconclusivoFinRG:
58
+ cpf: 95300818712
59
+ senha: 091017
60
+
61
+ inconclusivoFinCNH:
62
+ cpf: 50437991296
63
+ senha: 091017
64
+
65
+ conta:
66
+ cpf: 11618476262
67
+ senha: 103050
68
+ senhaCartao: 1770
69
+
70
+ marAberto:
71
+ cpfDebito: 35315245772
72
+ cpfCredito: 25037315700
73
+ nome: teste bv
74
+ email: teste@teste.com.br
75
+ celular: 11992223391
76
+ nascimento: 01/01/2000
77
+ genero: masculino
78
+ documento: 101010
79
+ numCEP: 03344-000
80
+ numendereco: 32444
81
+ compEndereco: a
82
+ mae: mae do teste
83
+ ppe: nao
84
+ ocupacao: empresario
85
+ cartao: livre
86
+ bandeira: master
87
+ bairro:
88
+ renda: 1000000
89
+ nacionalidade: brasil
90
+ vencimento: 20
91
+
92
+ vitrineCartoes:
93
+ cpf: 14233377518
94
+ senha: 103050
95
+ nome: teste bv
96
+ email: teste@teste.com.br
97
+ celular: 11992223391
98
+ nascimento: 01/01/2000
99
+ genero: masculino
100
+ documento: 101010
101
+ numCEP: 05056-000
102
+ numendereco: 32444
103
+ compEndereco: a
104
+ mae: mae do teste
105
+ ppe: nao
106
+ ocupacao: empresario
107
+ cartao: livre
108
+ bandeira: master
109
+ bairro:
110
+ renda: 1000000
111
+ nacionalidade: brasil
112
+ vencimento: 20
113
+
114
+ cartoes:
115
+ cpf: 27646286338
116
+ senha: 103050
117
+ nome: teste bv
118
+ email: teste@teste.com.br
119
+ celular: 11992223391
120
+ nascimento: 01/01/2000
121
+ genero: masculino
122
+ documento: 101010
123
+ numCEP: 05056-000
124
+ numendereco: 32444
125
+ compEndereco: a
126
+ mae: mae do teste
127
+ ppe: sim
128
+ ocupacao: empresario
129
+ cartao: livre
130
+ bandeira: master
131
+ bairro:
132
+ renda: 1000000
133
+ nacionalidade: brasil
134
+ vencimento: 20
135
+
136
+ vitrineFinancimento:
137
+ cpf: 25713881857
138
+ senha: 091017
139
+ nome: teste bv
140
+ email: teste@teste.com.br
141
+ celular: 11992223391
142
+ nascimento: 01/01/2000
143
+ genero: masculino
144
+ documento: 101010
145
+ numCEP: 05056-000
146
+ numendereco: 32444
147
+ compEndereco: a
148
+ mae: mae do teste
149
+ ppe: nao
150
+ ocupacao: empresario
151
+ cartao: livre
152
+ bandeira: master
153
+ bairro:
154
+ renda: 1000000
155
+ nacionalidade: brasil
156
+ vencimento: 20
157
+
158
+ financiamento:
159
+ cpf: 28238626765
160
+ senha: 103050
161
+ nome: teste bv
162
+ email: teste@teste.com.br
163
+ celular: 11992223391
164
+ nascimento: 01/01/2000
165
+ genero: masculino
166
+ documento: 101010
167
+ numCEP: 05056-000
168
+ numendereco: 32444
169
+ compEndereco: a
170
+ mae: mae do teste
171
+ ppe: nao
172
+ ocupacao: empresario
173
+ cartao: unico
174
+ bandeira: visa
175
+ bairro:
176
+ renda: 1000000
177
+ nacionalidade: brasil
178
+ vencimento: 20
179
+
180
+ finMegvi:
181
+ cpf: 10046270841
182
+ senha: 103050
183
+ nome: teste bv
184
+ email: teste@teste.com.br
185
+ celular: 11992223391
186
+ nascimento: 01/01/2000
187
+ genero: masculino
188
+ documento: 101010
189
+ numCEP: 05056-000
190
+ numendereco: 32444
191
+ compEndereco: a
192
+ mae: mae do teste
193
+ ppe: nao
194
+ ocupacao: empresario
195
+ cartao: livre
196
+ bandeira: master
197
+ bairro:
198
+ renda: 1000000
199
+ nacionalidade: brasil
200
+ vencimento: 20
201
+
202
+ marMegvi:
203
+ cpf: 42973422191
204
+ nome: teste bv
205
+ email: teste@teste.com.br
206
+ celular: 11992223391
207
+ nascimento: 01/01/2000
208
+ genero: masculino
209
+ documento: 101010
210
+ numCEP: 03344-000
211
+ numendereco: 32444
212
+ compEndereco: a
213
+
214
+ resetCartMegvi:
215
+ cpf: 38567673208
216
+ 4digitos: 2810
217
+ senhaCompra: 7759
218
+ novaSenha: 103050
219
+ repetirSenha: 103050
220
+ nome: teste bv
221
+ email: teste@teste.com.br
222
+ celular: 11992223391
223
+ nascimento: 01/01/2000
224
+ genero: masculino
225
+ documento: 101010
226
+ numCEP: 05056-000
227
+ numendereco: 32444
228
+ compEndereco: a
229
+ mae: mae do teste
230
+ ppe: sim
231
+ ocupacao: empresario
232
+ cartao: livre
233
+ bandeira: master
234
+ bairro:
235
+ renda: 1000000
236
+ nacionalidade: brasil
237
+ vencimento: 20
238
+
239
+ cartoesMegvi:
240
+ cpf: 05532136955
241
+ senha: 103050
242
+ nome: teste bv
243
+ email: teste@teste.com.br
244
+ celular: 11992223391
245
+ nascimento: 01/01/2000
246
+ genero: masculino
247
+ documento: 101010
248
+ numCEP: 05056-000
249
+ numendereco: 32444
250
+ compEndereco: a
251
+ mae: mae do teste
252
+ ppe: sim
253
+ ocupacao: empresario
254
+ cartao: livre
255
+ bandeira: master
256
+ bairro:
257
+ renda: 1000000
258
+ nacionalidade: brasil
259
+ vencimento: 20
260
+
261
+ numMarAberto:
262
+ cpf: 75602066896
263
+ cartao: unico
264
+ bandeira: visa
265
+ mae: mae do teste
266
+ ppe: nao
267
+ ocupacao: empresario
268
+ cartao: unico
269
+ bandeira: visa
270
+ bairro:
271
+ renda: 1000000
272
+ nacionalidade: brasil
273
+ vencimento: 20
274
+
275
+ numFinanciamento:
276
+ cpf: 54503709704
277
+ senha: 103050
278
+ cartao: mais
279
+ bandeira: visa
280
+ mae: mae do teste
281
+ ppe: nao
282
+ ocupacao: empresario
283
+ cartao: unico
284
+ bandeira: visa
285
+ bairro:
286
+ renda: 1000000
287
+ nacionalidade: brasil
288
+ vencimento: 20
289
+
290
+ numCartoes:
291
+ cpf: 56090544000
292
+ senha: 103050
293
+ cartao: unico
294
+ bandeira: visa
295
+ nome: teste bv
296
+ email: teste@teste.com.br
297
+ celular: 11992223391
298
+ nascimento: 01/01/2000
299
+ genero: masculino
300
+ documento: 101010
301
+ numCEP: 03344-000
302
+ numendereco: 32444
303
+ compEndereco: a
304
+
305
+ funcionario:
306
+ cpf: 31713175835
307
+ senha: 103050
308
+
309
+ aberturaConta:
310
+ cpf: 91463948930
@@ -0,0 +1,35 @@
1
+ ios:
2
+ xxxx:
3
+ tipo_busca: :xpath
4
+ value: ""
5
+ xxxx:
6
+ tipo_busca: :id
7
+ value: ""
8
+ xxxx:
9
+ tipo_busca: :class
10
+ value: ""
11
+ xxxx:
12
+ tipo_busca: :accessibility_id
13
+ value: ""
14
+ android:
15
+ telaWalkThrough:
16
+ tipo_busca: :xpath
17
+ value: "//android.widget.ImageView[1]"
18
+ btnWalkThrough:
19
+ tipo_busca: :xpath
20
+ value: "//android.widget.Button[contains(@text, 'Vamos começar?') or contains(@content-desc, 'Vamos começar?')]"
21
+ imagemHome:
22
+ tipo_busca: :xpath
23
+ value: "//android.widget.ImageView[2]"
24
+ xxxx:
25
+ tipo_busca: :xpath
26
+ value: ""
27
+ xxxx:
28
+ tipo_busca: :id
29
+ value: ""
30
+ xxxx:
31
+ tipo_busca: :class
32
+ value: ""
33
+ xxxx:
34
+ tipo_busca: :accessibility_id
35
+ value: ""
@@ -0,0 +1,44 @@
1
+ ios:
2
+ x1:
3
+ tipo_busca: :xpath
4
+ value: ""
5
+ x2:
6
+ tipo_busca: :id
7
+ value: ""
8
+ x3:
9
+ tipo_busca: :class
10
+ value: ""
11
+ x4:
12
+ tipo_busca: :accessibility_id
13
+ value: ""
14
+ android:
15
+ campoCPF:
16
+ tipo_busca: :xpath
17
+ value: "//android.view.View[contains(@text,'Digite aqui') or contains(@content-desc,'Digite aqui')]"
18
+ preencherCpf:
19
+ tipo_busca: :xpath
20
+ value: "//android.widget.EditText"
21
+ preencherSenha:
22
+ tipo_busca: :xpath
23
+ value: "//android.widget.EditText[contains(@text,'Digite sua senha')]"
24
+ btnContinuar:
25
+ tipo_busca: :xpath
26
+ value: "//android.widget.Button[contains(@text,'Continuar') or contains(@content-desc,'Continuar')]"
27
+ btnAtivarAcessoBio:
28
+ tipo_busca: :xpath
29
+ value: "//android.widget.Button[contains(@text,'Ativar acesso por biometria') or contains(@content-desc,'Ativar acesso por biometria')]"
30
+ btnDeixarParaDepois:
31
+ tipo_busca: :xpath
32
+ value: "//android.view.View[contains(@text,'Deixar para depois') or contains(@content-desc,'Deixar para depois')]"
33
+ btnOkEntendiBio:
34
+ tipo_busca: :xpath
35
+ value: "//android.widget.Button[contains(@text,'Ok, entendi') or contains(@content-desc,'Ok, entendi')]"
36
+ x1:
37
+ tipo_busca: :id
38
+ value: ""
39
+ x2:
40
+ tipo_busca: :class
41
+ value: ""
42
+ x3:
43
+ tipo_busca: :accessibility_id
44
+ value: ""
@@ -0,0 +1,29 @@
1
+ ios:
2
+ xxxx:
3
+ tipo_busca: :xpath
4
+ value: ""
5
+ xxxx:
6
+ tipo_busca: :id
7
+ value: ""
8
+ xxxx:
9
+ tipo_busca: :class
10
+ value: ""
11
+ xxxx:
12
+ tipo_busca: :accessibility_id
13
+ value: ""
14
+ android:
15
+ perfil:
16
+ tipo_busca: :xpath
17
+ value: "//android.view.View"
18
+ logo:
19
+ tipo_busca: :xpath
20
+ value: "//android.widget.ImageView"
21
+ xxxx:
22
+ tipo_busca: :id
23
+ value: ""
24
+ xxxx:
25
+ tipo_busca: :class
26
+ value: ""
27
+ xxxx:
28
+ tipo_busca: :accessibility_id
29
+ value: ""
@@ -0,0 +1,30 @@
1
+ ios:
2
+ xxxx:
3
+ tipo_busca: :xpath
4
+ value: ""
5
+ xxxx:
6
+ tipo_busca: :id
7
+ value: ""
8
+ xxxx:
9
+ tipo_busca: :class
10
+ value: ""
11
+ xxxx:
12
+ tipo_busca: :accessibility_id
13
+ value: ""
14
+ android:
15
+ btnDeixarParaDepois:
16
+ tipo_busca: :xpath
17
+ value: "//android.view.View[contains(@text,'Deixar para depois') or contains(@content-desc,'Deixar para depois')]"
18
+ prevwIrTelaInicialencherCpf:
19
+ tipo_busca: :xpath
20
+ value: "//android.view.View[contains(@text,'Ir para a tela inicial') or contains(@content-desc,'Ir para a tela inicial')]"
21
+ xxxx:
22
+ tipo_busca: :id
23
+ value: ""
24
+ xxxx:
25
+ tipo_busca: :class
26
+ value: ""
27
+ xxxx:
28
+ tipo_busca: :accessibility_id
29
+ value: ""
30
+
@@ -0,0 +1,16 @@
1
+ #language: en
2
+ #encoding: utf-8
3
+
4
+ @login
5
+ Feature: Login
6
+
7
+ Background:
8
+ Given eu tenha as paginas necessárias iniciadas
9
+ And o arquivo de massa de dados
10
+
11
+ @login_valido
12
+ Scenario: Login efetuado com sucesso
13
+ Given que estou na tela inicial
14
+ When insiro as minhas credenciais de acesso
15
+ Then sou direcionado a home de Conta
16
+
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+ class HomePage
3
+
4
+ def initialize
5
+ get_screen_mappings 'home', 'login'
6
+ end
7
+
8
+ def is_home?
9
+ if $platform == 'android'
10
+ wait_for_element_exist(@mappings['imagemHome'])
11
+ end
12
+ if $platform == 'ios'
13
+ wait_for_element_exists(@mappings['imagemHome'])
14
+ find(@mappings['telaWalkThrough']).click
15
+ end
16
+ wait_for_element_exist(@mappings['telaWalkThrough'])
17
+ end
18
+
19
+ def pulaWalkThrough
20
+ swipe_orientation(@mappings['telaWalkThrough'], @mappings['btnWalkThrough'], "up")
21
+ find(@mappings['btnWalkThrough']).click
22
+ end
23
+ end
24
+
@@ -0,0 +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
+
52
+ end
@@ -0,0 +1,22 @@
1
+ class LoginPages
2
+
3
+ def home
4
+ HomePage.new
5
+ end
6
+
7
+ def login
8
+ LoginPage.new
9
+ end
10
+
11
+ def cadastrar
12
+ CadastrarPage.new
13
+ end
14
+
15
+ def token
16
+ TokenPage.new
17
+ end
18
+
19
+ def organizadorHome
20
+ OrganizadorHome.new
21
+ end
22
+ end
@@ -0,0 +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
+
@@ -0,0 +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
+
@@ -0,0 +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
@@ -0,0 +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
65
+ end
@@ -0,0 +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)
@@ -0,0 +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")
18
+ end
@@ -0,0 +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
metadata ADDED
@@ -0,0 +1,190 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-mobile-appium-template
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Roger Fernandes
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-03-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: cucumber-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: cucumber
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: selenium-webdriver
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: capybara
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: bundler
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: nokogiri
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: 'generates directory and required files for any type of project needing
140
+ to test with Ruby Mobile Appium '
141
+ email: roger.fernandess@hotmail.com
142
+ executables:
143
+ - ruby-mobile-appium-template
144
+ extensions: []
145
+ extra_rdoc_files: []
146
+ files:
147
+ - bin/ruby-mobile-appium-template
148
+ - lib/ruby_appium.rb
149
+ - templates/Gemfile
150
+ - templates/Rakefile
151
+ - templates/cucumber.yml
152
+ - templates/features/login/data/login.yaml
153
+ - templates/features/login/elements/screen_mappings_home.yaml
154
+ - templates/features/login/elements/screen_mappings_login.yaml
155
+ - templates/features/login/elements/screen_mappings_organizadorhome.yaml
156
+ - templates/features/login/elements/screen_mappings_token.yaml
157
+ - templates/features/login/features/login.feature
158
+ - templates/features/login/pageobjects/home.rb
159
+ - templates/features/login/pageobjects/login.rb
160
+ - templates/features/login/pageobjects/loginPages.rb
161
+ - templates/features/login/pageobjects/organizadorHome.rb
162
+ - templates/features/login/pageobjects/token.rb
163
+ - templates/features/login/steps/login_steps.rb
164
+ - templates/features/support/appium_custom.rb
165
+ - templates/features/support/env.rb
166
+ - templates/features/support/hooks.rb
167
+ - templates/features/support/utils.rb
168
+ homepage: http://github.com/rogerfernandess/ruby-mobile-appium-template
169
+ licenses: []
170
+ metadata: {}
171
+ post_install_message:
172
+ rdoc_options: []
173
+ require_paths:
174
+ - lib
175
+ required_ruby_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ required_rubygems_version: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - ">="
183
+ - !ruby/object:Gem::Version
184
+ version: '0'
185
+ requirements: []
186
+ rubygems_version: 3.2.3
187
+ signing_key:
188
+ specification_version: 4
189
+ summary: A basic archetype for a Ruby Mobile Appium
190
+ test_files: []