I'm using the following code:
if i[1] == "id_text":
inst = driver.find_element_by_id(i[2])
#inst.click()
for option in inst.find_elements_by_tag_name('option'):
if option.text == i[3]:
option.click()
But it keeps constantly raising the error
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: u'Unable to locate element: {"method":"xpath","selector":"//select[@id=\'sex\']"}' ; Stacktrace:
I know the if statement is being executed, and that the value of the id is correct. To try to fix this i tried replacing id with name, no result. I then tried using find_element_by_id and find_element_by_name, still unable to find the element.
The element does exist and the page has loaded. I know this for certain because before the dropdown there exists another text field which is filled in properly, there is no ajax on the website either but i did try using waits. 60 sec waits didn't help either.
The dropdown i am trying to zero in on is
<select style="visibility: visible;" name="sex" id="sex" onchange="changefees()">
<option value="0">Select Gender</option>
<option value="1">Male</option><option value="2">Female</option>
</select>
The value of the id/name being supplied as well as the text is correct, i verified that by printing the values before executing the code. Any help is highly appreciated.
Edit: I also tried to use the same code on another dropdown on the page, same result.