mercredi 21 août 2019

Need to click the checkbox based on item number

I'm unable to click the checkbox based on item number:

List<WebElement> returnItemContainer = driver
                .findElements(By.xpath("//ul[@class='return-item-select-container']"));

    int numberOfElements = driver.findElements(By.xpath("//ul[@class='return-item-select-container']")).size();

    String ItemNumber = "//li[@class='name'and//p[contains(text(),'Item #" + XLTestData.get("itemId").toString() + "')]]";



    for (int i = 0; i <= numberOfElements; i++) {

        if (ItemNumber.contains(XLTestData.get("itemId").toString())) {

            WebElement element = driver.findElement(By.xpath("//input[@type='checkbox']"));
            JavascriptExecutor executor = (JavascriptExecutor) driver;
            executor.executeScript("arguments[0].click();", element);

        }
    }

Can you me that i need to click of the that exact item numberenter image description here




Aucun commentaire:

Enregistrer un commentaire