如何找到/访问小吃栏元素?我找不到小吃店的定位器 [英] How to locate/Access snackbar elements? I am not able to find locators for snackbar

查看:67
本文介绍了如何找到/访问小吃栏元素?我找不到小吃店的定位器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Appium的Android自动化: 我正在尝试验证/验证小吃栏.但是Appium Inspector并未标识小吃店的定位器.请帮助我如何验证快餐栏内容.

Android Automation using Appium: I am trying to verify/validate the snackbar. but Appium Inspector is not identifying the locators for snackbar. please help me how to validate the snackbar content.

推荐答案

最简单的处理方法是检查Android应用程序的源代码.假设您在Snackbar中有一个文本视图和按钮,您应该能够找到这样的东西:

The easiest way to handle it is to check the source code of your Android application. Assuming you have a text view and button in Snackbar, you should be able to find smth like this:

<view
    class="android.support.design.internal.SnackbarContentLayout"
    >

    <TextView
        android:id="@+id/snackbar_text"/>

    <Button
        android:id="@+id/snackbar_action"
        android:visibility="gone"/>
</view>

如果没有id,我建议您自己添加它们. 现在,您应该可以找到零食吧,获取文字或单击按钮:

If id is not in place, I suggest to add them by yourself. Now you should be able to spot your snack bar, get the text or click the button:

FluentWait<WebDriver> wait = new WebDriverWait(driver, 10, 100).ignoring(NoSuchElementException.class);
wait.until(visibilityOfElementLocated(By.id("snackbar_text")));

这篇关于如何找到/访问小吃栏元素?我找不到小吃店的定位器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆