Automate Amazon: Sketch out a Use Case
This post is second of a series of nine. Need to go back to the beginning?
With the last blog entry, we talked about setting up a development environment and running our first test.
With this entry, we are going to examine Amazon.com's site and see if we can come up with a quick test to automate creating a purchase order with Amazon's Sign In, AddToCart and Checkout process.
The SignInPage is where we Sign into the site, entering the email address and password into the appropriate text boxes, and select the "Sign in" button. We need to:
For an initial test product in the Purchase Order test, let's use a Mass Market Paperback copy of The Hitchhiker's Guide to the Galaxy, by Douglas Adams. This is the first book in the four book "Hitchhiker trilogy", re-released by Del Ray in 1995.
You can find the Amazon link to the book at http://www.amazon.com/gp/product/0345391802
Besides a lot of absurdist and excellent nerdy humor, this test product has many properties.
While we add this book to the cart and checkout with it -- as much as we can do without any test credit cards -- we will be attempting to verify at each stage that these four properties stay the same.
Now, let's walk through the site, seeing what happens when we add this book to the cart.
First, let's come up with some more proper names we can use.
Now, let's select the [AddToCart] button.
Here, we can verify that the properties on the ProductPage carried over to the ShoppingCart page:
From our sketch, it looks like we can collect the web elements in the package pages into the following Page Objects:
The individual page objects would be Java classes that only contained encapsulate getting, setting, and validating the web elements.
We could do the extra step of grouping up common elements of the test such as the steps to sign into Amazon.com in an actions package in a class called PurchaseOrderActions.java.
NEXT: Setting up Common Utility Methods >>
-T.J. Maher
Sr. QA Engineer, Fitbit
Boston, MA
// Automated tester for [ 8 ] month and counting!
With the last blog entry, we talked about setting up a development environment and running our first test.
With this entry, we are going to examine Amazon.com's site and see if we can come up with a quick test to automate creating a purchase order with Amazon's Sign In, AddToCart and Checkout process.
Draft the Test
Go to the Sign In Page
The SignInPage is where we Sign into the site, entering the email address and password into the appropriate text boxes, and select the "Sign in" button. We need to:
- Go to http://www.amazon.com/
- Mouseover to "Hello. Sign in Your Account"
- Select the "Sign In" button
Sign Into the Site
- At the Sign In page enter the test user name and password.
- Log into the site.
Select a Test Project
You can find the Amazon link to the book at http://www.amazon.com/gp/product/0345391802
Besides a lot of absurdist and excellent nerdy humor, this test product has many properties.
- ProductTitle: The Hitchhiker's Guide to the Galaxy
- Author: Douglas Adams
- OfferPrice: $7.19
- Edition: Mass Market Paperback
While we add this book to the cart and checkout with it -- as much as we can do without any test credit cards -- we will be attempting to verify at each stage that these four properties stay the same.
Now, let's walk through the site, seeing what happens when we add this book to the cart.
ProductPage
First, let's come up with some more proper names we can use.
- Let's call http://www.amazon.com/ the HomePage, and the url the baseURL.
- Since the subfolder is /product/ let's call this section the ProductPage.
- Since the suffix for the URL is 0345391802, let's call this the productID
- So, to get to this specific URL it is baseURL + productPage + productID.
Now, let's select the [AddToCart] button.
ShoppingCartPage
Here, we can verify that the properties on the ProductPage carried over to the ShoppingCart page:
- ProductTitle: The Hitchhiker's Guide to the Galaxy
- Author: Douglas Adams
- OfferPrice: $7.19
- Edition: Mass Market Paperback
Components of the Test
The test methods can go in the package testcases in a class called PurchaseOrderTest.java.From our sketch, it looks like we can collect the web elements in the package pages into the following Page Objects:
- HomePage
- SignInPage
- ProductPage
- ShoppingCartPage
The individual page objects would be Java classes that only contained encapsulate getting, setting, and validating the web elements.
We could do the extra step of grouping up common elements of the test such as the steps to sign into Amazon.com in an actions package in a class called PurchaseOrderActions.java.
View the (mostly) Completed Test Code:
- All test code can be found on GitHub at Automate-Amazon.
NEXT: Setting up Common Utility Methods >>
-T.J. Maher
Sr. QA Engineer, Fitbit
Boston, MA
// Automated tester for [ 8 ] month and counting!
Please note: 'Adventures in Automation' is a personal blog about automated testing. It is not an official blog of Fitbit.com.
Automate Amazon:
- Introduction
- Part One: Environment Setup
- Part Two: Sketch Use Case
- Part Three: CommonUtils, methods, exceptions
- Part Four: Write Sign In Test
- Part Five: Product Enums and Objects
- Part Six: Initializing Login and Cart
- Part Seven: Writing Shopping Cart Test
- Part Eight: Data Driven Tests with TestNG XML
- Part Nine: Code Review Request, please!
- Source Code: GitHub, T.J. Maher