Appium - 收到错误未定义:未定义参考元素

Appium - Received error undefined: Reference element is not defined

我不知道为什么会给我这个错误。我刚刚用 appium/node.js

开始了自动化

谁能帮我解决这个问题?

this.clickOnSavedCard.click();

const waitElemd = $('//android.widget.TextView[@resource-id="com.uat:id/changeSelectedPayment"]');
waitElemd.waitForDisplayed(12000);

driver.touchScroll({
  el: element,
  xOffset: 10,
  yOffset: 100
});

this.runCTA.click();

看起来您正在使用 WebdriverIO 并遇到了此处描述的问题:webdriverio/issues/4172 这实际上取决于您使用的 Webdriverio 版本。根据 source code 你可以这样称呼它:

driver.touchScroll(10, 110, <elementId>) // current master code

driver.touchScroll( <elementId>, 10, 110) // webdriverio v3.4

请注意,elementId 不是定位符,而是 WebDriver 分配给找到的元素的唯一标识符。所以为了得到它,你首先需要找到一个带有$的元素。 这就是您收到错误的原因:传递了不正确的参数。

也许您不想获取 elementId 并稍后将其传递给 touchScroll(),因此正如文档建议的那样,可以使用 TouchAction 代替:

driver.touchAction([ {action: 'press', x: startX, y: startY}, {action: 'moveTo', x: endX, y: endY}, 'release' ]);

其中 startX,startYendX,endY 是您要滚动 from[=34] 的坐标=] 和