【问题标题】:Can't click a button due to a sticky button presence由于存在粘滞按钮,无法单击按钮
【发布时间】:2018-05-24 22:50:29
【问题描述】:

由于存在粘性聊天按钮,我无法在 Appium 测试中单击屏幕上的按钮。有人可以帮忙吗?

代码

public static void TapViewBookingButton() throws InterruptedException 
{
    Setup.startTimer();
    MobileElement btnViewBooking = (MobileElement) Setup.wait.until(ExpectedConditions.presenceOfElementLocated(By.id(btnViewBooking_ID)));
    btnViewBooking.click();
    Setup.updateLogMessage("VIEW BOOKING button clicked in " + Setup.stopTimer(Setup.stopWatch), SM_CONSTANTS.isScreenshot);
}

buttonViewBooking.Click() - (查看预订)由于屏幕右下角显示的粘性在线聊天粘性按钮而无法如图所示工作

日志:

info: --> POST /wd/hub/session/7ee1afc3-9a7c-4105-b8e9-acdbf9570f46/elements {"using":"id","value":"com.servicemarket.app.debug:id /btnViewBooking"} 信息:[调试] 等待最多 0 毫秒的条件 信息:[debug] 将命令推送到 appium 工作队列:["find",{"strategy":"id","selector":"com.servicemarket.app.debug:id/btnViewBooking","context":"" "多个":true}] info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"find","params":{"strategy":"id","selector": "com.servicemarket.app.debug:id/btnViewBooking","context":"","multiple":true}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令动作:find 信息:[调试] [BOOTSTRAP] [调试] 使用带有 contextId 的 ID 查找 com.servicemarket.app.debug:id/btnViewBooking:multiple: true 信息:[debug] [BOOTSTRAP] [debug] 使用:UiSelector[RESOURCE_ID=com.servicemarket.app.debug:id/btnViewBooking] 信息:[调试] [BOOTSTRAP] [调试] getElements 选择器:UiSelector[RESOURCE_ID=com.servicemarket.app.debug:id/btnViewBooking] 信息:[调试] [BOOTSTRAP] [调试] 元素 [] 为空:(0) 信息:[debug] [BOOTSTRAP] [debug] getElements tmp 选择器:UiSelector[INSTANCE=0, RESOURCE_ID=com.servicemarket.app.debug:id/btnViewBooking] 信息:[调试] [BOOTSTRAP] [调试] 元素 [] 为空:(1) 信息:[调试] [BOOTSTRAP] [调试] getElements tmp 选择器:UiSelector[INSTANCE=1,RESOURCE_ID=com.servicemarket.app.debug:id/btnViewBooking] 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":[{"ELEMENT":"126"}],"status":0} 信息:[调试]成功响应客户端:{"status":0,"value":[{"ELEMENT":"126"}],"sessionId":"7ee1afc3-9a7c-4105-b8e9-acdbf9570f46"} 信息: POST /wd/hub/session/7ee1afc3-9a7c-4105-b8e9-acdbf9570f46/element/126/点击 {"id":"126"} 信息:[debug] 将命令推送到 appium 工作队列:["element:click",{"elementId":"126"}] info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"element:click","params":{"elementId":"126"}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令动作:点击 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":true,"status":0} 信息:[调试]成功响应客户端:{“status”:0,“value”:true,“sessionId”:“7ee1afc3-9a7c-4105-b8e9-acdbf9570f46”} 信息:

【问题讨论】:

  • 请提供更多信息。屏幕截图、DOM 的输出、您尝试使用的代码。
  • 请立即查看

标签: java android appium ui-automation


【解决方案1】:

所以你可以得到元素。那已经很好了。尝试点击TouchAction,例如presslongPress:

Point point = btnViewBooking.getLocation();
new TouchAction(driver)
    .longPress(point.getX(), point.getY())
    .release()
    .perform();

【讨论】:

  • 你可以使用 Appium Inspector(Appium Desktop 的一部分 - github.com/appium/appium-desktop)。您可以在其中记录单击操作。它可能会使用 xpath,但这可能会为您提供有关可见性或分层问题的线索。
猜你喜欢
  • 1970-01-01
  • 2010-12-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-02-03
  • 2018-04-10
相关资源
最近更新 更多