1

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

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

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) {
       System.out.println(option.getText());
}

System.out.println();

// 3. selecting dropdown menu 

categories1.selectByValue("1426");
1
  • which website ? are there 32 elements ? – PDHide Mar 30 at 15:15
1

try

 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, privacy policy and cookie policy

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