1Plain JavaScript:
2===================
3var e = document.getElementById("elementId");
4var value = e.options[e.selectedIndex].value;
5var text = e.options[e.selectedIndex].text;
6---------------------------------------------------------
7jQuery:
8=======
9$("#elementId :selected").text(); // The text content of the selected option
10$("#elementId :selected").val(); // The value of the selected option
1How do you handle Select type of dropdown?
2 - If it is <select> we would have to use Select class from Selenium.
3 - Methods to select from dropdown:
4 Select s = new Select(element);
5 - s.selectByVisibleText
6 - s.selectByValue
7 - s.selectByIndex
8--> How do we verify which option is selected in a dropdown?
9 - If we want to get the currently selected option,
10 we use getFirstSelectedOption() method.