错误Domain = com.facebook.WebDriverAgent代码= 1“为'设置了不受支持的原始类型'图像'

时间:2019-09-07 22:06:36

标签: selenium selenium-webdriver appium appium-ios

我试图使用ios appium单击默认图像,但是java发送以下错误

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Error Domain=com.facebook.WebDriverAgent Code=1 "Unsupported origin type 'Image' is set for '{
    duration = 100;
    origin = Image;
    type = pointerMove;
    x = 0;
    y = 0;
}' action item. Supported origin types: (
    pointer,
    viewport
) or an element instance" UserInfo={NSLocalizedDescription=Unsupported origin type 'Image' is set for '{
    duration = 100;
    origin = Image;
    type = pointerMove;
    x = 0;
    y = 0;
}' action item. Supported origin types: (
    pointer,
    viewport
) or an element instance}
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T14:04:26.12Z'
System info: host: 'sprout24.local', ip: '192.168.1.73', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.5', java.version: '1.8.0_162'
Driver info: io.appium.java_client.ios.IOSDriver

这是导致该问题的代码。

  List<WebElement> dp = driver.findElementsByClassName("XCUIElementTypeImage");

System.out.println("default pic found");
Actions build4 = new Actions(driver); 
build4.moveToElement(dp.get(0)).build().perform();

我正在使用Actions类,因为该属性被设置为visible = false,即使该元素在屏幕上也是如此。

我也尝试过

TouchActions action = new TouchActions(driver);
        action.singleTap(dp.get(0));
        action.perform();

但它也失败

2 个答案:

答案 0 :(得分:2)

如我所见,您正在使用iOS设备,对吗?如果据我所知,appium不支持所有iOS版本的Actions类,如果要滚动屏幕,最好使用:

JavascriptExecutor js;
HashMap<String, String> scrollObject = new HashMap<>();
scrollObject.put("direction", "down");
js.executeScript("mobile: swipe", scrollObject);

此代码将向下滚动屏幕(如果在“方向”字段值中键入“向上”,则向上滚动)。 提前,关于

List<WebElement> dp = driver.findElementsByClassName("XCUIElementTypeImage");

如果要检查某个元素是否存在,则最好使用以下方法:

driver.findElements(By.name("")).isEmpty();

driver.findElementsByAccessibilityId(...).isEmpty();

通过这种方式,您将不会收到NoSuchElementException,并且元素不存在。

答案 1 :(得分:0)

好,这是解决方法:

        List<WebElement> dp = driver.findElementsByClassName("XCUIElementTypeImage");
        Point point = dp.get(0).getLocation();
        PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");
        Sequence sequence = new Sequence(finger, 1);
        sequence.addAction(finger.createPointerMove(Duration.ofMillis(1), PointerInput.Origin.viewport(), point.x, point.y));
        driver.perform(Arrays.asList(sequence));