我有这个层次结构:我想点击列表视图中的项目,我这样做了,但它不起作用
driver.findElement(By.xpath("//FrameLayout/android.support.v4.widget.DrawerLayout/ListView[4]")).click();
我有这个层次结构:我想点击列表视图中的项目,我这样做了,但它不起作用
driver.findElement(By.xpath("//FrameLayout/android.support.v4.widget.DrawerLayout/ListView[4]")).click();
尝试这个:
driver.findElementsByXPath("//*[@class='android.widget.TextView' and @name='Settings']");
试试这个:(如果列表元素具有相同的 id/name)
List<WebElement> allItems = driver.findElements(By.className("android.widget.EditText"));
allItems.get(1).click();
试试这个,应该可以的
WebElement wlobj = driver.findElement(By.name("Settings"));
wlobj.click();
否则试试
driver.findElementsByXPath("//*[@name='Settings' and @index='0']");
text 和 content-desc 可用于 (By.name)