samedi 8 avril 2017

How to show a jquery dropdown menu in a django test with selenium?

I don't find the way to make visible a jquery dropdown menu in a django test with selenium. Here some parts of the code ("admin_user" is the link who has to drop down the menu with link "Coop Admin App"):

def wait_loading(self, driver, xpath_string):
    try:
        WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, xpath_string)))
        return True
    except TimeoutException as ex:
        print("Exception has been thrown. " + str(ex))

def test_membership_request(self):
    s = self.selenium
    s.get('%s%s' % (self.live_server_url, "/"))
    self.wait_loading(s, '//a[contains(text(), "admin_user")]')
    s.find_element_by_partial_link_text("admin_user").click()
    self.wait_loading(s, '//a[contains(text(), "Coop Admin App")]')
    s.find_element_by_partial_link_text('Coop Admin App').click()

The test is always throwing ElementNotVisibleException, so the click in "admin_user" seems not to make visible "Coop Admin App". Any ideas?

Edit: I've been trying with:

s.execute_script("document.querySelectorAll('a[data-toggle=dropdown]')").click()

with the same problems.

Aucun commentaire:

Enregistrer un commentaire