如何双击列表中具有相同ID、索引和名称的元素

How can I double click the element with the same id, index and name in the list

enter image description here

enter image description here

大家好。如何多次单击具有所有相同属性的元素?

我的代码:

BasePage.java

public By parent = By.xpath("//android.widget.LinearLayout");
public By children = By.xpath("//android.widget.TextView[@text='Remove']");

protected List<WebElement> findChildrenOfParent(By parentBy, By childrenBy) {
    waitVisibility(parentBy);
    WebElement parentElement = driver.findElement(parentBy);
    return parentElement.findElements(childrenBy);
}

protected void removeAllProductsFromCart(List<WebElement> elementList) {

    for (int i = 0; i < elementList.size(); i++) {
        elementList.get(i).click();
                   
    }

CartPage.java

public void deleteAllProductsBasket() throws InterruptedException {
                
    List<WebElement> childrenElements = findChildrenOfParent(parent, children);
    removeAllProductsFromCart(childrenElements);
            
}

您只需点击这些元素两次:

for (int i = 0; i < elementList.size(); i++) {
    elementList.get(i).click();
    try {
        Thread.sleep(300);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }                   
    elementList.get(i).click();
}

我在点击之间添加了一个短暂的休眠以使其更稳定