Appium 多点触摸报错

代码:

package samoyed;

import java.net.MalformedURLException;
import java.net.URL;
import java.time.Duration;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;

import io.appium.java_client.MultiTouchAction;
import io.appium.java_client.TouchAction;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.touch.WaitOptions;
import io.appium.java_client.touch.offset.PointOption;

public class Zoom {

public static AndroidDriver ad;

public static void main(String[] args) throws MalformedURLException, InterruptedException {

DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability("deviceName", "127.0.0.1:62001");
dc.setCapability("platformName", "Android");
dc.setCapability("noReset", "True");
dc.setCapability("automationName", "uiautomator2");
dc.setCapability("appPackage", "com.baidu.BaiduMap");
dc.setCapability("appActivity", "com.baidu.baidumaps.WelcomeScreen");

ad = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"), dc);

Zoom();

}

public static void Zoom() throws InterruptedException {

Thread.sleep(13000);

MultiTouchAction mta = new MultiTouchAction(ad);
TouchAction tA1 = new TouchAction(ad);
TouchAction tA2 = new TouchAction(ad);

int x = ad.manage().window().getSize().getWidth();
int y = ad.manage().window().getSize().getHeight();

PointOption S1 = PointOption.point(x*4/10,y*4/10);
PointOption D1 = PointOption.point(x*2/10,y*2/10);

PointOption S2 = PointOption.point(x*6/10,y*6/10);
PointOption D2 = PointOption.point(x*8/10,y*8/10);

Duration du = Duration.ofMillis(2000);
WaitOptions wo = WaitOptions.waitOptions(du);

tA1.press(S1).waitAction(wo).moveTo(D1).release();
tA1.press(S2).waitAction(wo).moveTo(D2).release();

mta.add(tA1).add(tA2);

mta.perform();

}
}

Eclipse 报错:

十一月 03, 2020 5:16:54 下午 io.appium.java_client.remote.AppiumCommandExecutor$1 lambda$0 信息: Detected dialect: OSS
Exception in thread "main" org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Cannot read property 'action' of undefined (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'T480S-SJFANG', ip: '10.66.40.99', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_202-release'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities {appActivity: com.baidu.baidumaps.Welcome..., appPackage: com.baidu.BaiduMap, automationName: uiautomator2, databaseEnabled: false, desired: {appActivity: com.baidu.baidumaps.Welcome..., appPackage: com.baidu.BaiduMap, automationName: uiautomator2, deviceName: 127.0.0.1:62001, noReset: true, platformName: Android}, deviceApiLevel: 22, deviceManufacturer: OPPO, deviceModel: OPPO R11, deviceName: 127.0.0.1:62001, deviceScreenDensity: 240, deviceScreenSize: 720x1280, deviceUDID: 127.0.0.1:62001, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, noReset: true, pixelRatio: 1.5, platform: LINUX, platformName: Android, platformVersion: 5.1.1, statBarHeight: 38, takesScreenshot: true, viewportRect: {height: 1242, left: 0, top: 38, width: 720}, warnings: {}, webStorageEnabled: false}
Session ID: 64fb9c2b-550d-4f2c-ae07-2a1ffebe2e98
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
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 io.appium.java_client.PerformsTouchActions.performMultiTouchAction(PerformsTouchActions.java:58)
at io.appium.java_client.MultiTouchAction.perform(MultiTouchAction.java:74)
at samoyed.Zoom.Zoom(Zoom.java:61)
at samoyed.Zoom.main(Zoom.java:32)

Appium 报错:

[MJSONWP (64fb9c2b)] Encountered internal error running command: TypeError: Cannot read property 'action' of undefined

**[MJSONWP (64fb9c2b)] at AndroidUiautomator2Driver.parseTouch (C:\Users\sjfang\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-android-driver\lib\commands\touch.js:194:16)

**[MJSONWP (64fb9c2b)] at parseTouch (C:\Users\sjfang\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-android-driver\lib\commands\touch.js:292:23)

**[MJSONWP (64fb9c2b)] at mapper (C:\Users\sjfang\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\asyncbox\lib\asyncbox.js:79:24)

**[HTTP] <-- POST /wd/hub/session/64fb9c2b-550d-4f2c-ae07-2a1ffebe2e98/touch/multi/perform 500 4 ms - 213

回帖
请输入回帖内容 ...