SurfCustomCalabash 0.2.0 → 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 +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +68 -4
- data/SurfCustomCalabash.gemspec +3 -3
- data/bin/SurfCustomCalabash +54 -0
- data/bin/surf-calabash-console.rb +62 -0
- data/bin/surf-calabash-gen.rb +17 -0
- data/bin/surf-calabash-helpers.rb +34 -0
- data/lib/SurfCustomCalabash/CommonMethods.rb +3 -3
- data/lib/SurfCustomCalabash/DroidMethods.rb +2 -1
- data/lib/SurfCustomCalabash/IosMethods.rb +2 -2
- data/lib/SurfCustomCalabash/version.rb +1 -1
- data/sources/Backdoors list b/data/sources/Backdoors → list +0 -0
- data/sources/Gemfile +27 -0
- data/sources/Scripts/and.sh +5 -0
- data/sources/Scripts/ca.sh +5 -0
- data/sources/Scripts/ci.sh +5 -0
- data/sources/Scripts/data +7 -0
- data/sources/Scripts/fa.sh +6 -0
- data/sources/Scripts/fi.sh +5 -0
- data/sources/Scripts/get_apk.rb +68 -0
- data/sources/Scripts/get_scenarios.rb +193 -0
- data/sources/Scripts/import_scenarios.rb +172 -0
- data/sources/Scripts/ios.sh +5 -0
- data/sources/Scripts/parallel_android_smoke.sh +4 -0
- data/sources/Scripts/parallel_android_test.sh +4 -0
- data/sources/Scripts/ra.sh +12 -0
- data/sources/Scripts/ri.sh +9 -0
- data/sources/Scripts/smoke_and.sh +5 -0
- data/sources/Scripts/smoke_ios.sh +5 -0
- data/sources/Scripts/ta.sh +5 -0
- data/sources/Scripts/ti.sh +5 -0
- data/sources/Scripts/to_exec.sh +19 -0
- data/sources/Scripts/update.sh +24 -0
- data/sources/Scripts/update_exec.rb +96 -0
- data/sources/TestFolder/small.gif +0 -0
- data/sources/ci/JenkinsfileUiTestAndroid.groovy +22 -0
- data/sources/ci/JenkinsfileUiTestIos.groovy +23 -0
- data/sources/config/cucumber.yml +24 -0
- data/sources/features/android/pages/standard/DroidCommon.rb +33 -0
- data/sources/features/android/pages/standard/Init_android.rb +8 -0
- data/sources/features/android/pages/test.rb +43 -0
- data/sources/features/android/support/app_life_cycle_hooks.rb +147 -0
- data/sources/features/android/support/log_hooks_and.rb +40 -0
- data/sources/features/android/support/video_hooks_and.rb +110 -0
- data/sources/features/ios/pages/standard/Init_ios.rb +5 -0
- data/sources/features/ios/pages/standard/IosCommon.rb +30 -0
- data/sources/features/ios/pages/test.rb +37 -0
- data/sources/features/ios/support/01_launch.rb +194 -0
- data/sources/features/ios/support/log_hooks_ios.rb +40 -0
- data/sources/features/ios/support/video_hooks_ios.rb +58 -0
- data/sources/features/net/net.rb +28 -0
- data/sources/features/net/screentest_api.rb +186 -0
- data/sources/features/scenarios/eng.feature +8 -0
- data/sources/features/scenarios/rus.feature +8 -0
- data/sources/features/step_definitions/test.rb +43 -0
- data/sources/features/support/credentials.rb +11 -0
- data/sources/features/support/env.rb +8 -0
- data/sources/features/support/hooks.rb +21 -0
- data/sources/features/support/localization.rb +8 -0
- data/sources/find_id.rb +95 -0
- data/sources/group_steps.rb +39 -0
- data/sources/irbrcs/android/irbrc +105 -0
- data/sources/irbrcs/ios/irbrc +132 -0
- data/sources/start.sh +134 -0
- metadata +63 -6
- data/bin/console +0 -14
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10324a3851f0d2c8a774575861c3489d6519d9a6fed70ac48244565ed9c03da6
|
4
|
+
data.tar.gz: 70572d7c07b601e2407cc9cf8e0d3317a680b919afb56faca9be2d3cb9f68f04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4092df2ff8c18a451ad3e0132accbb3eae2c66ee24526e43d7c0adfa51f17e47234f8573999d248df0de0eb24a91f264fed8cd1310a8784309e44eb5776bdc57
|
7
|
+
data.tar.gz: 89d7c2269fd6aa04b72eb58ace406dad941a2dcaf2ae84559729802ff1ea65e65e39db5d1902577e70df131b35f5e4e13f8abdebfe3b2054e798caa336eac22d
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Change Log
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
|
5
|
+
## v1.0.0 - 28.08.2020
|
6
|
+
### Added
|
7
|
+
- Changelog.md
|
8
|
+
- Added template file for initializing a new autotest project (use **SurfCustomCalabash gen**)
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
- method close_keybord can now be called with optional parameters **x_start** and **y_start** (by default **x_start:** 100, **y_start:** 150)
|
data/README.md
CHANGED
@@ -21,11 +21,75 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
This gem provides methods for easier use Calabash.
|
23
23
|
|
24
|
-
Install gem in your project, add
|
24
|
+
Install gem in your exist project, add in your ios or android ruby files.
|
25
25
|
|
26
|
-
IosCommon
|
26
|
+
$require 'SurfCustomCalabash/IosCommon'
|
27
|
+
|
28
|
+
$require 'SurfCustomCalabash/DroidCommon'
|
29
|
+
|
30
|
+
**IosCommon** contains custom swipe methods for ios.
|
31
|
+
|
32
|
+
**DroidCommon** contains custom swipe methods for android.
|
33
|
+
|
34
|
+
**CommonMethods** contains different methods (taps, swipes, waits and other) for both platforms.
|
35
|
+
|
36
|
+
### Create new project
|
37
|
+
You should move to the directory which would contains folder with your tests.
|
38
|
+
surf-calabash will create it by itself with the name **Change_it_to_your_own_project_name**:
|
39
|
+
|
40
|
+
$ SurfCustomCalabash gen
|
41
|
+
|
42
|
+
After that you'll see many folders inside them. Each of them will be describe below.
|
43
|
+
|
44
|
+
#### ci
|
45
|
+
|
46
|
+
It is used for all scripts for continuous integration. In Surfstudio we have .groovy files for them.
|
27
47
|
|
28
|
-
|
48
|
+
|
49
|
+
#### config
|
50
|
+
|
51
|
+
Contains only cucumber.yml file. It named arguments are called profiles - e.g. iOS or Android for run.
|
52
|
+
|
53
|
+
|
54
|
+
#### features
|
55
|
+
|
56
|
+
Main folder of all project. Every feature, step definition, support files and page objects are here. You can read about it more in each file of this folder.
|
57
|
+
|
58
|
+
|
59
|
+
#### irbrcs
|
60
|
+
|
61
|
+
Our own shtick. We change calabash-android console and calabash-ios console a little, so you can write your own complex functions, which you'll implement in the step_definitions or in page objects. So for the correct work we had to change irbrc-files of gems too.
|
62
|
+
|
63
|
+
#### reports
|
64
|
+
|
65
|
+
Folder with screenshots of errors.
|
66
|
+
|
67
|
+
|
68
|
+
#### test_servers
|
69
|
+
|
70
|
+
Standard calabash-android folder with signed apk-files.
|
71
|
+
|
72
|
+
#### TestFolder
|
73
|
+
|
74
|
+
Contains some additional files, e.g. jpg-pictures or other data which can be used in tests.
|
75
|
+
|
76
|
+
#### Backdoors list
|
77
|
+
|
78
|
+
We use backdoors for our applications for get around the limit of nativity of calabash.
|
79
|
+
|
80
|
+
#### Gemfile
|
81
|
+
|
82
|
+
All required gems for surf-calabash. You should run installing all gems by bundle after initializing project when you rename **Change_it_to_your_own_project_name** to your own name.
|
83
|
+
|
84
|
+
$bundle install
|
85
|
+
|
86
|
+
#### Scripts
|
87
|
+
|
88
|
+
Some shell scripts which can help to start tests faster because of typing smaller count of symbols. :)
|
89
|
+
Also it shows some integration with Xray Jira plugin.
|
90
|
+
|
91
|
+
#### start.sh
|
29
92
|
|
30
|
-
|
93
|
+
Shell script for useful launch all helpful scripts of folder above.
|
31
94
|
|
95
|
+
|
data/SurfCustomCalabash.gemspec
CHANGED
@@ -32,9 +32,9 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
33
33
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
34
34
|
end
|
35
|
-
spec.bindir = "exe"
|
36
|
-
spec.executables =
|
37
|
-
spec.require_paths = ["lib"]
|
35
|
+
# spec.bindir = "exe"
|
36
|
+
spec.executables = ["SurfCustomCalabash"]
|
37
|
+
# spec.require_paths = ["lib"]
|
38
38
|
|
39
39
|
spec.add_development_dependency "bundler", "~> 1.17"
|
40
40
|
spec.add_development_dependency "rake", "~> 10.0"
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
require 'rbconfig'
|
5
|
+
|
6
|
+
# for ruby 1.9.1 and earlier
|
7
|
+
unless defined? RbConfig.ruby
|
8
|
+
def RbConfig.ruby
|
9
|
+
File.join(RbConfig::CONFIG["bindir"], RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"])
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
require File.join(File.dirname(__FILE__), "surf-calabash-helpers")
|
14
|
+
|
15
|
+
@hierarchy = File.join(FileUtils.pwd, "Change_it_to_your_own_project_name")
|
16
|
+
@source_dir = File.join(File.dirname(__FILE__), '..', 'sources')
|
17
|
+
|
18
|
+
if ARGV.length == 0
|
19
|
+
print_usage
|
20
|
+
else
|
21
|
+
cmd = ARGV.shift
|
22
|
+
|
23
|
+
case cmd
|
24
|
+
when 'help'
|
25
|
+
print_help
|
26
|
+
when 'gen'
|
27
|
+
gen = File.join(File.dirname(__FILE__), "surf-calabash-gen")
|
28
|
+
require gen
|
29
|
+
surf_gen
|
30
|
+
when 'android_console'
|
31
|
+
require 'calabash-android/helpers'
|
32
|
+
require 'calabash-android/utils'
|
33
|
+
require 'calabash-android/java_keystore'
|
34
|
+
require 'calabash-android/env'
|
35
|
+
require File.join(File.dirname(__FILE__), "surf-calabash-console")
|
36
|
+
|
37
|
+
if ARGV.empty? or not is_apk_file?(ARGV.first)
|
38
|
+
Kernel.puts "The first parameter must be the path to the apk file."
|
39
|
+
exit 1
|
40
|
+
else
|
41
|
+
android_console(relative_to_full_path(ARGV.shift))
|
42
|
+
end
|
43
|
+
|
44
|
+
when 'ios_console'
|
45
|
+
require File.join(File.dirname(__FILE__), "surf-calabash-console")
|
46
|
+
ios_console
|
47
|
+
when 'version'
|
48
|
+
require_relative '../lib/SurfCustomCalabash/version'
|
49
|
+
Kernel.puts SurfCustomCalabash::VERSION
|
50
|
+
else
|
51
|
+
Kernel.puts "Invalid command '#{cmd}'"
|
52
|
+
print_usage
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
require 'rbconfig'
|
5
|
+
|
6
|
+
def android_console(app_path = nil)
|
7
|
+
test_server_path = test_server_path(app_path)
|
8
|
+
|
9
|
+
path = ENV['CALABASH_IRBRC']
|
10
|
+
Kernel.puts(path)
|
11
|
+
|
12
|
+
unless path
|
13
|
+
if File.exist?('irbrc')
|
14
|
+
path = File.expand_path('irbrc')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
unless path
|
19
|
+
path = File.expand_path(File.join(File.dirname(__FILE__), '../sources/irbrcs/android', 'irbrc'))
|
20
|
+
end
|
21
|
+
|
22
|
+
ENV['IRBRC'] = path
|
23
|
+
Kernel.puts(path)
|
24
|
+
|
25
|
+
unless ENV['APP_PATH']
|
26
|
+
ENV['APP_PATH'] = app_path
|
27
|
+
end
|
28
|
+
|
29
|
+
unless ENV['TEST_APP_PATH']
|
30
|
+
ENV['TEST_APP_PATH'] = test_server_path
|
31
|
+
end
|
32
|
+
|
33
|
+
build_test_server_if_needed(app_path)
|
34
|
+
|
35
|
+
Kernel.puts 'Starting calabash-android console...'
|
36
|
+
Kernel.puts "Loading #{ENV['IRBRC']}"
|
37
|
+
Kernel.puts 'Running irb...'
|
38
|
+
exec('irb')
|
39
|
+
end
|
40
|
+
|
41
|
+
def is_apk_file?(file_path)
|
42
|
+
file_path.end_with? ".apk" and File.exist? file_path
|
43
|
+
end
|
44
|
+
|
45
|
+
def relative_to_full_path(file_path)
|
46
|
+
File.expand_path(file_path)
|
47
|
+
end
|
48
|
+
|
49
|
+
def ios_console
|
50
|
+
path = ENV['CALABASH_IRBRC']
|
51
|
+
unless path
|
52
|
+
if File.exist?('.irbrc')
|
53
|
+
path = File.expand_path('.irbrc')
|
54
|
+
end
|
55
|
+
end
|
56
|
+
unless path
|
57
|
+
path = File.expand_path(File.join(File.dirname(__FILE__), '../sources/irbrcs/ios', 'irbrc'))
|
58
|
+
end
|
59
|
+
ENV['IRBRC'] = path
|
60
|
+
puts "Running irb..."
|
61
|
+
exec("irb")
|
62
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
def surf_gen
|
2
|
+
if File.exists?(@hierarchy)
|
3
|
+
Kernel.puts "hierarchy is already created. Stopping..."
|
4
|
+
exit 1
|
5
|
+
end
|
6
|
+
msg("Question") do
|
7
|
+
Kernel.puts "I'm about to create a subdirectory called sources."
|
8
|
+
Kernel.puts "Please change name of it to name of your own project."
|
9
|
+
Kernel.puts "Please hit return to confirm that's what you want."
|
10
|
+
end
|
11
|
+
exit 2 unless STDIN.gets.chomp == ''
|
12
|
+
|
13
|
+
FileUtils.cp_r(@source_dir, @hierarchy)
|
14
|
+
msg("Info") do
|
15
|
+
Kernel.puts "hierarchy was created. \n"
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
require 'json'
|
3
|
+
require "rubygems"
|
4
|
+
|
5
|
+
def msg(title, &block)
|
6
|
+
Kernel.puts "\n" + "-"*10 + title + "-"*10
|
7
|
+
block.call
|
8
|
+
Kernel.puts "-"*10 + "-------" + "-"*10 + "\n"
|
9
|
+
end
|
10
|
+
|
11
|
+
def print_usage
|
12
|
+
Kernel.puts <<EOF
|
13
|
+
Usage: SurfCustomCalabash <command-name> [parameters] [options]
|
14
|
+
<command-name> can be one of
|
15
|
+
help
|
16
|
+
prints more detailed help information.
|
17
|
+
gen
|
18
|
+
generate a features folder structure.
|
19
|
+
version
|
20
|
+
prints the gem version
|
21
|
+
|
22
|
+
<options> can be
|
23
|
+
-v, --verbose
|
24
|
+
Turns on verbose logging
|
25
|
+
EOF
|
26
|
+
end
|
27
|
+
|
28
|
+
def print_help
|
29
|
+
print_usage
|
30
|
+
end
|
31
|
+
|
32
|
+
def is_json?(str)
|
33
|
+
str[0..0] == '{'
|
34
|
+
end
|
@@ -209,7 +209,7 @@ def remember(element, sleep_duration: 1, timeout_duration: 5)
|
|
209
209
|
wait_element(element, sleep_duration: sleep_duration, timeout_duration: timeout_duration)
|
210
210
|
name = query(element)
|
211
211
|
save_name = name.first['text']
|
212
|
-
puts(save_name)
|
212
|
+
Kernel.puts(save_name)
|
213
213
|
return save_name
|
214
214
|
end
|
215
215
|
|
@@ -218,7 +218,7 @@ def remember_last_text(element, sleep_duration: 1, timeout_duration: 5)
|
|
218
218
|
wait_element(element, sleep_duration: sleep_duration, timeout_duration: timeout_duration)
|
219
219
|
name = query(element)
|
220
220
|
save_name = name.last['text']
|
221
|
-
puts(save_name)
|
221
|
+
Kernel.puts(save_name)
|
222
222
|
return save_name
|
223
223
|
end
|
224
224
|
|
@@ -273,7 +273,7 @@ def cross_coordinate(element_front, element_behind, delta: 100)
|
|
273
273
|
cross = false
|
274
274
|
end
|
275
275
|
end
|
276
|
-
# puts(cross)
|
276
|
+
# Kernel.puts(cross)
|
277
277
|
return cross
|
278
278
|
end
|
279
279
|
|
@@ -2,9 +2,9 @@ require 'calabash-cucumber/ibase'
|
|
2
2
|
require 'SurfCustomCalabash/CommonMethods'
|
3
3
|
|
4
4
|
# close keyboard with a swipe of the screen
|
5
|
-
def close_keyboard
|
5
|
+
def close_keyboard(x_start: 100, y_start: 150)
|
6
6
|
if keyboard_visible?
|
7
|
-
pan_coordinates({x:
|
7
|
+
pan_coordinates({x: x_start, y: y_start}, {x: x_start, y: y_start+100})
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
File without changes
|
data/sources/Gemfile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
6
|
+
|
7
|
+
gem 'calabash-android'
|
8
|
+
gem 'cucumber'
|
9
|
+
gem 'calabash-cucumber'
|
10
|
+
gem 'require_all'
|
11
|
+
gem 'rake'
|
12
|
+
gem 'pry'
|
13
|
+
gem 'parallel_calabash'
|
14
|
+
gem 'json', '1.8.6'
|
15
|
+
gem 'test-unit'
|
16
|
+
gem 'CFPropertyList', '2.2.8'
|
17
|
+
gem 'rest-client'
|
18
|
+
gem 'syntax'
|
19
|
+
gem 'httpclient', '2.8.3'
|
20
|
+
gem 'run_loop', '>=4.4.1'
|
21
|
+
gem 'SurfCustomCalabash'
|
22
|
+
gem 'open3'
|
23
|
+
gem 'timeout'
|
24
|
+
gem 'process'
|
25
|
+
gem 'rspec'
|
26
|
+
gem 'streamio-ffmpeg'
|
27
|
+
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'base64'
|
3
|
+
require 'nokogiri'
|
4
|
+
require 'open-uri'
|
5
|
+
|
6
|
+
class GetApk
|
7
|
+
|
8
|
+
def initialize(path)
|
9
|
+
# хэш со всеми данными из файла scripts/data
|
10
|
+
@all_data = get_all_data
|
11
|
+
|
12
|
+
# название проекта в дженкинсе
|
13
|
+
@project = @all_data['project_name_jenkins']
|
14
|
+
|
15
|
+
# название джоба для сборки в дженкинсе
|
16
|
+
@job_name = "#{@project}_Android_TAG"
|
17
|
+
|
18
|
+
# адрес дженкинса
|
19
|
+
@host = "https://jenkins.surfstudio.ru/view/Projects/view/#{@project}/job/#{@job_name}/lastSuccessfulBuild"
|
20
|
+
|
21
|
+
# логин в дженкинсе
|
22
|
+
@login = @all_data['login']
|
23
|
+
|
24
|
+
# пароль дженкинса
|
25
|
+
@password = @all_data['jenkins_pass']
|
26
|
+
|
27
|
+
# путь до папки с автотестами
|
28
|
+
@path = path
|
29
|
+
|
30
|
+
# токен в дженкинсе
|
31
|
+
@auth = 'Basic ' + Base64.encode64( "#{@login}:#{@password}" ).chomp
|
32
|
+
end
|
33
|
+
|
34
|
+
# считываем данные пользователя из файла
|
35
|
+
def get_all_data
|
36
|
+
Hash[*File.read("#{@path}scripts/data").split(/[, \n]+/)]
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_path_to_apk
|
40
|
+
url = "#{@host}/api/xml?tree=artifacts%5BrelativePath%5D"
|
41
|
+
|
42
|
+
response = RestClient.get url, {:Authorization => @auth}
|
43
|
+
|
44
|
+
xml_parse = Nokogiri::XML(response)
|
45
|
+
|
46
|
+
all_path = xml_parse.xpath("//relativePath")
|
47
|
+
|
48
|
+
all_path.each do |path|
|
49
|
+
@path_to_apk = path.content unless path.content[/qa.*\.apk$/].nil?
|
50
|
+
end
|
51
|
+
|
52
|
+
Kernel.puts(@path_to_apk)
|
53
|
+
|
54
|
+
return @path_to_apk
|
55
|
+
end
|
56
|
+
|
57
|
+
def download_apk
|
58
|
+
path = get_path_to_apk
|
59
|
+
url = "#{@host}/artifact/#{path}"
|
60
|
+
|
61
|
+
Kernel.puts('Start download')
|
62
|
+
File.open('L.apk', "wb") do |file|
|
63
|
+
file.write open(url, :http_basic_authentication => [@login, @password]).read
|
64
|
+
end
|
65
|
+
|
66
|
+
Kernel.puts('End download')
|
67
|
+
end
|
68
|
+
end
|