I have a dropdown in my frontend looking like this:
<div class="dropdown-menu dropdown-menu-right text-left" id="dropdown_menu">
<a class="dropdown-item" data-toggle="modal" data-target="#exampleModalCenter" id="dropdown_change_pwd">Change Password</a>
<a class="dropdown-item" href="{{ url_for('auth.logout') }}" id="dropdown_logout">Logout</a>
</div>
I want to access these buttons with selenium in python. I tried to access it like this:
class SearchPage:
_CHANGE_PWD_DROPDOWN = (By.ID, 'dropdown_change_pwd')
_LOGOUT_DROPDOWN = (By.ID, 'dropdown_logout')
_DROPDOWN = (By.ID, 'dropdown_menu')
def __init__(self, browser):
self.browser = browser
def logout(self):
time.sleep(5)
dropdown = self.browser.find_element(*self._DROPDOWN)
dropdown.click()
logout = self.browser.find_element(*self._LOGOUT_DROPDOWN)
logout.click()
However I always end up with:
response = {'status': 400, 'value': '{\n\t"value" : \n\t{\n\t\t"error" : "element not interactable",\n\t\t"message" : "Element is not displayed",\n\t\t"stacktrace" : ""\n\t}\n}\r\n'}
It seems like Selenium can't deal with the bootstrap dropdown. How can I still click any of the elements in this dropdown?
If there is no direct solution for doing this, is there some way for an workaround?