selenium webdriver how to select from list menu item selenium webdriver how to select from list menu item selenium selenium

selenium webdriver how to select from list menu item


you can try using wait,

new WebDriverWait(driver, 60).until(ExpectedConditions.visibilityOfElementLocated(By.id("combobox0-text"))).clear();driver.findElement(By.id("combobox0-text")).sendKeys("Brown Mustard");new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("li.ui-menu-item"))).click();

the above code will clear the input field and type in the required item and wait for the menu item to appear in the drop down...,the 3rd statement will click on the menu item..


This is how it shall work:

driver.FindElement(By.Id("combobox0-text")).Clear();driver.FindElement(By.Id("combobox0-text")).SendKeys("bro");driver.FindElement(By.CssSelector("li.ui-menu-item")).Click();

FYI: It shall select the first/top menu item after sending keys. So, type more keys if you wanted to select a particular item.


After entering B, you could create a select object of the menu items and then select items based on visible text

import org.openqa.selenium.support.ui.Select;//your code before entering BSelect menu = new Select(driver.findElement(By.id("combobox0-text")));menu.selectByVisibleText("Brown Mustard");