i tried to identify the text from the drop down but it displays the error.

Select agentName1 = new Select(driver.findElement(By.id("XYZ")));

i tried with agentName1.selectByIndex(32) & agentName1.selectByValue("587"); but every time during my automation run i have to create the new text due this the index and value is changed due to this selenium is unable to locate the element.

i tried clicking the drop down it worked but selecting the text from the dropdown is not working.

i tried all the possible way displayed in the forum but no luck.

Please help me on to resolve the issue.

enter image description here

tried below code as well.

WebElement agentDropDown1 = driver.findElement(By.name("baseline"));
Select categories1 = new Select(agentDropDown1);

// 2. getting all options of menu

java.util.List<WebElement> optionsList1 = categories1.getOptions();
System.out.println("The options list : ");
for (WebElement option : optionsList1) {


// 3. selecting dropdown menu 

  • which website ? are there 32 elements ?
    – PDHide
    Commented Mar 30, 2021 at 15:15

1 Answer 1



 List<WebElement> list = driver.findElements(By.tagname("option"));
 list.get(<index number of the selection>).click();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.