WebDriverWait wait = new WebDriverWait(driver,30);
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id='searchDropdownBox']")));
Select selectobj = new Select(driver.findElement(By.xpath("//*[@id='searchDropdownBox']")));
List <WebElement> option = selectobj.getOptions();
for(WebElement selectLi: option) {
System.out.println(selectLi.getText()+ ",,,,");
if(selectLi.getText().equalsIgnoreCase("Baby")) selectLi.click();;
}
Exception :
"main" org.openqa.selenium.ElementNotInteractableException: Element <option> could not be scrolled into view
String url = "https://www.amazon.in/";
driver.get(url);
driver.findElement(By.xpath("//select[@title='Search in']")).click();
driver.findElement(By.xpath("//option[@value='search-alias=baby']")).click();
driver.findElement(By.xpath("//div[@class='nav-search-submit nav-sprite']//input[@value='Go']")).click();