Ifd_Mobile 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ee675b90713b5589113a7ff21c60674ee7be56c
4
- data.tar.gz: a5e1efdde2e63fc6618efebfbcbada6cc0d61b15
3
+ metadata.gz: 949a421da04ff5b53b4dd75c27563dbd8da92348
4
+ data.tar.gz: 328188e946f8b32c2bd3ece2206381dc80e7123a
5
5
  SHA512:
6
- metadata.gz: 4e7cb6e8438520a6ec931803e7113f4253151c88585b049b21d5de4b7dba3cae07d5de2ce7b3f3d595821b365322a67c3d3b2ffe2bb814ac431d92407df16554
7
- data.tar.gz: 847ffee059c626ca87069b7ba087638059ea82ad681a9233b275540e0f77a7b3d86c2e3f8fa9ee9472fa3d0fbc9fecc6fe7e34d740c2995da852731e7cc2aa8a
6
+ metadata.gz: 08833b006525152c84d0f8ff23f81f6b45ba687bc583ca0d9b5836d3250cd9f28aedd435b2cc9bdbfa8ee4784e51cdb80682a93035cf4981d3b52f5ffc362dc6
7
+ data.tar.gz: 86e89630fdad43a08d843186381cf8cfb04b55a3f3aa3759d1a813e4181c536981c2ac21a134b8be73a863bf53f94ff67d7f91ec2e236ea0c6e3b065591c2759
@@ -64,8 +64,43 @@ And /^I delete an character$/ do
64
64
  system('adb shell input keyevent 67')
65
65
  end
66
66
 
67
- And /^I test "(.*)"$/ do |element|
68
- found_element = find_object element
69
- actual_value = found_element.attribute("value")
70
- puts actual_value
67
+ Then(/^I tap on back button of device$/) do
68
+ navigate('back')
69
+ end
70
+
71
+ Then(/^I tap on forward button of device$/) do
72
+ navigate('forward')
73
+ end
74
+
75
+ #---------- Swipe with direction
76
+ Then(/^I swipe left$/) do
77
+ swipe_direction("left")
78
+ end
79
+
80
+ Then(/^I swipe right$/) do
81
+ swipe_direction("right")
82
+ end
83
+
84
+ Then(/^I swipe up$/) do
85
+ swipe_direction("up")
86
+ end
87
+
88
+ Then(/^I swipe down$/) do
89
+ swipe_direction("down")
90
+ end
91
+
92
+ Then(/^I long tap on element having "(.*?)"$/) do |element|
93
+ long_press_on_element_default_duration(element)
94
+ end
95
+
96
+ Then(/^I long tap on element having (.+) "(.*?)" for "(.*?)" sec$/) do |element, duration|
97
+ long_press_on_element_with_duration(element, duration)
98
+ end
99
+
100
+ Then(/^I long tap on co\-ordinate "(.*?)","(.*?)"$/) do |x, y|
101
+ long_press_on_coordinates(x, y)
102
+ end
103
+
104
+ Then(/^I long tap on co\-ordinate "(.*?)","(.*?)" for "(.*?)" sec$/) do |x, y, duration|
105
+ long_press_on_coordinates_with_duration(x, y, duration)
71
106
  end
@@ -134,3 +134,99 @@ end
134
134
  def click_by_coordinate x, y
135
135
  selenium.execute_script 'mobile: tap', :x => x, :y => y
136
136
  end
137
+
138
+ # method to navigate back & forward
139
+ def navigate(direction)
140
+ if direction == 'back'
141
+ selenium.navigate.back
142
+ else
143
+ selenium.navigate.forward
144
+ end
145
+ end
146
+
147
+ def swipe_direction(direction)
148
+ size = selenium.manage.window.size
149
+ height = size.height.to_i - 10
150
+ width = size.width.to_i - 10
151
+
152
+ if direction == 'right'
153
+ start_x = (width/100) * 15 # 83
154
+ start_y = height/2 # 695
155
+ end_x = (width/100) * 90 # 900
156
+ end_y = height/2 # 630
157
+ elsif direction == 'left'
158
+ start_x = (width/100) * 90
159
+ start_y = height/2
160
+ end_x = (width/100) * 15
161
+ end_y = height/2
162
+ elsif direction == 'up'
163
+ start_x = width/2
164
+ start_y = (height/100) * 90
165
+ end_x = width/2
166
+ end_y = (height/100) * 15
167
+ elsif direction == 'down'
168
+ start_x = width/2
169
+ start_y = (height/100) * 15
170
+ end_x = width/2
171
+ end_y = (height/100) * 90
172
+ else
173
+ raise "invalid direction"
174
+ end
175
+
176
+ swipe(start_x, start_y, end_x, end_y)
177
+ end
178
+
179
+ def swipe(start_x, start_y, end_x, end_y)
180
+ action = Appium::TouchAction.new.press(x: "#{start_x}", y: "#{start_y}").wait(1000).move_to(x: "#{end_x}", y: "#{end_y}").release()
181
+ action.perform
182
+ end
183
+
184
+
185
+ def long_press_on_element_default_duration(element)
186
+ begin
187
+ ele_from = find_object element.location
188
+ x = ele_from.x
189
+ y = ele_from.y
190
+
191
+ action = Appium::TouchAction.new.press(x: "#{x}", y: "#{y}").wait(2000).move_to(x: "#{x}", y: "#{y}").release()
192
+ action.perform
193
+ rescue Exception => e
194
+ if e.to_s == 'The swipe did not complete successfully'
195
+ print ""
196
+ else
197
+ raise e
198
+ end
199
+ end
200
+ end
201
+
202
+ def long_press_on_element_with_duration(element, duration)
203
+ begin
204
+ ele_from = find_object element.location
205
+ x = ele_from.x
206
+ y = ele_from.y
207
+
208
+ duration = duration.to_i
209
+ duration = duration * 1000
210
+ action = Appium::TouchAction.new.press(x: "#{x}", y: "#{y}").wait("#{duration}").move_to(x: "#{x}", y: "#{y}").release()
211
+ action.perform
212
+ rescue Exception => e
213
+ if e.to_s == 'The swipe did not complete successfully'
214
+ print ""
215
+ else
216
+ raise e
217
+ end
218
+ end
219
+ end
220
+
221
+ def long_press_on_coordinates(x, y)
222
+ action = Appium::TouchAction.new.press(x: "#{x}", y: "#{y}").wait(2000).move_to(x: "#{x}", y: "#{y}").release()
223
+ action.perform
224
+ end
225
+
226
+ def long_press_on_coordinates_with_duration(x, y, duration)
227
+ duration = duration.to_i
228
+ duration = duration * 1000
229
+ puts duration
230
+ action = Appium::TouchAction.new.press(x: "#{x}", y: "#{y}").wait("#{duration}").move_to(x: "#{x}", y: "#{y}").release()
231
+ action.perform
232
+ end
@@ -1,5 +1,5 @@
1
1
  module Ifd
2
2
  module Mobile
3
- VERSION = '0.1.3'
3
+ VERSION = '0.1.4'
4
4
  end
5
5
  end
data/project/Gemfile CHANGED
@@ -5,3 +5,6 @@ gem "rspec"
5
5
  gem "selenium-webdriver"
6
6
  gem "cucumber"
7
7
  gem "rspec-expectations"
8
+ gem "appium_lib"
9
+ gem "rack-utf8_sanitizer"
10
+ gem "Ifd_Mobile"
@@ -7,9 +7,11 @@ Feature: Demo
7
7
  Scenario: Navigate
8
8
  Given I have App running with appium
9
9
  When I input text "4" on "textbox1"
10
- And I input text "4" on "textbox2"
11
- And I click on "button_sum"
12
- Then I verify property "result" with "value" has value "8"
13
- When I click on "show_alert"
14
- Then I verify property "alert title" with "name" has value "Cool title"
15
- And I accept alert
10
+ # And I input text "4" on "textbox2"
11
+ # And I click on "button_sum"
12
+ # Then I verify property "result" with "value" has value "8"
13
+ # When I click on "show_alert"
14
+ # Then I verify property "alert title" with "name" has value "Cool title"
15
+ # And I accept alert
16
+ * I rotate device to landscape
17
+ * I rotate device to portrait
@@ -2,7 +2,7 @@ Before { $driver.start_driver }
2
2
 
3
3
  After do
4
4
  begin
5
- selenium.quit
5
+ selenium.driver_quit
6
6
  rescue StandardError => myStandardError
7
7
  puts "\nERROR: *** #{myStandardError}"
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Ifd_Mobile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anh Pham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-23 00:00:00.000000000 Z
11
+ date: 2015-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber