AppiumDriver获取尺寸大小给出Web视图中不支持的未知错误操作

时间:2018-11-22 18:56:51

标签: appium appium-android

我想知道去年是否有人遇到过此问题,(由于最近几年对io.Appium客户端进行了更改。)当我尝试在a中初始化Dimensions时遇到了一个问题方法,然后在移动浏览器中执行常规滑动。根据StackTrace,当我初始化我的Dimensions对象时,错误开始,并且我得到的错误消息是

"org.openqa.selenium.WebDriverException: unknown error: operation is unsupported on Android
  (Session info: chrome=68.0.3440.91)
  (Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Windows NT 10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds"

我一直在围绕该主题进行讨论,而解决方案是根据Web上下文使用Appium Docs目前正在使用的解决方案。我还有没有考虑的其他因素?

这是我初始化尺寸的尺寸的方法:

@SuppressWarnings("rawtypes")
    public  void  swipeVertical  (double startPercentage, double finalPercentage, int duration) {
        size = driver.manage().window().getSize();
        int width = (int) (size.width/2);
        int startPoint = (int) (size.getHeight() * startPercentage);
        int endPoint = (int) (size.getHeight() * finalPercentage);
        new TouchAction(driver)
            .press(PointOption.point(width, startPoint))
            .waitAction(WaitOptions.waitOptions(Duration.ofMillis(duration)))
            .moveTo(PointOption.point(width, endPoint))
            .release()
            .perform();
    }  

这是StackTrace:

org.openqa.selenium.WebDriverException: unknown error: operation is unsupported on Android
  (Session info: chrome=68.0.3440.91)
  (Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Windows NT 10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.13.0', revision: '2f0d292', time: '2018-06-25T15:24:21.231Z'
System info: host: 'LAPTOP-L1BFDSGL', ip: '192.168.174.2', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_181'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities {appiumURL: http://127.0.0.1:5000/wd/hub, browserName: Chrome, databaseEnabled: false, desired: {appiumURL: http://127.0.0.1:5000/wd/hub, browserName: Chrome, deviceName: device1, newCommandTimeout: 4000, noReset: false, platformName: Android, systemPort: 8200, udid: 192.168.174.101:5555}, deviceManufacturer: Genymotion, deviceModel: Samsung, deviceName: 192.168.174.101:5555, deviceScreenSize: 1440x2560, deviceUDID: 192.168.174.101:5555, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, newCommandTimeout: 4000, noReset: false, platform: LINUX, platformName: Android, platformVersion: 6.0, systemPort: 8200, takesScreenshot: true, udid: 192.168.174.101:5555, warnings: {}, webStorageEnabled: false}
Session ID: 4b662163-cef7-439b-bfd1-998dd6f8e5cc
    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:231)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
    at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:46)
    at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
    at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
    at org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteWindow.getSize(RemoteWebDriver.java:809)
    at AppiumDriverSetUp_Lib.PageObject.swipeVertical(PageObject.java:45)
    at BaseTest.BaseTest.testActivation(BaseTest.java:62)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
... Removed 20 stack frames

驱动程序:AppiumDriver

浏览器:Chrome

io.appium Java客户端:6.1.0

上下文:Web视图/默认

(注意:如果适用,我想将上下文保留为默认值。)

1 个答案:

答案 0 :(得分:0)

当驱动程序实例为{% for post in posts%} {{ post.content }} {{ post.num_comments }} {% endfor %}而不是AndroidDriver <MobileElement>时,它可以正常工作。

此外,您必须使用AppiumDriver而不是AndroidTouchAction类。