Breaking News

Automate Amazon: Development Environment Setup

This post is first in a series of nine.

Back in June 2015, I blogged about how I would write automated tests vs Dave Haeffner's site, "The-Internet".

For this second project, I picked a more difficult site to automate: Puchasing an order on Amazon.com's site.



Please note: I haven't been doing automation on-the-job for very long. I have less than a year's worth of experience developing automated tests in Selenium WebDriver. Please don't take anything that I am doing as the industry standard.


If you do have knowledge of the industry standard of automated testing, please feel free to correct me! I will be eagerly monitoring the comments section for any advice or wisdom.

Setting Up the Development Environment


For this project I am using:
  • Platform and Operating System: Windows 10.
  • Integrated Development Environment (IDE): IntelliJ. Although we use the Enterprise Edition at work, the only difference between that and the free Community version is extra features for database integration.  
  • Test Framework: TestNG. It is built into the latest version of IntelliJ, but you still need to set up the dependencies in your pom.xml file.
  • Dependencies Management: Even though at work we use Gradle, for this project I am using Maven to add Selenium WebDriver and TestNG as dependencies. 
  • Browsers: Both at work and at home to inspect page elements, I use the Firefox browser plugins Firebug and Firepath to examine the web document.

If you need help getting IntelliJ, setting up Maven, setting up your pom.xml file or TestNG, or installing Firefox, Firebug or Firepath, there is a free introduction on Alan Richardson's page, Start Using Selenium WebDriver at http://seleniumsimplified.com/get-started/.

If you are looking for more material, Alan Richardson has an extensive course on Selenium 2 WebDriver with Java at http://courses.compendiumdev.co.uk/courses/selenium-2-webdriver-with-java which helped me immensely preparing for my current position.

Make sure to go to the official SeleniumHQ site at http://docs.seleniumhq.org/docs/ or visit their new documentation that is still in progress at https://seleniumhq.github.io/docs/.

If it helps, below is a sample of my POM.xml file.

xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0"         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0modelVersion>

<groupId>com.tjmaher.seleniumgroupId>
<artifactId>com.tjmaher.seleniumartifactId>
<version>1.0-SNAPSHOTversion>
<dependencies>
<dependency>
<groupId>org.seleniumhq.seleniumgroupId>
<artifactId>selenium-javaartifactId>
<version>2.48.2version>
dependency>
<dependency>
<groupId>org.testnggroupId>
<artifactId>testngartifactId>
<version>6.1.1version>
dependency>
dependencies>

project>



Run Your First Test

Let's name the test class PurchaseOrderTest.java.

The @BeforeClass method contains the setUp information that launches the browser.
The @AfterClass method contains the tearDown information that closes the browser.

They will be executed respectively before the class PurchaseOrderTest, then after the class is done.





When you run PurchaseOrderTest:

  • The Firefox browser opens up
  • It navigates to Amazon.com
  • The Firefox browser closes.



Now that we know that tests can be run, with the next installment of this blog, we can sketch out a quick test.

-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