Friday, February 16, 2007

How to test your Google Checkout integration using Selenium

You're a merchant and you've integrated your cool e-commerce site with Google
Checkout's Level 2 integration
. Great start!

What is Level 2 integration you ask? Well quite simply, it is a little more detailed process
(than using buy buttons) to integrating your site with Google Checkout. It basically requires
your site to speak XML to Google Checkout during the order flow process, from
posting a cart to charging the order to shipping the order. A simple diagram
from the official Google Checkout integration document should illustrate this
process



A few days later, you make some changes to your site, and you want to test it.
Simple right? Call up cousin Fran in Chicago and have her purchase that cool
backpack she always wanted for her son. Sounds neat. Except that you don't have
a cousin Fran in Chicago, and you want to push your changes live in 5 minutes!

"So if all this is done via APIs, why do I need a browser to test it?" you ask.
In order to test new order notification you need to place an order in the
system. In order to test merchant calculated shipping, you need to have that
order processed and then shipped. And you would create these orders using a
regular browser, just like your customers would.

Obviously the next question is, how can I do all this quickly?
Selenium to the rescue. No not the element
with atomic number 34, but one of the best open source web testing tools
available. Using Selenium, you can easily and quickly create an automated test
that verifies this work flow. Here's how ...

Short answer


Usually in order to test your
application you configure an instance of it to use the Google
Checkout Sandbox
. You configure your sandbox merchant account to
send notifications to your application's url. You can then test
your application's level 2 integration by using your application
to place an order in the Google Ceckout Sandbox, then check that
you received the notification and processed it correctly.


Detailed answer (step-by-step instructions)

  • Step 1: Download and install Selenium

    This is a lot easier than it sounds. Almost too easy to be true. Go to the
    Selenium IDE download
    page
    . Click on the latest Firefox extension version and have it installed
    in your browser. Obviously, this works only in Firefox for now.

    You should see 'Selenium IDE' under Tools menu option.


  • Step 2: Setup Selenium to record your actions

    Again, this step couldn't be simpler. All you need to do is work with the
    application as you would normally do, and let Selenium record the session.
    Selenium will record all the keyboard and mouse input in the browser. Here
    are the step-by-step instructions:

    • Open Firefox
    • Under 'Tools' menu option click Selenium IDE. Selenium IDE window will pop up.
    • Enter the web application's base URL (e.g.
      https://store.chanezon.com/catalog)
    • Keep you mouse pointer over the small red button in upper right
      corner of the Selenium window. If the tool tip says "Now
      Recording. Click to Stop Recording" you're good to go.
      Otherwise click it!


  • Step 3: Record the actions

    In the main Firefox window, go to your web site, and buy an item just like any
    other customer would. Simply follow the regular check out work flow. Selenium will record all your web actions (filling out
    forms, button clicks, etc.) in a script.
  • Step 4: Save your script

    When you're done, click on the small red button in the upper right corner of
    the Selenium window, to indicate you're done recording.

    Here's what a sample recorded script looks like:



    In this specific example, we buy a Microsoft IntelliMouse Explorer by clicking
    on the Google Checkout buy button , entering a
    login and password, and clicking the 'Place order' button.

    The script is recorded as an HTML file containing a simple table. Each row
    represents a recorded step and the columns represent parameters for each step.
  • Step 5: Play back your script

    Now all you need to do is open your previously recorded test script, and
    click on the 'Play' button (green triangle) in the Selenium window. Your
    script will be played back and failures, if any, will be marked in red.
  • Step 6: Verify logs

    Check your server logs to see if you have received the notification from
    Google Checkout. Here's an example:



    Also check your database to determine that you have taken the approriate actions for that order. All these can be automated through regular scripts, or even using Selenium (using
    a similar record-playback strategy described above) if you
    have a web UI to access this data.

No comments: