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 _.

http://gnosis.cx/publish/programming/regular_expressions.html

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.

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 of the 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.

Pages

Subscribe to OpenWritings.net RSS