Selenium Remote Control (RC) is a test tool that allows you to write automated web application UI tests in any programming language against any HTTP website using any mainstream JavaScript-enabled browser.
Selenium RC comes in two parts.
1. A server which automatically launches and kills browsers, and acts as an HTTP proxy for web requests from them.
2. Client libraries for your favorite computer language.
Selenium Testing
TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionality that make it more powerful and easier to use, such as:
TestNG is designed to cover all categories of tests: unit, functional, end-to-end, integration, etc…
Related Page: Different Flavours Of Selenium
Why use TestNG with Selenium RC?
Selenium IDE by itself is great for creating test cases and executing single tests. TestRunner is ok at running a test suite. But if you want full automation against different server and client platforms, you need a way to invoke the tests from a command line process, flexibility in how you create your test suites, and reports that tell you what happened. TestNG provides these features. You can use Selenium RC with other languages as well, but since Sakai is written in Java it makes sense to stick with the language most of us are familiar with already.
Checkout Selenium Interview Questions
How to Install TestNG plugin in Eclipse
TestNG is a testing framework inspired from JUnit and NUnit, but introduces some new functionalities that make it more powerful and easier to use.
Related Page: How To Create Test Suites In Selenium
Testing sample script
package one;
import org.openqa.selenium.server.SeleniumServer;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;
public class FirstTNG {
public SeleniumServer ss;//Create a variable
public Selenium selenium;//Create a variable
@BeforeClass
public void beforeClass() throws Exception
{
ss=new SeleniumServer();//Create an object
ss.start();//start selenium server
selenium=new DefaultSelenium("localhost", 4444, "*firefox", "https://"); //Pass arguments to selenium
selenium.start();//srat selenium server
}
@TEST
public void testFirstTNG() throws Exception
{
//open google page
selenium.open("https://www.google.com");
//maximize window
selenium.windowMaximize();
Thread.sleep(5000);
}
@AfterClass
public void afterClass()
{
//stop selenium
selenium.stop();
//stop selenium server
ss.stop();
}
}
Reports generation using Testing
Testing is required to generate the reports. Without testNG this code won’t work.
Generating reports is easy in Testing compared to other frame works. Testing will generate reports automatically. After running the script just refresh the project. Right click on Project and click Refresh…then u can see a new folder test-output..expand that folder, you can see INDEX.html and emailable-report.html. These two files are the reports.
Creating Test suites using Testing
A test suite is a collection of test cases intended to test a behavior or a set of behaviors of software programs.
For TESTNG we need to create a test suite using XML file. For sample XML file, we can use the (index.html) report created automatically.
1. Click on Index.html
2. Click on LINK under testing.xml column.
3. Copy the XML code.
4. Now create an XML file (Right click on Project---New ---- File)
5. Give file name as testing.xml and copy the code in that file
6. Save the file.
7. Under Classes tag.add classes…and save it..
8. Right click on the XML file from Package Explorer and runas-testngsuite..
9. The scripts will run one after the other and report is created automatically.
Name | Dates | |
---|---|---|
Selenium Training | Nov 02 to Nov 17 | View Details |
Selenium Training | Nov 05 to Nov 20 | View Details |
Selenium Training | Nov 09 to Nov 24 | View Details |
Selenium Training | Nov 12 to Nov 27 | View Details |
Madhuri is a Senior Content Creator at MindMajix. She has written about a range of different topics on various technologies, which include, Splunk, Tensorflow, Selenium, and CEH. She spends most of her time researching on technology, and startups. Connect with her via LinkedIn and Twitter .