mardi 17 septembre 2019

How to find web element location for dynamic drop down list element in selenium using Java

I am unable to locate dynamic web element location for drop down list

public void selectClassofService(String value) throws InterruptedException {

    driver.findElement(By.xpath("/html/body/div[1]/div/div/div/div[3]/div[2]/div[2]/div/div/div/div[2]/div[2]/div[2]/form/div[5]/div/div[2]/div/div/div[1]/input")).click();

   List<WebElement> list = driver.findElements(By.xpath("/html/body/div[1]/div/div/div/div[3]/div[2]/div[2]/div/div/div/div[2]/div[2]/div[2]/form/div[5]/div/div[2]/div/div/div[1]/input"));
    System.out.println("Size of the list size =" + list.size());
    for (int i = 0; i < list.size(); i++) {
        System.out.println("names of the divisions " + list.get(i).getText());

        if (list.get(i).getText().contains(value)) {
            list.get(i).click();
            break;
        }

    }

this is my sample html code sample pack sample pack sample pack2




Aucun commentaire:

Enregistrer un commentaire