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

APPENDIX A

PythonAnywhere

Are you planning to use PythonAnywhere to follow along with this book? Here’s a few

notes on how to get things working, specifically with regards to Selenium/Firefox tests,

running the test server, and screenshots.

If you haven’t already, you’ll need to sign up for a PythonAnywhere account. A free one

should be fine.

Running Firefox Selenium Sessions with Xvfb

The next thing is that PythonAnywhere is a console-only environment, so it doesn’t

have a display in which to pop up Firefox. But we can use a virtual display.

In

Chapter 1

,

when we write our first ever test ,

you’ll find things don’t work as expected.

The first test looks like this, and you can type it in using the PythonAnywhere editor

just fine:

from

selenium

import

webdriver

browser

=

webdriver

.

Firefox

()

browser

.

get

(

'http://localhost

:8000'

)

assert

'Django'

in

browser

.

title

But when you try and run it (in a

Bash console

), you’ll get an error:

$

python3 functional_tests.py

Traceback (most recent call last):

File "tests.py", line 3, in <module>

browser = webdriver.Firefox()

File "/usr/local/lib/python3.3/site-packages/selenium/webdriver/firefox/webdrive

self.binary, timeout),

File "/usr/local/lib/python3.3/site-packages/selenium/webdriver/firefox/extensio

self.binary.launch_browser(self.profile)

File "/usr/local/lib/python3.3/site-packages/selenium/webdriver/firefox/firefox_

self._wait_until_connectable()

File "/usr/local/lib/python3.3/site-packages/selenium/webdriver/firefox/firefox_

409