SurfCustomCalabash 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +21 -0
- data/README.md +31 -0
- data/Rakefile +10 -0
- data/SurfCustomCalabash.gemspec +42 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/SurfCustomCalabash.rb +9 -0
- data/lib/SurfCustomCalabash/CommonMethods.rb +216 -0
- data/lib/SurfCustomCalabash/DroidCommon.rb +104 -0
- data/lib/SurfCustomCalabash/IosCommon.rb +104 -0
- data/lib/SurfCustomCalabash/version.rb +3 -0
- metadata +104 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8782b3ba7379e77beba7c31b9228786433cc91fd
|
4
|
+
data.tar.gz: ecdc8ed6ea807fb080178260f3d8804f3d563e4a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 699a83b0f4263972ccabe4e79853d025e0d0d6b2bbbf4357f5b0ea846583f48ffb5cc560283f63499060fb8e17505666a1d22d8f6625e9b0be396d1613747166
|
7
|
+
data.tar.gz: 4fba7507932a38fa1df61b3e738ca81392c752959321e98eb7aabad81ae583f5315d0dab729e62121bbd78d5363a9a330dca211cfa329840b168a793b47a436d
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at hripunov@surfstudio.ru. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Алексей Хрипунов
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# SurfCustomCalabash
|
2
|
+
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
gem 'SurfCustomCalabash'
|
10
|
+
```
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install SurfCustomCalabash
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
This gem provides methods for easier use Calabash.
|
23
|
+
|
24
|
+
Install gem in your project, add require 'SurfCustomCalabash/IosCommon' and 'SurfCustomCalabash/DroidCommon' in your ios or android ruby files.
|
25
|
+
|
26
|
+
IosCommon contains custom swipe methods for ios.
|
27
|
+
|
28
|
+
DroidCommon contains custom swipe methods for android.
|
29
|
+
|
30
|
+
CommonMethods contains different methods (taps, swipes, waits and other) for both platforms.
|
31
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "SurfCustomCalabash/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "SurfCustomCalabash"
|
8
|
+
spec.version = SurfCustomCalabash::VERSION
|
9
|
+
spec.authors = ["Alexey Hripunov"]
|
10
|
+
spec.email = ["hripunov@surfstudio.ru"]
|
11
|
+
|
12
|
+
spec.summary = "Custom methods for calabash ios and android"
|
13
|
+
spec.description = "Custom methods for calabash ios and android"
|
14
|
+
spec.homepage = "https://github.com/alexeyhripunov/SurfCustomCalabash"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata["allowed_push_host"] = "http://rubygems.org"
|
21
|
+
|
22
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
23
|
+
spec.metadata["source_code_uri"] = "https://github.com/alexeyhripunov/SurfCustomCalabash"
|
24
|
+
spec.metadata["changelog_uri"] = "https://github.com/alexeyhripunov/SurfCustomCalabash"
|
25
|
+
else
|
26
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
27
|
+
"public gem pushes."
|
28
|
+
end
|
29
|
+
|
30
|
+
# Specify which files should be added to the gem when it is released.
|
31
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
32
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
33
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
34
|
+
end
|
35
|
+
spec.bindir = "exe"
|
36
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
37
|
+
spec.require_paths = ["lib"]
|
38
|
+
|
39
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
40
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
41
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
42
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "SurfCustomCalabash"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,216 @@
|
|
1
|
+
require 'unicode'
|
2
|
+
|
3
|
+
module CommonMethods
|
4
|
+
|
5
|
+
|
6
|
+
def enter_text(text)
|
7
|
+
wait_for_keyboard(:timeout=>5)
|
8
|
+
keyboard_enter_text(text)
|
9
|
+
end
|
10
|
+
|
11
|
+
# ----------------------------------------------Custom Taps-----------------------------------------------------------
|
12
|
+
# wait element and tap
|
13
|
+
def tap_on(element)
|
14
|
+
wait_for_elements_exist(element, :timeout=>15, :retry_frequency=>5)
|
15
|
+
sleep(0.5)
|
16
|
+
touch(element)
|
17
|
+
end
|
18
|
+
|
19
|
+
def tap_on_text(text)
|
20
|
+
tap_on("* {text CONTAINS'#{text}'}")
|
21
|
+
end
|
22
|
+
|
23
|
+
# if element exists - tap, if not - swipe until element exists and tap
|
24
|
+
def tap_or_swipe(element)
|
25
|
+
if element_exists(element)
|
26
|
+
sleep(1)
|
27
|
+
touch(element)
|
28
|
+
else
|
29
|
+
until_element_exists(element,:action => lambda{light_swipe('down')}, :timeout => 30)
|
30
|
+
touch(element)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# ----------------------------------------------------Custom Waits----------------------------------------------------
|
35
|
+
def wait_element(element)
|
36
|
+
wait_for_element_exists(element, :timeout=>15)
|
37
|
+
end
|
38
|
+
|
39
|
+
def wait_no_element(element)
|
40
|
+
wait_for_element_does_not_exist(element, :timeout=>15)
|
41
|
+
end
|
42
|
+
|
43
|
+
def strong_swipe_until_not_exist(dir, element_destination)
|
44
|
+
until_element_does_not_exist(element_destination,
|
45
|
+
:action => lambda{strong_swipe(dir)})
|
46
|
+
end
|
47
|
+
|
48
|
+
def normal_swipe_until_not_exist(dir, element_destination)
|
49
|
+
until_element_does_not_exist(element_destination,
|
50
|
+
:action => lambda{normal_swipe(dir)})
|
51
|
+
end
|
52
|
+
|
53
|
+
def light_swipe_until_not_exist(dir, element_destination)
|
54
|
+
until_element_does_not_exist(element_destination,
|
55
|
+
:action => lambda{light_swipe( dir)})
|
56
|
+
end
|
57
|
+
|
58
|
+
def strong_swipe_until_exists(dir, element_destination)
|
59
|
+
until_element_exists(element_destination,
|
60
|
+
:action => lambda{strong_swipe( dir)})
|
61
|
+
end
|
62
|
+
|
63
|
+
def normal_swipe_until_exists(dir, element_destination)
|
64
|
+
until_element_exists(element_destination,
|
65
|
+
:action => lambda{normal_swipe( dir); sleep(2)}, :timeout=>40)
|
66
|
+
end
|
67
|
+
|
68
|
+
def light_swipe_until_exists(dir, element_destination)
|
69
|
+
until_element_exists(element_destination,
|
70
|
+
:action => lambda{light_swipe( dir); sleep(2)}, :timeout=>60)
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
def strong_swipe_element_until_exists(dir, element, element_destination)
|
75
|
+
until_element_exists(element_destination,
|
76
|
+
:action => lambda{strong_swipe_element(element, dir)})
|
77
|
+
end
|
78
|
+
|
79
|
+
def light_swipe_element_until_exists(dir, element, element_destination)
|
80
|
+
until_element_exists(element_destination,
|
81
|
+
:action => lambda{light_swipe_element(element, dir)}, :timeout=>70)
|
82
|
+
end
|
83
|
+
|
84
|
+
def strong_swipe_element_until_not_exists(dir, element, element_destination)
|
85
|
+
until_element_does_not_exist(element_destination,
|
86
|
+
:action => lambda{pan(element, dir)})
|
87
|
+
end
|
88
|
+
|
89
|
+
def light_swipe_element_until_not_exists(dir, element, element_destination)
|
90
|
+
until_element_does_not_exist(element_destination,
|
91
|
+
:action => lambda{light_swipe_element(element, dir)}, :timeout=>70)
|
92
|
+
end
|
93
|
+
|
94
|
+
def swipe_to_text(dir, text)
|
95
|
+
sleep(1)
|
96
|
+
if dir == 'вверх'
|
97
|
+
until_element_exists("* {text CONTAINS'#{text}'}", :action => lambda{light_swipe('up'); sleep(1)}, :timeout => 60)
|
98
|
+
elsif dir == 'вниз'
|
99
|
+
until_element_exists("* {text CONTAINS'#{text}'}", :action => lambda{light_swipe('down'); sleep(1.5)}, :timeout => 60)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# -------------------------------------------------Asserts------------------------------------------------------------
|
104
|
+
def assert_eql_with_rescue(element1, element2)
|
105
|
+
begin
|
106
|
+
expect(element1).to eq(element2)
|
107
|
+
true
|
108
|
+
rescue Exception => e
|
109
|
+
false
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def assert_eql(element1, element2)
|
114
|
+
expect(element1).to eq(element2)
|
115
|
+
end
|
116
|
+
|
117
|
+
def assert_not_eql(element1, element2)
|
118
|
+
expect(element1).not_to eql(element2)
|
119
|
+
end
|
120
|
+
|
121
|
+
def assert_true(element)
|
122
|
+
expect(element).to be true
|
123
|
+
end
|
124
|
+
|
125
|
+
def assert_false(element)
|
126
|
+
expect(element).to be false
|
127
|
+
end
|
128
|
+
|
129
|
+
def assert_nil(element)
|
130
|
+
expect(element).to be_nil
|
131
|
+
end
|
132
|
+
|
133
|
+
# ------------------------------------------Generate String-----------------------------------------------------------
|
134
|
+
def get_random_num_string(length)
|
135
|
+
source=(0..9).to_a
|
136
|
+
key=""
|
137
|
+
length.times{ key += source[rand(source.size)].to_s }
|
138
|
+
return key
|
139
|
+
end
|
140
|
+
|
141
|
+
def get_random_text_string(length)
|
142
|
+
source=("a".."z").to_a
|
143
|
+
key=""
|
144
|
+
length.times{ key += source[rand(source.size)].to_s }
|
145
|
+
return key
|
146
|
+
end
|
147
|
+
|
148
|
+
def get_random_email
|
149
|
+
return get_random_text_string(7) + "@" + get_random_text_string(2) + ".test"
|
150
|
+
end
|
151
|
+
|
152
|
+
def down_case(text)
|
153
|
+
Unicode::downcase text
|
154
|
+
end
|
155
|
+
|
156
|
+
def up_case(text)
|
157
|
+
Unicode::upcase text
|
158
|
+
end
|
159
|
+
|
160
|
+
# get text from first element
|
161
|
+
def remember(element)
|
162
|
+
wait_for_element_exists(element, :timeout => 5)
|
163
|
+
sleep(1.5)
|
164
|
+
name = query(element)
|
165
|
+
save_name = name.first['text']
|
166
|
+
puts(save_name)
|
167
|
+
return save_name
|
168
|
+
end
|
169
|
+
|
170
|
+
# get text from last element
|
171
|
+
def remember_last_text(element)
|
172
|
+
wait_for_element_exists(element, :timeout => 5)
|
173
|
+
sleep(1.5)
|
174
|
+
name = query(element)
|
175
|
+
save_name = name.last['text']
|
176
|
+
puts(save_name)
|
177
|
+
return save_name
|
178
|
+
end
|
179
|
+
|
180
|
+
# wait text
|
181
|
+
def check_text(text)
|
182
|
+
wait_for_element_exists("* {text CONTAINS'#{text}'}", :timeout => 5, :retry_frequency => 2)
|
183
|
+
end
|
184
|
+
|
185
|
+
def no_check_text(text)
|
186
|
+
wait_for_element_does_not_exist("* {text CONTAINS'#{text}'}", :timeout => 5, :retry_frequency => 5)
|
187
|
+
end
|
188
|
+
|
189
|
+
# get element coordinate
|
190
|
+
def get_coordinate(element)
|
191
|
+
el = query(element)
|
192
|
+
coordinate = el[0]['rect']['center_y']
|
193
|
+
# puts(coordinate)
|
194
|
+
return coordinate.to_i
|
195
|
+
end
|
196
|
+
|
197
|
+
# if elements cross - return true, if not - false
|
198
|
+
def cross_coordinate(element_front, element_behind)
|
199
|
+
cross = false
|
200
|
+
|
201
|
+
if element_exists(element_front) && element_exists(element_behind)
|
202
|
+
coordinate_front = get_coordinate(element_front)
|
203
|
+
coordinate_behind = get_coordinate(element_behind)
|
204
|
+
delta = 100
|
205
|
+
|
206
|
+
if coordinate_front < coordinate_behind + delta
|
207
|
+
cross = true
|
208
|
+
else
|
209
|
+
cross = false
|
210
|
+
end
|
211
|
+
end
|
212
|
+
# puts(cross)
|
213
|
+
return cross
|
214
|
+
end
|
215
|
+
|
216
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'calabash-android'
|
2
|
+
require 'rspec/expectations'
|
3
|
+
require 'SurfCustomCalabash/CommonMethods'
|
4
|
+
|
5
|
+
class DroidCommon
|
6
|
+
|
7
|
+
include Calabash::Android::Operations
|
8
|
+
include CommonMethods
|
9
|
+
|
10
|
+
def initialize(driver)
|
11
|
+
@driver = driver
|
12
|
+
end
|
13
|
+
|
14
|
+
def method_missing (sym, *args, &block)
|
15
|
+
@driver.send sym, *args, &block
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.element(name, &block)
|
19
|
+
define_method(name.to_s, &block)
|
20
|
+
end
|
21
|
+
|
22
|
+
class << self
|
23
|
+
alias :value :element
|
24
|
+
alias :action :element
|
25
|
+
alias :trait :element
|
26
|
+
end
|
27
|
+
|
28
|
+
def close_keyboard
|
29
|
+
if keyboard_visible?
|
30
|
+
hide_soft_keyboard
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
#----------------------------------------------Custom Android Swipe---------------------------------------------------
|
35
|
+
def strong_swipe(dr)
|
36
|
+
if dr == "up"
|
37
|
+
perform_action('drag', 50, 50, 15, 75, 4)
|
38
|
+
elsif dr == "down"
|
39
|
+
perform_action('drag', 50, 50, 60, 5, 1)
|
40
|
+
elsif dr == "left"
|
41
|
+
perform_action('drag', 90, 0, 50, 50, 10)
|
42
|
+
elsif dr == "right"
|
43
|
+
perform_action('drag', 0, 90, 50, 50, 10)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def normal_swipe(dr)
|
48
|
+
if dr == "up"
|
49
|
+
perform_action('drag', 50, 50, 45, 80, 10)
|
50
|
+
elsif dr == "down"
|
51
|
+
perform_action('drag', 50, 50, 80, 45, 10)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def light_swipe(dr)
|
56
|
+
if dr == "down"
|
57
|
+
perform_action('drag', 50, 50, 80, 70, 10)
|
58
|
+
elsif dr == "up"
|
59
|
+
perform_action('drag', 50, 50, 70, 80, 5)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def strong_swipe_element(element, dir)
|
64
|
+
if dir == 'left'
|
65
|
+
flick(element, :left)
|
66
|
+
elsif dir == 'right'
|
67
|
+
flick(element, :right)
|
68
|
+
elsif dir == 'down'
|
69
|
+
flick(element, :up)
|
70
|
+
elsif dir == 'up'
|
71
|
+
flick(element, :down)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def normal_swipe_element(element, dir)
|
76
|
+
if dir == 'left'
|
77
|
+
pan(element, :left)
|
78
|
+
elsif dir == 'right'
|
79
|
+
pan(element, :right)
|
80
|
+
elsif dir == 'down'
|
81
|
+
pan(element, :up)
|
82
|
+
elsif dir == 'up'
|
83
|
+
pan(element, :down)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def light_swipe_element(element, dir)
|
88
|
+
if dir == 'left'
|
89
|
+
pan(element, :left)
|
90
|
+
elsif dir == 'right'
|
91
|
+
pan(element, :right)
|
92
|
+
elsif dir == 'down'
|
93
|
+
pan(element, :up)
|
94
|
+
elsif dir == 'up'
|
95
|
+
pan(element, :down)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# pull-to-refresh screen
|
100
|
+
def ptr
|
101
|
+
perform_action('drag', 50, 50, 15, 75, 4)
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'calabash-cucumber/ibase'
|
2
|
+
require 'SurfCustomCalabash/CommonMethods'
|
3
|
+
|
4
|
+
class IosCommon < Calabash::IBase
|
5
|
+
|
6
|
+
include CommonMethods
|
7
|
+
|
8
|
+
def initialize(driver)
|
9
|
+
@driver = driver
|
10
|
+
end
|
11
|
+
|
12
|
+
def method_missing (sym, *args, &block)
|
13
|
+
@driver.send sym, *args, &block
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.element(name, &block)
|
17
|
+
define_method(name.to_s, &block)
|
18
|
+
end
|
19
|
+
|
20
|
+
class << self
|
21
|
+
alias :value :element
|
22
|
+
alias :action :element
|
23
|
+
alias :trait :element
|
24
|
+
end
|
25
|
+
|
26
|
+
#----------------------------------------------Custom Swipe iOS-------------------------------------------------------
|
27
|
+
def strong_swipe(dir)
|
28
|
+
if dir == 'left'
|
29
|
+
swipe :left, force: :strong
|
30
|
+
elsif dir == 'right'
|
31
|
+
swipe :right, force: :strong
|
32
|
+
elsif dir == 'up'
|
33
|
+
swipe :down, force: :strong
|
34
|
+
elsif dir == 'down'
|
35
|
+
swipe :up, force: :strong
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def normal_swipe(dir)
|
40
|
+
if dir == 'left'
|
41
|
+
swipe :left, force: :normal
|
42
|
+
elsif dir == 'right'
|
43
|
+
swipe :right, force: :normal
|
44
|
+
elsif dir == 'up'
|
45
|
+
swipe :down, force: :normal
|
46
|
+
elsif dir == 'down'
|
47
|
+
swipe :up, force: :normal
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def light_swipe(dir)
|
52
|
+
if dir == 'left'
|
53
|
+
swipe :left, force: :light
|
54
|
+
elsif dir == 'right'
|
55
|
+
swipe :right, force: :light
|
56
|
+
elsif dir == 'up'
|
57
|
+
swipe :down, force: :light
|
58
|
+
elsif dir == 'down'
|
59
|
+
swipe :up, force: :light
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def strong_swipe_element(element, dir)
|
64
|
+
if dir == 'left'
|
65
|
+
swipe :left, :query => element, force: :strong
|
66
|
+
elsif dir == 'right'
|
67
|
+
swipe :right, :query => element, force: :strong
|
68
|
+
elsif dir == 'up'
|
69
|
+
swipe :down, :query => element, force: :strong
|
70
|
+
elsif dir == 'down'
|
71
|
+
swipe :up, :query => element, force: :strong
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def normal_swipe_element(element, dir)
|
76
|
+
if dir == 'left'
|
77
|
+
swipe :left, :query => element, force: :normal
|
78
|
+
elsif dir == 'right'
|
79
|
+
swipe :right, :query => element, force: :normal
|
80
|
+
elsif dir == 'up'
|
81
|
+
swipe :down, :query => element, force: :normal
|
82
|
+
elsif dir == 'down'
|
83
|
+
swipe :up, :query => element, force: :normal
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def light_swipe_element(element, dir)
|
88
|
+
if dir == 'left'
|
89
|
+
swipe :left, :query => element, force: :light
|
90
|
+
elsif dir == 'right'
|
91
|
+
swipe :right, :query => element, force: :light
|
92
|
+
elsif dir == 'up'
|
93
|
+
swipe :down, :query => element, force: :light
|
94
|
+
elsif dir == 'down'
|
95
|
+
swipe :up, :query => element, force: :light
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# pull-to-refresh screen
|
100
|
+
def ptr
|
101
|
+
swipe(:down, :offset => {:x => 0, :y => -200})
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: SurfCustomCalabash
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexey Hripunov
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-01-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
description: Custom methods for calabash ios and android
|
56
|
+
email:
|
57
|
+
- hripunov@surfstudio.ru
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- CODE_OF_CONDUCT.md
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- SurfCustomCalabash.gemspec
|
70
|
+
- bin/console
|
71
|
+
- bin/setup
|
72
|
+
- lib/SurfCustomCalabash.rb
|
73
|
+
- lib/SurfCustomCalabash/CommonMethods.rb
|
74
|
+
- lib/SurfCustomCalabash/DroidCommon.rb
|
75
|
+
- lib/SurfCustomCalabash/IosCommon.rb
|
76
|
+
- lib/SurfCustomCalabash/version.rb
|
77
|
+
homepage: https://github.com/alexeyhripunov/SurfCustomCalabash
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata:
|
81
|
+
homepage_uri: https://github.com/alexeyhripunov/SurfCustomCalabash
|
82
|
+
source_code_uri: https://github.com/alexeyhripunov/SurfCustomCalabash
|
83
|
+
changelog_uri: https://github.com/alexeyhripunov/SurfCustomCalabash
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 2.5.2.1
|
101
|
+
signing_key:
|
102
|
+
specification_version: 4
|
103
|
+
summary: Custom methods for calabash ios and android
|
104
|
+
test_files: []
|