I am testing my site with a functional test, but it seems Selenium does not click the link in the menu, when watching the test running with waits between function calls it opens the menu but then it stays on the page although the link with the id can be find in the browser in the website source code.
HTML
<div class="off-canvas-wrap" data-offcanvas>
<div class="inner-wrap">
<nav class="tab-bar">
<section class="left-small">
<a id="id_toggle_menu" class="left-off-canvas-toggle menu-icon" href="#"><span></span></a>
</section>
<section class="middle tab-bar-section">
<h1 class="title"><a href="{% url 'home' %}">LearnCloud</a></h1>
</section>
</nav>
<aside class="left-off-canvas-menu">
<ul class="off-canvas-list">
<li><label>Menu</label></li>
<li><a href="{% url 'notecards_add' %}">Home</a></li>
<li ><a id="id_link_to_notecards" href="{% url 'notecards_add' %}">Add new notecards</a></li>
</ul>
</aside>
<section class="main-section">
<!-- content goes here -->
{% block main %}
{% endblock %}
</section>
<a class="exit-off-canvas"></a>
</div>
</div>
Selenium/Python in test function:
self.browser.find_element_by_id("id_toggle_menu").click()
self.browser.find_element_by_id("id_link_to_notecards").click()
current_url = self.browser.current_url
self.assertRegex(current_url, "/notecards/add")
Aucun commentaire:
Enregistrer un commentaire