![Show Menu](styles/mobile-menu.png)
![Page Background](./../common/page-substrates/page0353.png)
self
.
get_item_input_box
()
.
send_keys
(
'Click cows
\n
'
)
second_list_url
=
self
.
browser
.
current_url
# Under "my lists", her new list appears
self
.
browser
.
find_element_by_link_text
(
'My lists'
)
.
click
()
self
.
browser
.
find_element_by_link_text
(
'Click cows'
)
.
click
()
self
.
assertEqual
(
self
.
browser
.
current_url
,
second_list_url
)
# She logs out. The "My lists" option disappears
self
.
browser
.
find_element_by_id
(
'id_logout'
)
.
click
()
self
.
assertEqual
(
self
.
browser
.
find_elements_by_link_text
(
'My lists'
),
[]
)
If you run it, the first error should look like this:
selenium.common.exceptions.NoSuchElementException: Message: 'Unable to locate
element: {"method":"link text","selector":"My lists"}' ; Stacktrace:
The Outside Layer: Presentation and Templates
The test is currently failing saying that it can’t find a link saying “My Lists”. We can
address that at the presentation layer, in
base.html
, in our navigation bar. Here’s the
minimal code change:
lists/templates/base.html (ch18l002-1).
{% if user.email %}
<ul
class=
"nav navbar-nav"
>
<li><a
href=
"#"
>
My lists
</a></li>
</ul>
<a
class=
"btn navbar-btn navbar-right"
id=
"id_logout"
[...]
Of course, that link doesn’t actually go anywhere, but it does get us along to the next
failure:
self.browser.find_element_by_link_text('Reticulate splines').click()
[...]
selenium.common.exceptions.NoSuchElementException: Message: 'Unable to locate
element: {"method":"link text","selector":"Reticulate splines"}' ; Stacktrace:
Which is telling us we’re going to have to build a page that lists all of a user’s lists by title.
Let’s start with the basics—a URL and a placeholder template for it.
Again, we can go outside-in, starting at the presentation layer with just the URL and
nothing else:
The Outside Layer: Presentation and Templates
|
325