Installing Pyccuracy

Pyccuracy is a useful tool for writing web acceptance tests using a BDD style language. This recipe shows all the steps needed to install and set it up for later recipes.

How to do it...

With these steps, we will install Pyccuracy and all the tools needed to run the scenarios later in this chapter.

  1. Install Pyccuracy by typing pip install pyccuracy.
  2. Download selenium-server.jar from http://github.com/heynemann/pyccuracy/raw/master/lib/selenium-server.jar.
  3. Start it up by typing java -jar selenium-server.jar. Note that if you don't have Java installed, you definitely need to download and install it as well.
  4. Install lxml by typing pip install lxml.
  5. Create a simple test file called recipe35.acc and enter the following code:
    As a Yahoo User
    I want to search Yahoo
    So that I can test my installation of Pyccuracy
    
    Scenario 1 - Searching for Python Testing Cookbook
    Given
        I go to "http://yahoo.com"
    When
        I fill "p" textbox with "Python Testing Cookbook"
        And I click "search-submit" button and wait
    Then
        I see "Python Testing Cookbook - Yahoo! Search Results" title
  6. Run it by typing pyccuracy_console -p test.acc. The following screenshot shows it being run with Firefox (default for this system).
    How to do it...
  7. Run it again, using a different web browser like Safari by typing pyccuracy_console -p test.acc -b safari.

    Note

    At the time of writing, Selenium supported Firefox, Safari, Opera, and IE 7+, but not Chrome.

    How to do it...
  8. In the folder where we ran the test, there should now be a report.html file. Open it up using a browser to view the results. Then click on Expand All.
    How to do it...

How it works...

Pyccuracy uses Selenium, a popular browser-driving application tester to run its scenarios. Pyccuracy provides an out-of-the-box Domain Specific Language (DSL) to write tests. The DSL provides the means to send commands to a test browser and also check the results, verifying web application behavior.

Later on in this chapter, there are several recipes which show more details of Pyccuracy.

See also

  • Testing the basics with Pyccuracy
  • Using Pyccuracy to verify web app security
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.226.121