Background Image
Table of Contents Table of Contents
Previous Page  421 / 478 Next Page
Information
Show Menu
Previous Page 421 / 478 Next Page
Page Background

The idea behind the Page pattern is that it should capture all the information about a

particular page in your site, so that if, later, you want to go and make changes to that

page—even just simple tweaks to its HTML layout for example—you have a single place

to go and look for to adjust your functional tests, rather than having to dig through

dozens of FTs.

The next step would be to pursue the FT refactor through our other tests. I’m not going

to show that here, but it’s something you could do, for practice, to get a feel for what the

trade-offs between D.R.Y. and test readability are like…

Extend the FT to a Second User, and the “My Lists” Page

Let’s spec out just a little more detail of what we want our sharing user story to be. Edith

has seen on her list page that the list is now “shared with” Oniciferous, and then we can

have Oni log in and see the list on his “My Lists” page, maybe in a section called “lists

shared with me”:

functional_tests/test_sharing.py (ch21l010).

[

...

]

list_page

.

share_list_with

(

'oniciferous@example.com'

)

# Oniciferous now goes to the lists page with his browser

self

.

browser

=

oni_browser

HomePage

(

self

)

.

go_to_home_page

()

.

go_to_my_lists_page

()

# He sees Edith's list in there!

self

.

browser

.

find_element_by_link_text

(

'Get help'

)

.

click

()

That means another function in our

HomePage

class:

functional_tests/home_and_list_pages.py (ch21l011).

class

HomePage

(

object

):

[

...

]

def

go_to_my_lists_page

(

self

):

self

.

test

.

browser

.

find_element_by_link_text

(

'My lists'

)

.

click

()

self

.

test

.

wait_for

(

lambda

:

self

.

test

.

assertEqual

(

self

.

test

.

browser

.

find_element_by_tag_name

(

'h1'

)

.

text

,

'My Lists'

))

Once again, this is a function that would be good to carry across into

test_my_lists.py

,

along with maybe a

MyListsPage

object. Exercise for the reader!

In the meantime, Oniciferous can also add things to the list:

functional_tests/test_sharing.py (ch21l012).

# On the list page, Oniciferous can see says that it's Edith's list

self

.

wait_for

(

lambda

:

self

.

assertEqual

(

list_page

.

get_list_owner

(),

'edith@example.com'

Extend the FT to a Second User, and the “My Lists” Page

|

393