While running the Python code on Edge browser in IE mode get the error: "Cannot click on option element. Executing JavaScript click function returned an unexpected error, but no error could be returned from Internet Explorer's JavaScript engine"
This code:
def my_select(self, text):
self.app.select_from_drop_down('//select[@class="gender"]', text)
calls this one:
def select_from_drop_down(self, selector, text):
wd = self.wd
if text is not None:
Select(wd.find_element(By.XPATH, selector)).select_by_visible_text(text)
and in the test I call the my_select method:
def test_select_male(app):
app.people_page.open_page()
app.people_page.my_select('Male')
DOM:
<select class="gender">
<option></option>
<option name="MALE">Male</option>
<option name="FEMALE">Female</option>
</select>
This is a know bug, that was reported to selenium developers. But it's not fixed. https://github.com/SeleniumHQ/selenium/issues/10319 People have found work around for Java and published it in the comments.
I have tried to write a work around for this bug in Python using execute_script, but never succeeded.
def select_from_drop_down_menu(self):
btn = wd.find_element(By.XPATH, '//select[@name="MALE"]').click()
wd.execute_script("arguments[0].click();", btn)
Thanks for your help!