如何移动到元素并在Mob App中按下

时间:2019-11-14 10:10:06

标签: android selenium appium

如何使用xpath移动到在屏幕上不可见的元素,然后在移动应用程序中单击它? 该元素位于底部,因此需要向上滑动。

3 个答案:

答案 0 :(得分:1)

这是滚动并单击的小例子:

module.exports = {
  up: (queryInterface, Sequelize) => {
    return queryInterface.createTable('Vendors', {
      id: {
        allowNull: false,
        primaryKey: true,
        type: Sequelize.UUID,
        defaultValue: Sequelize.UUIDV1
      },
      firstName: {
        type: Sequelize.STRING
      }
    });
  },
  down: (queryInterface, Sequelize) => {
    return queryInterface.dropTable('Vendors');
  }
}; ```

i know it is possible to generate migration using given model file . Can we do the opposite of that ?

答案 1 :(得分:0)

您需要使用findElementByAndroidUIAutomator方法。它滚动到您的特定元素,找到它后,您可以在此元素上调用click()

driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().text(\"" + Element_text + "\").instance(0))");
driver.findElementByAndroidUIAutomator("new UiSelector().text(\"Element_text\")").click();

答案 2 :(得分:0)

我是这样做的:

TouchAction ta = new TouchAction(driver);
ta.press(button).moveTo(x, y).release().perform();