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

))

# He adds an item to the list

list_page

.

add_new_item

(

'Hi Edith!'

)

# When Edith refreshes the page, she sees Oniciferous's addition

self

.

browser

=

edith_browser

self

.

browser

.

refresh

()

list_page

.

wait_for_new_item_in_list

(

'Hi Edith!'

,

2

)

That’s a couple more additions to our Page object:

functional_tests/home_and_list_pages.py (ch21l013).

ITEM_INPUT_ID

=

'id_text'

[

...

]

class

HomePage

(

object

):

[

...

]

def

get_item_input

(

self

):

return

self

.

test

.

browser

.

find_element_by_id

(

ITEM_INPUT_ID

)

class

ListPage

(

object

):

[

...

]

def

get_item_input

(

self

):

return

self

.

test

.

browser

.

find_element_by_id

(

ITEM_INPUT_ID

)

def

add_new_item

(

self

,

item_text

):

current_pos

=

len

(

self

.

get_list_table_rows

())

self

.

get_item_input

()

.

send_keys

(

item_text

+

'

\n

'

)

self

.

wait_for_new_item_in_list

(

item_text

,

current_pos

+

1

)

def

get_list_owner

(

self

):

return

self

.

test

.

browser

.

find_element_by_id

(

'id_list_owner'

)

.

text

It’s long past time to run the FT and check if all of this works!

$

python3 manage.py test functional_tests.test_sharing

share_box = list_page.get_share_box()

[...]

selenium.common.exceptions.NoSuchElementException: Message: 'Unable to locate

element: {"method":"css selector","selector":"input[name=email]"}' ;

That’s the expected failure; we don’t have an input for email addresses of people to share

with. Let’s do a commit:

$

git add functional_tests

$

git commit -m "Create Page objects for Home and List pages, use in sharing FT"

394

|

Chapter 21: The Token Social Bit, the Page Pattern, and an Exercise for the Reader