Suppose I have this HTML code:
<select id="superior" size="1" name="superior"> <option value=""></option> <option value="ciemmd.Division_1">DIVISION007</option> <option selected="selected" value="ciemmd.Division_$$_javassist_162_119">MyDivision</option> <option value="ciemmd.Division_121">MyDivision4</option> <option value="ciemmd.Division_122">MyDivision5</option> </select>
So this is a combo box
id=superior
and MyDivision is currently selected.
Using Selenium WebDriver I am trying to get the selected value, but have not succeeded.
I tried:
String option = this.ebtamTester.firefox.findElement(By.id(superiorId)).getText(); return option;
But this returns me all the values ββin the combo box.
Help me please?
Edit:
WebElement comboBox = ebtamTester.firefox.findElement(By.id("superior")); SelectElement selectedValue = new SelectElement(comboBox); String wantedText = selectedValue.getValue();
Koray tugay
source share