TestNG - Run specific groups of tests

One of the nice features of TestNG is that it allows you to run specific groups of tests among all the tests that you have written. In my case, this feature is handy when I want to run read only tests on the production environment. The idea is to associate each test method to a group. When you want to run each group of tests separately, you only invoke your desired groups through the configuration file of TestNG. The following shows you how to do it.

  1. To associate a test to a group, simply specify the group name in the groups attribute of the @Test annotation.

Java - Installation of JDK

JDK is the software development kit for creating Java programs. Instructions below show you step-by-step how to install and set it up.

  1. Download JDK. Install it and follow the instructions shown on the screen.
  2. Now that the JDK is installed, you have to add the binary folder path of the JDK to the PATH environment variable of your MS Windows.
    1. Depending on the version of your MS Windows, the steps below may be different but similar.

Java

Java programming language

Selenium - Misuse of waitForPageToLoad()

The common mistake that people usually do is to use waitForPageToLoad() function to wait for what appears to be a webpage being loaded. But, in fact, it is Ajax or JavaScript that is doing some changes to a portion of the webpage. As a result, the waitForPageToLoad() function will always time out because it is expecting for the whole webpage to load that never happened.

Selenium - Where to put Selenium.stop() within testing framework?

When using Selenium with a testing framework such as JUnit or TestNG, it is better to put selenium.stop() in the "closing method"(i.e. @After*) instead of in the test method itself. In this way, if tests failed, then the testing framework will be able to close the browser. Thus, you will save a lot of computer resources if your tests are opening and closing the browser thousands of times.

Code below show that TestNG will close the browser even the method failed.
 

Selenium - Speed benchmark of locators

Selenium locators are not all equals. Some locators are faster than others. Therefore, I took up the task to measure the speed of each Selenium locators. The speed test that I did is to measure the time that each locator took to fill up the 1st 50 input fields out of 500 inputs fields. From the results, ID locator is the fastest.

Selenium - First Selenium application in Java

The following shows you step-by-step how to run your first Selenium RC application in Java.

  1. It is assumed that you have JDK installed and set in your computer. If you are getting the version number(e.g javac 1.6.0_06) by running the following command in the Command Prompt, then your Java Compiler is installed and set correctly.
    javac -version
  2. Download Selenium RC.

Selenium

Overview
Selenium is a tool that employs Javascript in order to take control over your browsers and simulate web surfing activities. Therefore, Selenium is able to replicate any action typically undertaken by a user, such as clicking, typing and retrieving data from web pages.

When combining Selenium with other testing frameworks such as JUnit or TestNG, you are getting a very powerful and complete testing framework for web applications.

Drupal

Requirements

  • Apache is installed.
  • PHP is installed.
  • MySQL is installed.

To check if you have all the requirements, do the following steps:

  1. Paste <?php phpinfo(); ?> into a text editor and save as info.php
  2. Copy info.php into the root directory of the webserver(eg. htdocs folder)
  3. Open with an web browser http://yourDomain.com/info.php. You should see PHP Version X.X.X and MySQL Support. Otherwise, some requirements are not installed.

TestNG - Execution order of TestNG's annotations

Codes below show the execution order of commonly used annotations of TestNG.

/**
 * ExecutionOrderOfTestNGAnnotations.java
 * Show execution order of commonly used annotations of TestNG
 * Author: Xuan Ngo
 */
 
/*
 // OUTPUT:
 Run Constructor.(1695 ms)
 Run @BeforeTest method.(1498 ms)
 Run @BeforeClass method.(1184 ms)
 Run @BeforeMethod method.(839 ms)
 Run @Test method.(621 ms)
 Run @AfterMethod method.(594 ms)
 Run @AfterClass method.(1262 ms)
 Run @AfterTest method.(1971 ms)
 */
import org.testng.annotations.BeforeTest;

Syndicate content