1
I have a menu that presents several options, I want to select only the one that is active. When I give 'variable'. find_element_by_id('key') Selenium returns me ALL options. The active option has a "Selected" marker, as I point to is marked in Selenium?
variable = nanana.find_element_by_id('key')
<tr>
<td class="label"><label for="key"><em>*</em>Key:</label></td>
<td>
<select name="key" id="key"><option value="72-N-PR-2">ADEMAR </option>
<option value="32-N-PR-2" selected="selected">TEIXEIRA </option>
<option value="14-N-PR-2">ANA </option>
<option value="45-N-PR-2">RITA </option>
<option value="47-N-PR-2">ANDRE </option>
<option value="23-N-PR-2">JEANE </option>
<option value="45-N-PR-2">JOAO </option>
<option value="30-N-PR-2">LUIZ </option>
<option value="15-N-PR-2">VALDYR </option>
<option value="4-N-AM-2">VANESSA </option>
<option value="05-N-PR-2">GARCIA </option></select>
</td>
</tr>
What do you mean by "active option"? vc executed a click? want to select a specific element?
– Sidon
When I say active I mean "selected". Of all the options in the menu, it is the one that is currently visible. I do not intend to click, but capture the text for further processing, because the active text is the one that selects the active screen. If I select another option from the menu, it takes me to another screen.
– Bergo de Almeida
Vc is using a 'from Cratch" script or is generating through the Selenium IDE?
– Sidon
I’m using Selenium with Python, trying to avoid the use of Beautifulsoup (not to depend on another library). Selenium has located everything I need so far... by testing in Python Idle itself.
– Bergo de Almeida
Okay, put a possible answer, see if it helps.
– Sidon
What? the answer answered? :-)
– Sidon
Thanks friend! The only change I made was to put "select.first_selected_option"! I am very grateful!
– Bergo de Almeida