Katalon Studio
Version: 5.6.3
Build: 1
I’ve spent quite some time in getting the horizontal swipe action to work in a ViewPager on Android without result. Tried both relative/absolute solutions with enough delay between the swipes. All the swipe steps pass according to the log but never got further then the first page (out of 10) and it looked more like ‘jump’ then a swipe.
I found out that i’am not the only one experiencing this problem; it would be realy nice to be able to simulate horizontal swipes on Android as this action is used a lot on mobile devices.
I tested on real and simulated Android devices and used https://www.katalon.com/resources-center/tutorials/horizontal-swipe-mobile-automation/ as guidance.
Below one of my latest experiments (stops after first swipe left):
Mobile.startApplication(‘/Users/xxxx/Downloads/xxx.apk’, true)
/* Tap on Top 10 icon */
Mobile.tap(findTestObject(‘Navigation/navigation_top_10_icon’), 10)
/* Verify Top 10 list is displayed */
Mobile.verifyElementExist(findTestObject(‘Navigation/navigation_top_10_list_header’), 10)
/* Open first article 01/10 */
Mobile.tap(findTestObject(‘Navigation/navigation_top_10_first_article’), 10)
/* Verfiy article count */
Mobile.verifyElementVisible(findTestObject(‘Navigation/navigation_top_10_article_count’), 10)
Mobile.verifyElementAttributeValue(findTestObject(‘Navigation/navigation_top_10_article_count’), ‘text’, ‘01’, 10)
java.lang.Thread.sleep(5000);
/* Swipe left */
CustomKeywords.‘com.swipe.AndroidSwipe.AndroidSwipeLeft’()
java.lang.Thread.sleep(5000);
/* Swipe left */
CustomKeywords.‘com.swipe.AndroidSwipe.AndroidSwipeLeft’()
java.lang.Thread.sleep(5000);
Mobile.closeApplication()
++++
Custom keyword:
public class AndroidSwipe {
@Keyword
def AndroidSwipeLeft(){
int device_Height, device_Width
device_Height = Mobile.getDeviceHeight()
device_Width = Mobile.getDeviceWidth()
int midheight = device_Height/2
int midwidth = device_Width/2
int startX,startY,endX,endY
startX = device_Width-100
startY = midheight
endX = -startX
endY = 0
Mobile.swipe(startX,startY,endX,endY)
}
}