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





9 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.

studyfy.com said...

hello everyone! I've been having some problems recently. I couldn't write an essay, I was bored, lazy and didn't want to do it. I was having a really hard time with essays. But one day, I was helped by the Essay writing service here it is studyfy.com . Since then, I don't write essays anymore and all my free time goes to my favorite activities. I also have no problems at school, and my teachers respect me!

Jessica Carvin said...

As a Top Web Developer, I can see how automating Amazon could be incredibly valuable for businesses and consumers alike. One potential use case that comes to mind is automating the product purchasing process.

Imagine being able to create a script that automatically purchases products from Amazon based on certain criteria. For example, you could set up the script to purchase a certain product when it drops below a certain price, or when it goes on sale. This could be incredibly useful for businesses that need to purchase large quantities of products on a regular basis, as it would save them time and effort.

Aaron Reed said...

When seeking a paper writer https://writer24.com/paper-writer , several key factors should guide your decision. Start by reading online reviews to gauge their credibility. The writer you select should possess relevant academic qualifications and demonstrate expertise in your paper's subject matter. While affordability is important, the cheapest options may not always provide the best quality. Strive to find a balance between cost and quality. Timeliness is also a crucial consideration, particularly if you're dealing with strict deadlines. Choose a writer who is responsive and readily available to address any concerns or make revisions promptly. Ultimately, thorough research and careful selection are the keys to finding a competent writer.

govalu said...

I wish to express my genuine gratitude to the creative force behind this blog. Your unwavering dedication and hard work truly shine and are profoundly valued. The consistently perceptive content you produce is a testament to your resolute commitment. I am eagerly looking forward to immersing myself in more of your captivating articles. Your exceptional efforts undoubtedly deserve recognition and a heartfelt recommendation.Multa Conducción Imprudente Nueva Jersey