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.
JDK is the software development kit for creating Java programs. Instructions below show you step-by-step how to install and set it up.
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.
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 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.
The following shows you step-by-step how to run your first Selenium RC application in Java.
javac -version
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.
Requirements
To check if you have all the requirements, do the following steps:
<?php phpinfo(); ?> into a text editor and save as info.phpCodes 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;