org.openqa.selenium.ElementNotInteractableException while trying to access Category dropdown

199 views
Skip to first unread message

Anagha G

unread,
Apr 12, 2019, 12:34:07 AM4/12/19
to Selenium Users
I am trying to access dropdown [All categories]of Amazon.in but getting the above exception.

Here is my code :

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

Sanket

unread,
Apr 12, 2019, 3:15:13 AM4/12/19
to Selenium Users
Hello,


Simply run below code.

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();



After that you can process further operations......

Thanks,
Sanket
Reply all
Reply to author
Forward
0 new messages