-
Notifications
You must be signed in to change notification settings - Fork 112
Automation Selenium RC using TestNG
Selenium far flung manage Selenium far flung control (RC) is a take a look at device that permits you to jot down automated net software UI exams in any programming language towards any HTTP website the usage of any mainstream JavaScript-enabled browser. Selenium RC comes in elements.
A server which robotically launches and kills browsers, and acts as an HTTP proxy for net requests from them. purchaser libraries to your favorite pc language.
Selenium TestNG TestNG is a checking out framework inspired from JUnit and NUnit however introducing some new capability that make it extra effective and easier to use, inclusive of: JDK five Annotations (JDK 1.four is also supported with JavaDoc annotations). bendy check configuration. help for records-driven testing (with @DataProvider). support for parameters. allows distribution of checks on slave machines. effective execution version (no greater TestSuite). Supported by using a selection of tools and plug-ins (Eclipse, idea, Maven, etc…). Embeds BeanShell for in addition flexibility. Default JDK features for runtime and logging (no dependencies). dependent techniques for software server trying out. TestNG is designed to cover all categories of exams: unit, practical, stop-to-end, integration, and many others…
Why use TestNG with Selenium RC ?
Selenium IDE by using itself is high-quality for creating test cases and executing single exams. TestRunner is ok at going for walks a take a look at suite. however if you need complete automation against different server and client platforms, you want a manner to invoke the assessments from a command line technique, flexibility in the way you create your test suites, and reviews that inform you what passed off. TestNG provides those features. you could use seleniumRC with different languages as well, however on the grounds that Sakai is written in Java it makes sense to stick with the language most folks are familiar with already. how to set up TestNG plugin in Eclipse TestNG is a checking out framework inspired from JUnit and NUnit, but introduces some new functionalities that make it greater effective and simpler to use.
visit tolls–set up new software installation window can be opened.click add button. In upload repository window –enter names as TestNG click ok. select TEstNG and click on subsequent. And again, click next next…after installing checking out, just restart Eclipse to mirror the adjustments. TestNG 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"); //Pass arguments to selenium selenium.start();//srat selenium server }
@Test public void testFirstTNG() throws Exception { //open google page selenium.open("http://www.google.com"); //maximize window selenium.windowMaximize(); Thread.sleep(5000); }
@AfterClass public void afterClass() { //stop selenium selenium.stop(); //stop selenium server ss.stop(); } } Reports era the use of TestNG
TestNG is needed to generate the reviews. without testNG this code received’t paintings. generating reports is easy in TEstNG in comparison to other body works. TestNG will generate reviews routinely. After jogging the script just refresh the assignment. right click on venture and click on Refresh…then u can see a new folder check‐output..enlarge that folder, you could see INDEX.html and emailable‐report.html. these two files are the reviews. developing check suites the use of TestNG
A take a look at suite is a collection of take a look at cases intended to test a conduct or a hard and fast of behaviors of software program programs. For TESTNG we need to create a test suite the usage of XML document. For sample XML document, we can use the (index.html) file created robotically.
- click on Index.html
- click on hyperlink beneath testing.xml column.
- replica the XML code.
- Now create an XML report (right click on assignment‐‐‐New ‐‐‐‐ file)
- provide document call as trying out.xml and duplicate the code in that document
- keep the report.
- under training tag.add classes…and shop it..
- proper click on at the XML record from package deal Explorer and runas‐testngsuite..
- The scripts will run one after the opposite and file is created robotically.