There is a drop down in that selected any index value using "selectedbyindex(i)" now i need the value which i selected in drop down to validate the value. Please let me know how we can achieve this thing.
Find the set of code
WebElement dropdown = driver.findElement(By.id("portfolioid"));
Select s = new Select(dropdown);
s.selectByVisibleText("My Portfolio");
s.selectByIndex(2);
// System.out.println(s.getFirstSelectedOption());
Instructor
Ashish Thakur Replied on 25/11/2019
Before this... can you put a delay of 5 sec?
Thread.sleep(5000)
Select s = new Select(dropdown);
Hi Team,
Thanks for quick response.
I am able to select the value from drop down but after selection how we can get it selected text means what value currently selected?
Eg :
WebElement dropdown = driver.findElement(By.id("portfolioid"));
Select s = new Select(dropdown);
s.selectByVisibleText("My Portfolio");
s.selectByIndex(2);
After above line how we can get the selected drop down value?
Any Update?
Instructor
Ashish Thakur Replied on 27/11/2019
s.getFirstSelectedOption()
will give you currently selected Option