Activity: Creating a TestNG Test

Before you Begin

Open Chrome and go to https://trainingbypackt.github.io/Beginning-Selenium/lesson_7/activity_7_C-1.html.

Scenario

Once again, we will work with the Gigantic Store application home page, which was modeled into Page Objects during Chapter 6, Page Object Model. We will review how we implemented the automation scripts to validate elements on the application in order to convert them to TestNG tests.

Aim

To implement TestNG tests and migrate automation scripts.

Steps for Completion

  1. Analyze the GiganticStoreScript class.
    In general, a test script should be concise and not do too many different things.
  2. Identify sections from the previous automation script that can be extracted as a test. Sections such as the one to verify results in products pages are good candidates.
  3. Create a test method with the section you extracted from the automation script. Don't forget to create the WebDriver object and go to the browser to the desired URL.
  4. To avoid code duplication and provide simplicity, use the @BeforeMethod and @AfterMethod annotations to simplify the WebDriver creation and teardown.
  5. Convert the validations done with "if else" statements to use TestNG assertions.
  1. Apply the previous steps to the validation that was done for the home page.
  2. Run the tests by clicking on Run next to the class name.

To refer to the detailed steps, go to the Solutions section at the end of this book on page no. 181.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.42.208