Tuesday 13 May 2014

How to select size from dropdown in Selenium or BDD in Java


Select sele = new Select(driver.findElement(By.xpath("//*[contains(@id,'dropdown')]")));
           
            List<WebElement> sizeOptions = sele.getOptions();
            for(WebElement element: sizeOptions)
            {
                String sizeValue;
                String checkInStock = null;
                checkInStock = "In Stock";
               sizeValue = element.getText();
             
                if(sizeValue.contains(checkInStock)){
                    sele.selectByVisibleText(sizeValue);
                    System.out.println(sizeValue);
                   
                    break;
                }
            }
            Thread.sleep(1000);

No comments:

Post a Comment