December 24, 2015

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.


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


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.

  • 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
... Since we don't have any test credit cards, let's skip placing your order and end the test here.

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:


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





5 comments:

Oliver said...

This is great, I think you can help me create a use case for my Nursing assignment too, or at least provide me some Nursing assignment help UK so that I can understand the logics and create the assignment on my own.

jeffreyjonathan411 said...

Yes, you are right I agree with you you can hire the best assignment writer in the UK to do your assignments & homework. We have the best writers online dissertation writing services if you need help with your assignments so contact.

John said...

Well, to be honest, I have not read it entirely but I think it is related to the website because here is the content that can be used to create a website. Anyways, I have saved this post and will visit it immediately after finding business management assignment help service to complete my assignment.

unknown said...

Taking online service is a new trend for getting over the academic burden for students. I have also tried the UK Essay Writers services once which turned as the best help for all of my assignment writing troubles. Because it took off all of the extra pressure and provided great ease in assignment submission.

IngaVelington said...


If you're struggling with a math homework help https://essayservice.com/math-homework-help, it's important to seek out a tutor who is experienced in this subject. This way, you can rest assured that you're not the only one in need of assistance. It's important to find a tutor who can explain complex concepts in simple terms. You need someone who can understand physics in depth and can break things down for you.