I have a problem because I would like to get the selected option name: Option3 in this case. I want to use assert to check if value is selected correctly in this case. You can see a part of my page below:
<html>
<body>
<table border="0" cellpadding="0" cellspacing="0" class="rich-toolbar " id="mainMenuToolbar" width="100%">
<tbody>
<tr valign="middle">
<td class="rich-toolbar-item " style=";">
<form id="substituteForm" name="name" method="post" action="http://homepage/home.seam" enctype="application/x-www-form-urlencoded">
<select name="substituteForm:j_id158" size="1" onchange="document.getElementById('substituteForm:substituteSubmit').click();">
<option value="0">Option0</option>
<option value="1">Option2</option>
<option value="2" selected="selected">Option3</option>
</select>
</form>
</td>
</tr>
</tbody>
</table>
</body>
</html>
I used DevTool to copy XPath and I wrote a code:
element = Select(driver.find_element_by_xpath("//* [@id='substituteForm']/select"))
and I have error message:
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //*[@id='substituteForm']/select
I tried many XPath combinations and it still doesn't work.