![Show Menu](styles/mobile-menu.png)
![Page Background](./../common/page-substrates/page0283.png)
You can even see some of the debug output I left in my spiked view implementations.
Now it’s time to revert all of our temporary changes, and reintroduce them one by one
in a test-driven way.
Reverting Our Spiked Code
$
git checkout master
# switch back to master branch
$
rm -rf accounts
# remove any trace of spiked code
$
git add functional_tests/test_login.py
$
git commit -m "FT for login with Persona"
Now we rerun the FT and let it drive our development:
$
python3 manage.py test functional_tests.test_login
selenium.common.exceptions.NoSuchElementException: Message: 'Unable to locate
element: {"method":"id","selector":"login"}' ; Stacktrace:
[...]
The first thing it wants us to do is add a login link. Incidentally, I prefer prefixing HTML
IDs with
id_
; it’s a convention to make it easy to tell the difference between classes and
IDs in HTML and CSS. So let’s tweak the FT first:
functional_tests/test_login.py (ch15l017).
self
.
browser
.
find_element_by_id
(
'id_login'
)
.
click
()
[
...
]
self
.
wait_for_element_with_id
(
'id_logout'
)
Next a “do-nothing” login link. Bootstrap has some built-in classes for navigation bars,
so we’ll use them:
lists/templates/base.html.
<div
class=
"container"
>
<nav
class=
"navbar navbar-default"
role=
"navigation"
>
<a
class=
"navbar-brand"
href=
"/"
>
Superlists
</a>
<a
class=
"btn navbar-btn navbar-right"
id=
"id_login"
href=
"#"
>
Sign in
</a>
</nav>
<div
class=
"row"
>
[...]
After 30 seconds, that gives:
AssertionError: could not find window
License to move on! Next thing: more JavaScript.
De-spiking
|
255