Apache Ant is a Java-based build tool.

Define a variable

TestNG - First TestNG test

Write TestNG test

Writing tests using TestNG is easy. There are only 2 steps:

Java - Setting the class path

This tutorial offers step-by-step instructions on how to set up the class path. I will use selenium-java-client-driver.jar and junit-4.5.jar as examples to show you how to add them to the CLASSPATH.

  1. Depending on the version of your MS Windows, the steps below may be different but similar.
    • If you are using MS Windows XP, then open [Classic View]Control Panel->System->Advanced->Environment Variables.


WARNING: If you want to learn to write batch script in DOS, stop it right now! Do yourself a favor. Stop reading this tutorial. Unless your are masochist. Please consider other alternative such as Perl. DOS is a pain and the 'language' is not intuitive and not logical.


Display string.

Regular Expression - Grep

# Grep tab using Perl regex
grep -P "\t"
# Select multiple text patterns(e.g "this" or "that")

Regular Expression - Sed

Helpful Sed one-liners commands.

REM Delete empty line
sed -e "/^$/d" 1x.txt > 2x.txt

REM Delete all newline.( Concatenate each line of 1x.txt into 1 line of string )
sed ":a;N;$!ba;s/\n//g" 1x.txt > 2x.txt

REM Print line without 'code'
sed -n "/code/!p" 1x > 2x.txt
REM In bash shell, use single quote.

REM Delete line 2 up to line 10 inclusively.
sed -e "2,10d" 1x.txt > 2x.txt

REM Skip the 3rd line(Replace 'a' with 'b' for all lines except the 3rd line).
sed -e "3n; s/a/b/g" 1x.txt > 2x.txt

Regular Expression

Regular expression is an expression that describe the pattern of characters or strings.

[a-z, 0-9, _]*: Permit strings that contains a-z and/or 0-9 and/or _.

Selenium - Locators

In order for Selenium to control and manipulate each HTML element(e.g. <a>, <input>, <div>, etc) on the website, you have to provide it with a reference to each element. That reference is used by Selenium to identify the element and apply the actions on that element. The term used in Selenium to denote the reference of an element is called locator.

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.


Subscribe to RSS