gpt4 book ai didi

android - 从 uiautomator 中的 AutoCompleteTextView 中选择项目

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:51:02 25 4
gpt4 key购买 nike

更新

该项目今天不再维护,但最受欢迎的是解决方案。谢谢。


AutoCompleteTextView adapter issue for selecting item

我正在创建一个自动化测试项目,在该项目中我无法从 AutoCompleteTextView 中选择项目。

您可以看到快照及其拥有的 View [全部展开]。 AutoCompleteTextView 的下拉菜单没有出现在 View 树中,我也无法使用鼠标进行选择。

我尝试了以下方法从 AutoCompleteTextView 适配器中选择项目表单:

  1. UiScrollable locationList = new UiScrollable(new UiSelector().scrollable(true)); locationList.scrollTextIntoView(location);

  2. UiScrollable locationList = new UiScrollable(locationEditText.getSelector()); locationList.scrollTextIntoView(location); 这里 locationEditText 是我的 AutoCompleteTextView

  3. UiObject selectedLocation = locationList.getChild(new UiSelector().text(location)); selectedLocation.click(); 从 locationList 中它没有选择带有传递的字符串的项目。

  4. editLocationResId = "android:id/text1"; UiObject selectedLocation = new UiObject(new UiSelector().resourceId(editLocationResId)); selectedLocation.click(); 来自适配器 TextView 的 id 也不起作用。

谁能帮我从 uiautomator 的 AutoCompleteTextView 中选择项目?或者更多的方法获得期望的输出。

最佳答案

获取文本域的坐标:

int x = element.getLocation().getX();
int y = elmement.getLocation().getY();

添加值以获得正确的坐标。

x = x+x1
y = y+y1

使用点击功能点击它。

TouchAction action = new TouchAction(driver);

action.tap(x,y).perform();

关于android - 从 uiautomator 中的 AutoCompleteTextView 中选择项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25197993/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com