java - 由于存在粘性按钮而无法单击按钮

标签 java android appium ui-automation

由于存在粘性聊天按钮,我无法在我的 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() - (VIEW BOOKING) 由于屏幕右下角显示的粘性在线聊天粘性按钮无法正常工作,如图所示

enter image description here

日志:

info: --> POST /wd/hub/session/7ee1afc3-9a7c-4105-b8e9-acdbf9570f46/elements {"using":"id","value":"com.servicemarket.app.debug:id/btnViewBooking"} info: [debug] Waiting up to 0ms for condition info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.servicemarket.app.debug:id/btnViewBooking","context":"","multiple":true}] info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.servicemarket.app.debug:id/btnViewBooking","context":"","multiple":true}} info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION info: [debug] [BOOTSTRAP] [debug] Got command action: find info: [debug] [BOOTSTRAP] [debug] Finding com.servicemarket.app.debug:id/btnViewBooking using ID with the contextId: multiple: true info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[RESOURCE_ID=com.servicemarket.app.debug:id/btnViewBooking] info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[RESOURCE_ID=com.servicemarket.app.debug:id/btnViewBooking] info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0) info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[INSTANCE=0, RESOURCE_ID=com.servicemarket.app.debug:id/btnViewBooking] info: [debug] [BOOTSTRAP] [debug] Element[] is null: (1) info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[INSTANCE=1, RESOURCE_ID=com.servicemarket.app.debug:id/btnViewBooking] info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":[{"ELEMENT":"126"}],"status":0} info: [debug] Responding to client with success: {"status":0,"value":[{"ELEMENT":"126"}],"sessionId":"7ee1afc3-9a7c-4105-b8e9-acdbf9570f46"} info: <-- POST /wd/hub/session/7ee1afc3-9a7c-4105-b8e9-acdbf9570f46/elements 200 36.010 ms - 91 {"status":0,"value":[{"ELEMENT":"126"}],"sessionId":"7ee1afc3-9a7c-4105-b8e9-acdbf9570f46"} info: --> POST /wd/hub/session/7ee1afc3-9a7c-4105-b8e9-acdbf9570f46/element/126/click {"id":"126"} info: [debug] Pushing command to appium work queue: ["element:click",{"elementId":"126"}] info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"126"}} info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION info: [debug] [BOOTSTRAP] [debug] Got command action: click info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0} info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"7ee1afc3-9a7c-4105-b8e9-acdbf9570f46"} info: <-- POST /wd/hub/session/7ee1afc3-9a7c-4105-b8e9-acdbf9570f46/element/126/click 200 306.260 ms - 76 {"status":0,"value":true,"sessionId":"7ee1afc3-9a7c-4105-b8e9-acdbf9570f46"}

最佳答案

这样就可以获取元素了。那已经很好了。尝试使用 TouchAction 点击,例如按下longPress:

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

关于java - 由于存在粘性按钮而无法单击按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47752514/

相关文章:

java - Android 不会保存输入到 SQLite 数据库的数据

java - Java中如何将int转为long?

java - Windows 与 Java 中 Unix 的文件路径问题

android - 3rd-party Gradle插件可能是导致错误的原因

android - 指纹验证安卓

javascript - Selenium Webdriver - 等待页面在 Java&JavaScript(ajax/jquery/animation 等)中完全加载

android - 无法为基于 Atom x86 系统镜像的 Android 2.3.3 创建 AVD

javascript - 如何使用 webdriverio 和 appium 按下点击并按住并向下滚动

android - Appium Android Windows : driver. findElement(By.name (""))不能连续工作

android - Appium 自动服务器 - 未找到可以自动化 Chrome '68.0.3440' 的 Chromedriver