Swipe problem in Katalon

I’m using the Katalon Studio Version 9.3.2 build 212.
Appium (v2.0.1)
uiautomator2@2.45.1
Android
AVD

when I trying use the below code I get the error.

AppiumDriver<?> driver = MobileDriverFactory.getDriver()
new TouchAction(driver).press(PointOption.point(550, 640)).waitAction().moveTo(PointOption.point(550, 60)).release().perform();
Test Cases/Login/Main FAILED.
Reason:
org.openqa.selenium.InvalidArgumentException: java.lang.IllegalArgumentException: SwipeModel: The mandatory field 'steps' is not present in JSON
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'LM-SHI-41510709', ip: '192.168.50.220', os.name: 'Mac OS X', os.arch: 'aarch64', os.version: '14.4', java.version: '17.0.7'
Driver info: com.kms.katalon.core.appium.driver.SwipeableAndroidDriver
Capabilities {appActivity: .Settings, appPackage: com.android.settings, autoGrantPermissions: true, automationName: uiautomator2, databaseEnabled: false, desired: {appActivity: .Settings, appPackage: com.android.settings, autoGrantPermissions: true, automationName: uiautomator2, deviceName: emulator-5554 (sdk_gphone_a..., newCommandTimeout: 1800, platformName: android, platformVersion: 11, systemPort: 8253, udid: emulator-5554}, deviceApiLevel: 30, deviceManufacturer: Google, deviceModel: sdk_gphone_arm64, deviceName: emulator-5554, deviceScreenDensity: 420, deviceScreenSize: 1080x1920, deviceUDID: emulator-5554, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, newCommandTimeout: 1800, pixelRatio: 2.625, platform: LINUX, platformName: Android, platformVersion: 11, statBarHeight: 63, systemPort: 8253, takesScreenshot: true, udid: emulator-5554, viewportRect: {height: 1857, left: 0, top: 63, width: 1080}, warnings: {}, webStorageEnabled: false}
Session ID: ad89f842-039e-49a6-b714-fd69f53a0103
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
	at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
	at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
	at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
	at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
	at com.kms.katalon.core.appium.driver.SwipeableAndroidDriver.execute(SwipeableAndroidDriver.java:1)
	at io.appium.java_client.PerformsTouchActions.performTouchAction(PerformsTouchActions.java:41)
	at io.appium.java_client.TouchAction.perform(TouchAction.java:187)
	at io.appium.java_client.TouchAction.perform(TouchAction.java:1)
	at SelectCountryModal.run(SelectCountryModal:200)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:448)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:439)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:418)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:410)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:285)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:137)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:128)
	at TempTestCase1713742300914.run(TempTestCase1713742300914.groovy:25)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

how can I fix it?

1 Like

Hi,

Welcome to our community. Can you please share your SwipeModel as it is missing required field

1 Like

How can I find the SwipeModel?

Hi,

Can you please share your full code so that we can support you?

package com.katalon

import java.time.Duration;

import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory
import com.kms.katalon.core.testobject.TestObject

import io.appium.java_client.AppiumDriver
import io.appium.java_client.TouchAction
import io.appium.java_client.touch.WaitOptions
import io.appium.java_client.touch.offset.PointOption

public class KatalonCustomScroll {
@Keyword
def scrollNew(TestObject toGrid) {
int device_Height = Mobile.getElementHeight(toGrid, 0)
int device_Width = Mobile.getElementWidth(toGrid, 0)
Mobile.comment('[INFO] Device height: ’ + device_Height + " and width: " + device_Width )
int startX = device_Width * 0.5
int endX = device_Width * 0.5
int startY = device_Height * 0.6
int endY = device_Height * 0.1
AppiumDriver<?> driver = MobileDriverFactory.getDriver()
TouchAction swipe1 = new TouchAction(driver).press(PointOption.point(startX, startY)).waitAction(WaitOptions.waitOptions(Duration.ofMillis(200L))) //if you want to swipe longer you can increase the time
swipe1.moveTo(PointOption.point(endX, endY))
swipe1.release().perform();
}
}

I used
AppiumDriver<?> driver = MobileDriverFactory.getDriver()
PointerInput input = new PointerInput(TOUCH, “finger1”);
Sequence swipe = new Sequence(input, 1);
swipe.addAction(input.createPointerMove(ofMillis(0), viewport(), start.getX(), start.getY()));
swipe.addAction(input.createPointerDown(PointerInput.MouseButton.LEFT.asArg()));
swipe.addAction(input.createPointerMove(ofMillis(300), viewport(), end.getX(), end.getY()));
swipe.addAction(input.createPointerUp(PointerInput.MouseButton.LEFT.asArg()));
driver.perform(Arrays.asList(swipe));

Duong if possible can you please share complete code, it will be really helpful

import org.openqa.selenium.Point
import io.appium.java_client.AppiumDriver as AppiumDriver
import org.openqa.selenium.interactions.PointerInput
import org.openqa.selenium.interactions.Sequence
public static void swipe(Point start, Point end) {
		AppiumDriver<?> driver = MobileDriverFactory.getDriver()
		PointerInput input = new PointerInput(TOUCH, "finger1");
		Sequence swipe = new Sequence(input, 1);
		swipe.addAction(input.createPointerMove(ofMillis(0), viewport(), start.getX(), start.getY()));
		swipe.addAction(input.createPointerDown(PointerInput.MouseButton.LEFT.asArg()));
		swipe.addAction(input.createPointerMove(ofMillis(300), viewport(), end.getX(), end.getY()));
		swipe.addAction(input.createPointerUp(PointerInput.MouseButton.LEFT.asArg()));
		driver.perform(Arrays.asList(swipe));
	}

Hopefully this is working for you in Test Cloud Devices?