Software QA & Testing Videos

TestNG Assert Video Tutorial

Written by Zenergy | Feb 2, 2018 7:17:10 PM

Automation engineers, Chris Lawson and Ryan Eisma, demonstrate how to use testing asserts for basic verifications in test scripts.

"Many times in your test you are going to want to verify or assert, for example, that something is on the screen or that two specific values are equal to each other." - Automation expert, Chris Lawson

But, how do you address this goal of basic verifications in test scripts? Two methods for doing so is to either

  1. Build your own assertions class or
  2. Simply leverage what's already provided for us through other tools (Such as TestNG). In this video demo, Ryan Eisma, demonstrates how this can be done to complete the following assertions below.

"Assertions are a check to make sure that your test has successfully gotten to a particular point or that the value that you expect to be on that page is in fact there." - Automation expert, Ryan Eisma

Follow the times to match the video with the text provided below:

  • (00:43 - 00:47) With a simple test: Navigate to a site. You will need to instantiate a new GetkoDriver for Firefox and instantiate that driver. Then you are going to navigate to the webpage and find the web element on that page.
  • (00:57 - 01:28) Leverage the TestNG class of assertions for this test: For example, since if we are trying to find a page header we can assert that the header is actually displayed on the screen when we navigate to it.
  • (01:28 - 01:45) Assert that something is false: For example, if you were trying to our website (www.zenergytechnologies.com/) and take that URL and verify that it is false or that the URL is not "google" since that the site we want to be on.
  • (01:45 - 02:04) Check data against itself: TestNG provides the assert equals class, which allows you to get text on the page; since we have a header element you can verify that the header says Zenergy Technologies in it.
  • (02:04 - 02:17) Assert that it is not "Null": Ensuring that the site populated something if there is a value on the page (i.e. use the assert not null class).

Again, these are only a few methods call to check that values shown on the screen are correct with what is being reported correctly. For more information we would recommend looking further into the TestNG assertions class.

>> Subscribe to Zenergy on Youtube for more videosRead our blog, Five Common Missteps in Selenium Test Automation Implementations.