我正在努力在我的 native android 中找到以下内容的嵌套元素,并想知道如何最好地检索它们:
我的代码无法找到元素:
@FindBy(xpath = "//*[@id='password_complexity_layout']//*[@id='textView']")
public WebElement textView1;
@FindBy(xpath = "//*[@id='password_complexity_layout']//*[@id='textView2']")
public WebElement textView2;
最佳答案
使用下面的代码来查找所有 View 。
LinearLayout ll = …
final int childCount = ll.getChildCount();
for (int i = 0; i < childCount; i++) {
View v = ll.getChildAt(i);
// Do something with v.
// …
}
关于java - 如何在原生android和java中查找嵌套元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57426897/