Please check if the mentioned code is ok or not for validate the element in drop down. | Selenium Forum
G
gautam Posted on 26/05/2021

Hi Ashish,

Please confirm if the mentioned code is ok or not. I am not getting any failure. Your code was different so i just wanted to confirm.

public boolean ValidateDropDown(String locatorkey,String portfolio_name) {

WebElement element = getElement(locatorkey);
select = new Select(element);

List<WebElement> list_drop_down = select.getOptions();

for(int i=0; i<list_drop_down.size();i++) {

//System.out.println(list_drop_down.get(i).getText());
if(list_drop_down.get(i).getText().equals(portfolio_name)){

return true;
}
}

return false;

 


A
Ashish Thakur Replied on 01/06/2021

yes

Looks good


Related Posts