Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Logging will be done using log4testng. See Logger.java.

Use log4testng.properties to log INFO level messages to the console.

 

Using Selenium

  • The entire test suite will share one WebDriver. This is achieved by creating a base page class (e.g. BasePageTest.java) with a static WebDriver. All other test classes will extend the base page class.
    Image Modified
    Image Modified
  • Tests for elements with multiple attributes to be tested will be implemented using a multi-map.
    Image Added
  • Certain tests may have race conditions, so to avoid timing issues, sleep the thread whenever you perform an action that might change the page.
  • Example:
    Image Added

TestNG Tips

  • Printing the xpath of an element after a failed test will help with locating elements that need to be fixed.
    Sample method for getting the xpath of an element:
    Image Added
    The method should go in the base page class. 
  • StaleElementException: A StaleElementException is thrown when the element you were interacting is destroyed then recreated. Elements in the DOM are often destroyed and recreated when a web page changes dynamically as users interact with it. When this happens the reference to the element in the DOM that you previously had becomes stale and you are no longer able to use this reference to interact with the element in the DOM. You will need to refresh your reference to find the element again. This can be done using a try catch block within a while loop. See example below.
    Image Added