Saturday, March 24, 2012

ReportNG + Selenium



ReportNG create better report than TestNG's normal report.

To Start With:

Step 1 : Download reportng-1.1.3.jar and velocity-dep-1.4.jar into classpath

Step 2: Create a testNG.xml file


Sample code for testNG.xml file



Note: In above code TestScripts2 is the class name under test


Step 3: Now right-clicking on that XML file and select "Run as... TestNG suite".


>>The Report generted will be @ test-output/html and are as shown below:




Note: In case you are getting the following error
java.lang.NoClassDefFoundError: com/google/inject/Module
> at java.lang.Class.getDeclaredMethods0(Native Method)


Solution Is -->
1) Disable defaultlisteners , goto Eclipse Project-> Properties -> TestNG -> Diable deafult listeners.
and , 2) Download google-guice-3.0.zip and paste guice-3.0.jar into your classpath.
Now run and check the report in workspace/test-output/html.

6 comments:

  1. not able to Run testng.xml file :(

    ReplyDelete
  2. can u plz explain in detail of where to place the testng.xml and where the build.xml file should be???

    ReplyDelete
  3. Not able to run "testNG.xml" It gives error:

    org.testng.TestNGException: java.net.UnknownHostException: test.org
    at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:341)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:88)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
    Caused by: java.net.UnknownHostException: test.org
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
    at java.net.Socket.connect(Socket.java:579)
    at java.net.Socket.connect(Socket.java:528)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:378)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:473)
    at sun.net.www.http.HttpClient.(HttpClient.java:203)
    at sun.net.www.http.HttpClient.New(HttpClient.java:290)
    at sun.net.www.http.HttpClient.New(HttpClient.java:306)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:995)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:931)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:849)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1299)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:632)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:1270)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:1237)
    at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(XMLDTDScannerImpl.java:260)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(XMLDocumentScannerImpl.java:1153)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(XMLDocumentScannerImpl.java:1049)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:962)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:489)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1210)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:568)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:302)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
    at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:17)
    at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:10)
    at org.testng.xml.Parser.parse(Parser.java:172)
    at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:311)

    ReplyDelete
    Replies
    1. I also got this error. And now, I don't know what to do. How can you resolve it. Thank you!

      Delete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Hi, Let me know if there are any blogs on Selenium Grid. Hub connecting to nodes with different platforms. thanks :)

    ReplyDelete