Creating Sample Data Reading Test In WebDriver Data Driven Framework

STEP 8


PrerequisiteAll the steps from STEP 1 to STEP 7 should be followed properly as described.

We have added file reading utility In our selenium webdriver software automation testing data driven framework so now we are all set to read data from the .xls files. As you all know, Right now we have 2 test suites In our software automation testing framework and each test suite have 2 test cases. So total there are 2 test suites and 4 test cases In our software automation testing framework. And also we have created two separate .xls files for each test suite. So .xls files and their sheets mapping with the test suites and their test cases will be as bellow.


  • com.stta.SuiteOne -> SuiteOne.xls
    • SuiteOneCaseOne.java -> SuiteOneCaseOne Sheet
    • SuiteOneCaseTwo.java -> SuiteOneCaseTwo Sheet
  • com.stta.SuiteTwo -> SuiteTwo.xls
    • SuiteTwoCaseOne.java -> SuiteTwoCaseOne Sheet
    • SuiteTwoCaseTwo.java -> SuiteTwoCaseTwo Sheet
Download Required Files
Now let we try to read data from SuiteOneCaseOne test data Sheet of SuiteOne.xls  File for SuiteOneCaseOne.java test case. For that, You need to download bellow given 3 files.
  1. Download SuiteBase.java File
  2. Download SuiteOneBase.java File
  3. Download SuiteOneCaseOne.java File
Now copy-paste above downloaded files one by one as described bellow to replace existing files.
(Note : It should replace existing file when paste It on package. It should not Insert new file.)
  1. Paste SuiteBase.java File on com.stta.TestSuiteBase Package.
  2. Paste SuiteOneBase.java File on com.stta.SuiteOne Package.
  3. Paste SuiteOneCaseOne.java File on com.stta.SuiteOne Package.
SuiteBase.java File Explanation
Open this file In your eclipse and view the code. I have created Init() function In this file to Initialize all .xls file's paths.

Note : Your all .xls files must be located at bellow given path. If .xls files  are located at any other location then you have to change all file's path In SuiteBase.java too.
.xls File's Paths should Be : E:\backup\Training\WDDF\src\com\stta\ExcelFiles

SuiteOneBase.java File Explanation
This file do not have any function on this stage. It Is just child class of SuiteBase. Will Implement required functions later on.

SuiteOneCaseOne.java File Explanation
This Is our test case file. Using this file, we will read test data from .xls file and then print them In console. This file contains bellow given different functions and usage of all those functions Is described bellow.
  • checkCaseToRun() : If you will look at this function, I have used TestNG @BeforeTest annotation above the function. That means It will be executed before the @Test annotation method or we can say before starting of test execution. It will call Init() function from SuiteBase class to Initialize .xls files and then set SuiteOne.xls file's path In FilePath variable.
  • SuiteOneCaseOneTest() : This function has TestNG @Test annotation that means It will be executed after execution of @BeforeTest annotation function. Also used dataProvider with @Test annotation to accept test data from SuiteOneCaseOneData() dataprovider function. It will accept four string argument values On every Iteration.
  • SuiteOneCaseOneData() : It will retrieve test data from SuiteOne.xls file's SuiteOneCaseOne sheet and return data to SuiteOneCaseOneTest() function.
Note : retrieveTestData(String wsName) function In Read_XLS.java file Is written In such a way so that always It will skip reading of last two columns of data sheet("DataToRun" and "Pass/Fail/Skip").

Running Sample .xls Data Reading Test
Now It Is time to run our sample data reading test to make sure that every thing Is fine.
  • Right click on SuiteOneCaseOne.java file In eclipse and go to Run As -> TestNG Test as shown bellow.


It will execute your software test case using TestNG. @Test annotation method will be executed two times because there are two data rows In SuiteOneCaseOne test data sheet. On completion of test execution, You will see bellow given result In your console.

Console Result

TestNG Result

If you can see above results then everything Is fine till now In your software testing data driven framework creation. We succeed for running sample data reading test In our webdriver data driven framework.

60 comments:

  1. Hi,

    While running the above code, iam getting the below error.Please help me to fix this.

    java.io.FileNotFoundException

    ReplyDelete
    Replies
    1. Verify you have not forget any step.. It Is working fine for me any many more peoples

      Delete
    2. If you dont have the .xls files in the package specified you ll be getting this error.

      Say if u have the .xls files in some other directory try changing the
      line 14,16,18 of the SuiteBase.java file into

      System.getproperty("yourfilepath")

      for the respective file @ Ranjani Bala

      Delete
    3. This is due to the wrong path or notation given for the file.

      As @Vijaykumar says, you need to update line 14,16,18 from SuiteBase.java.

      From my case, I just change the notation '\\src' to '//src' for all path(line 14,16,18).

      Check your error message;

      ***Mine was: java.io.FileNotFoundException: /home/swapnil/Documents/Backup/Training/WDDF\src\com\stta\ExcelFiles\TestSuiteList.xls (No such file or directory)


      It is clear showing the variations for my file path. Somewhere it's '/' notation and somewhere its '\'. I just renamed it and problem solved.. :)

      Delete
  2. I am getting the following error on running the code (even though i have followed step 1 till here)

    Cannot find class in classpath: com.stta.SuiteOne.SuiteOneCaseOne
    at org.testng.xml.XmlClass.loadClass(XmlClass.java:81)
    at org.testng.xml.XmlClass.init(XmlClass.java:73)
    at org.testng.xml.XmlClass.(XmlClass.java:59)
    at org.testng.xml.TestNGContentHandler.startElement(TestNGContentHandler.java:543)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(Unknown Source)
    at javax.xml.parsers.SAXParser.parse(Unknown Source)
    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)
    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)

    ReplyDelete
  3. Hi, as I am Pasting SuiteBase.java File on com.stta.TestSuiteBase Package so its not replace the Existing File But its just insert and giving the error. So What Should I do?

    ReplyDelete
  4. Hi,

    While Pasting SuiteBase.java File on com.stta.TestSuiteBase Package so its not replace the Existing file but its just insert and giving the Error. Can you tell me what should i do?

    ReplyDelete
  5. when i do it means delete existing file and add new one then it gives the error.. please suggest me what should i do?

    ReplyDelete
  6. I did it, Means i have deleted the Existing file and then add new so its gives the error sign on the new file and on the package, please help What should i do?

    ReplyDelete
  7. Great!!! Works Its Really help for me to find-out automation. I am new to selenium framework. While i Try this by step by step works for me. Thanks a lot.

    ReplyDelete
  8. Hi,

    When I Right Click on Suiteonecaseone File and select Run As there's only Run Configurations option there is no TestNG Test option.

    ReplyDelete
  9. Hi,

    When I Right Click on suiteonecaseone File and select Run As there's only Run Configurations option and there is no TestNG Test option. Please get back to me. Thanks.


    ReplyDelete
    Replies
    1. Have you installed testng in eclipse? view this page -> http://software-testing-tutorials-automation.blogspot.in/2014/03/steps-of-downloading-and-installing.html

      Delete
  10. Hi Arvind,

    Don't know how to thank you! :) This is an awesome tutorial. I started learning selenium webdriver with Java. Got your tutorial on Google's first link. I have been following that. Learning quickly from beginning and I am here at this step after 5 days. Thanks a lot!

    While running this test I am getting some error - java.io.FileNotFoundException: D:\backup\Training\WDDF\src\com\stta\ExcelFiles\TestSuiteList.xls (The system cannot find the path specified)
    at java.io.FileInputStream.open0(Native Method)...
    I went through some solutions in web, but can't believe them.

    Could you please guide me.

    Waiting for a positive response.

    Thanks
    Nilachal

    ReplyDelete
    Replies
    1. Have you added TestSuiteList.xls file as described in this post? -> http://software-testing-tutorials-automation.blogspot.in/2014/07/create-required-xls-files-for-selenium.html

      Delete
    2. Thanks Aravind for replying.
      I don't miss a single line from your writings. Yes I have followed all the steps properly and the files are there at their respective places. I wanted to put a screenshot but I think that's not possible here. I think its best to follow the steps again. Does it have anything to be with the file read/write permissions?

      Thanks
      Nilachal

      Delete
  11. when I copied the code for Suiteonecaseone , I ma getting error message Test is not an annotation type and DataProvider is not an annotation type. Please help in fixing the issue.

    Thanks,

    ReplyDelete
  12. Thank you very much Arvind for sharing such wonderful thing. I really learn a lot and it's very much useful to me. I am successfully able to run the test cases. Thank you once again. Keep sharing such nice article.

    ReplyDelete
  13. Hi, I don't understand why you create a new instance of ReadXLS using:
    TestSuiteListExcel = new Read_XLS(System.getProperty(${path})). It makes me some fails, just providing the path during the instantiation works fine
    TestSuiteListExcel = new Read_XLS(${path})

    Could you explain what's the difference? Thanks

    ReplyDelete
  14. Am unable to download the SuiteOneBase.java file now

    ReplyDelete
  15. hiii i am getting following error .. "java.lang.NullPointerException"

    ReplyDelete
  16. Hi,Mr. Aravind
    I don't know how to let SuiteOne.xls showing on my eclipse(Mar 1).
    Thanks.

    Mak

    ReplyDelete
  17. I am also getting "java.lang.NullPointerException". Please help

    java.lang.NullPointerException
    at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:150)
    at org.testng.internal.Parameters.handleParameters(Parameters.java:430)
    at org.testng.internal.Invoker.handleParameters(Invoker.java:1276)
    at org.testng.internal.Invoker.createParameters(Invoker.java:992)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1082)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
    at org.testng.TestRunner.privateRun(TestRunner.java:773)
    at org.testng.TestRunner.run(TestRunner.java:623)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
    at org.testng.SuiteRunner.run(SuiteRunner.java:259)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1110)
    at org.testng.TestNG.run(TestNG.java:1018)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

    ReplyDelete
  18. I am also getting NullPointerException. Please help

    java.lang.NullPointerException
    at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:150)
    at org.testng.internal.Parameters.handleParameters(Parameters.java:430)
    at org.testng.internal.Invoker.handleParameters(Invoker.java:1276)
    at org.testng.internal.Invoker.createParameters(Invoker.java:992)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1082)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
    at org.testng.TestRunner.privateRun(TestRunner.java:773)
    at org.testng.TestRunner.run(TestRunner.java:623)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
    at org.testng.SuiteRunner.run(SuiteRunner.java:259)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1110)
    at org.testng.TestNG.run(TestNG.java:1018)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

    ReplyDelete
  19. Please help

    java.lang.NullPointerException
    at java.io.FileInputStream.(FileInputStream.java:130)

    java.lang.NullPointerException
    at java.io.FileInputStream.(FileInputStream.java:130)
    at java.io.FileInputStream.(FileInputStream.java:130)


    Caused by: java.lang.NullPointerException
    at com.stta.utility.Read_XLS.retrieveTestData(Read_XLS.java:160)

    ReplyDelete
  20. Hi everyone,
    I got the errors too, I tried to add all jar files to Libraries as usual instead of in "JarFiles" folder in step 4. Then I can run the project successfully in Step 8. So, let try that one. Good luck. :)

    ReplyDelete
  21. When I try to execute the class with testng then it is giving error as given.
    1.error exist in required project.
    2.if we still proceed then i am getting "a jni error has occurred please check your installation and try again coming"
    can you please give any feedback so that i can execute it successfully.

    ReplyDelete
  22. Hi Aravind,

    Thank you for your tutorial. I have been doing it since the beginning. And only this I have encountered an error like this "Exception in thread "main" com.beust.jcommander.ParameterException: Unknown option: -protocol
    at com.beust.jcommander.JCommander.parseValues(JCommander.java:742)
    at com.beust.jcommander.JCommander.parse(JCommander.java:282)
    at com.beust.jcommander.JCommander.parse(JCommander.java:265)
    at com.beust.jcommander.JCommander.(JCommander.java:210)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:162)"

    Do you know what is this mean?

    ReplyDelete
    Replies
    1. I have same issue , How did you resolve it

      Delete
  23. I have solved it. thank you.

    ReplyDelete
  24. Hi Aravind,

    I only got this result

    [TestNG] Running:
    C:\Temp\testng-eclipse--49012274\testng-customsuite.xml


    ===============================================
    Default test
    Tests run: 0, Failures: 0, Skips: 0
    ===============================================


    ===============================================
    Default suite
    Total tests run: 0, Failures: 0, Skips: 0
    ===============================================

    [TestNG] Time taken by org.testng.reporters.JUnitReportReporter@340f438e: 1 ms
    [TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 1 ms
    [TestNG] Time taken by org.testng.reporters.EmailableReporter2@7f63425a: 4 ms
    [TestNG] Time taken by org.testng.reporters.XMLReporter@1e643faf: 4 ms
    [TestNG] Time taken by org.testng.reporters.jq.Main@7c75222b: 23 ms
    [TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@6b71769e: 13 ms

    Test suite is not running. and I've got this green thing from the bottom page of the console in TestNG Result Listening Job keeps on running. I have been following exactly the same as what you've told. Are you able to help me this please?

    Thank you very much.

    ReplyDelete
    Replies
    1. I had same issue, but resolved it.
      Please convert to TesNG and add import org.testng.annotations.Test for this class

      Delete
  25. When I Right Click on suiteonecaseone File and select Run As there's only Run Configurations option and there is no TestNG Test option. While Run with TestNG available if right click on package.TestNG is installed in my project.Please Please reply ASAP

    ReplyDelete
  26. When I Right Click on suiteonecaseone File and select Run As there's only Run Configurations option and there is no TestNG Test option. While Run with TestNG available if right click on package.TestNG is installed in my project.

    ReplyDelete
  27. For someone who get error : java.lang.NullPointerException
    Please try my case :
    1. check the method : checkCaseToRun()
    2. make sure : FilePath = TestCaseListExcelOne
    => I don't know why I copy and paste the code to my eclipse but it's change to TestCaseListExcel.
    After debug and change back to TestCaseListExcelOne, it's work now.

    ReplyDelete
  28. sir pls help me i am getting an error Error: Could not find or load main class SuiteOneCaseOne.java

    ReplyDelete
  29. Hi,
    Even I am get the same Null pointer exception. And its pointing to Read_XLS.java file on the below code line....

    ipstr = new FileInputStream(filelocation);

    Anything to change in the above line?


    Below is the exception.
    java.lang.NullPointerException
    at java.io.FileInputStream.(Unknown Source)
    at java.io.FileInputStream.(Unknown Source)
    at com.stta.utility.Read_XLS.(Read_XLS.java:25)

    ReplyDelete
  30. Hi Sir,

    Please help me in resolving these two errors:

    TestCaseListExcelOne cannot be resolved to a variable

    The method init() is undefined for the type SuiteOneCaseOne

    ReplyDelete
  31. Hello,

    I have been learning Selenium with the help of you Blog. Thank you so much for that.

    I have a doubt... You have called the Init() method without any Object.

    Is it possible to call the Base class method without any Object in the Derived class.

    Could you please Clarify??

    ReplyDelete
  32. Hi,

    the file path result shows as
    FilePath Is : com.stta.utility.Read_XLS@62f1ddd3

    this is not showing the actual path of the file. please help
    The following code is there in the SuiteBase.java

    TestCaseListExcelOne = new Read_XLS(System.getProperty("user.dir")+"\\src\\com\\stta\\ExcelFiles\\SuiteOne.xls");

    And the SuiteOneCaseOne.java shows the following
    FilePath = TestCaseListExcelOne;

    ReplyDelete
    Replies
    1. System.getProperty("user.dir") -> it will automatically take your folder directory.
      make another java file and print this. you will get your directory path.

      Delete
  33. Hello ,

    I have got same null Pint Exception Error .

    java.lang.NullPointerException
    at java.io.FileInputStream.(Unknown Source)
    at java.io.FileInputStream.(Unknown Source)
    at com.stta.utility.Read_XLS.(Read_XLS.java:24)
    at com.stta.TestSuiteBase.SuiteBase.init(SuiteBase.java:14)
    at com.stta.SuiteOne.SuiteOneCaseOne.checkCaseToRun(SuiteOneCaseOne.java:20)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
    at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:514)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:215)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142)
    at org.testng.TestRunner.beforeRun(TestRunner.java:656)
    at org.testng.TestRunner.run(TestRunner.java:624)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
    at org.testng.SuiteRunner.run(SuiteRunner.java:268)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
    at org.testng.TestNG.run(TestNG.java:1064)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:137)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:58)

    ReplyDelete
    Replies
    1. replace All HSSF with XSSF and use .xlsx files

      Delete
    2. replace HSSF to XSSF if you are using current POI, it will read yor .xlsx file and resolve all error.

      Delete
    3. Still am seeing below error in Read_XLS.Java file. Changed to XSSF and used xslx files.
      "XSSFWorkbook cannot be resolved to a type".How to fix it?

      Delete
  34. Exception in thread "main" java.lang.NoClassDefFoundError: com/stta/suiteOne/SuiteOneCaseOne (wrong name: com/stta/SuiteOne/SuiteOneCaseOne)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.testng.internal.ClassHelper.forName(ClassHelper.java:103)
    at org.testng.internal.ClassHelper.fileToClass(ClassHelper.java:518)
    at org.testng.TestNG.configure(TestNG.java:1384)
    at org.testng.TestNG.privateMain(TestNG.java:1345)
    at org.testng.TestNG.main(TestNG.java:1324)
    C:\Users\Bhagwan\AppData\Local\NetBeans\Cache\8.1\executor-snippets\junit.xml:138: The following error occurred while executing this line:
    C:\Users\Bhagwan\AppData\Local\NetBeans\Cache\8.1\executor-snippets\junit.xml:115: Java returned: 1
    BUILD FAILED (total time: 0 seconds)

    ReplyDelete
  35. [TestNG] Running:
    C:\Users\Nishad\AppData\Local\Temp\testng-eclipse-132303544\testng-customsuite.xml

    FilePath Is : com.stta.utility.Read_XLS@5e7ef926
    TestCaseName Is : SuiteOneCaseOne
    [Utils] Attempting to create E:\backup\Training\WDDF\test-output\Default suite\Default test.xml
    [Utils] Directory E:\backup\Training\WDDF\test-output\Default suite exists: true
    SKIPPED: SuiteOneCaseOneTest
    java.lang.NoClassDefFoundError: com/google/common/primitives/Ints
    at org.testng.internal.annotations.JDK15TagFactory.createDataProviderTag(JDK15TagFactory.java:335)
    at org.testng.internal.annotations.JDK15TagFactory.createTag(JDK15TagFactory.java:59)
    at org.testng.internal.annotations.JDK15AnnotationFinder.findAnnotation(JDK15AnnotationFinder.java:217)
    at org.testng.internal.annotations.JDK15AnnotationFinder.findAnnotation(JDK15AnnotationFinder.java:111)
    at org.testng.internal.Parameters.findDataProvider(Parameters.java:326)
    at org.testng.internal.Parameters.findDataProvider(Parameters.java:261)
    at org.testng.internal.Parameters.handleParameters(Parameters.java:418)
    at org.testng.internal.Invoker.handleParameters(Invoker.java:1240)
    at org.testng.internal.Invoker.createParameters(Invoker.java:980)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1070)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
    at org.testng.TestRunner.privateRun(TestRunner.java:746)
    at org.testng.TestRunner.run(TestRunner.java:600)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
    at org.testng.SuiteRunner.run(SuiteRunner.java:268)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1264)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1189)
    at org.testng.TestNG.runSuites(TestNG.java:1104)
    at org.testng.TestNG.run(TestNG.java:1076)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:152)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:57)
    Caused by: java.lang.ClassNotFoundException: com.google.common.primitives.Ints
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 27 more

    ReplyDelete
  36. Default test
    Tests run: 1, Failures: 0, Skips: 1
    ===============================================


    ===============================================
    Default suite
    Total tests run: 1, Failures: 0, Skips: 1
    ===============================================

    [TestNG] Time taken by org.testng.reporters.XMLReporter@18515783: 10 ms
    [Utils] Attempting to create E:\backup\Training\WDDF\test-output\junitreports\TEST-com.stta.SuiteOne.SuiteOneCaseOne.xml
    [Utils] Directory E:\backup\Training\WDDF\test-output\junitreports exists: true
    [TestNG] Time taken by org.testng.reporters.JUnitReportReporter@68f92ae2: 20 ms
    [TestNG] Time taken by org.testng.reporters.EmailableReporter2@349f754: 13 ms
    [TestNG] Time taken by org.testng.reporters.jq.Main@172d40de: 83 ms
    [Utils] Attempting to create E:\backup\Training\WDDF\test-output\old\Default suite\toc.html
    [Utils] Directory E:\backup\Training\WDDF\test-output\old\Default suite exists: true
    [Utils] Attempting to create E:\backup\Training\WDDF\test-output\old\Default suite\Default test.properties
    [Utils] Directory E:\backup\Training\WDDF\test-output\old\Default suite exists: true
    [Utils] Attempting to create E:\backup\Training\WDDF\test-output\old\Default suite\index.html
    [Utils] Directory E:\backup\Training\WDDF\test-output\old\Default suite exists: true
    [Utils] Attempting to create E:\backup\Training\WDDF\test-output\old\Default suite\main.html
    [Utils] Directory E:\backup\Training\WDDF\test-output\old\Default suite exists: true
    [Utils] Attempting to create E:\backup\Training\WDDF\test-output\old\Default suite\groups.html
    [Utils] Directory E:\backup\Training\WDDF\test-output\old\Default suite exists: true
    [Utils] Attempting to create E:\backup\Training\WDDF\test-output\old\Default suite\classes.html
    [Utils] Directory E:\backup\Training\WDDF\test-output\old\Default suite exists: true
    [Utils] Attempting to create E:\backup\Training\WDDF\test-output\old\Default suite\reporter-output.html
    [Utils] Directory E:\backup\Training\WDDF\test-output\old\Default suite exists: true
    [Utils] Attempting to create E:\backup\Training\WDDF\test-output\old\Default suite\methods-not-run.html
    [Utils] Directory E:\backup\Training\WDDF\test-output\old\Default suite exists: true
    [Utils] Attempting to create E:\backup\Training\WDDF\test-output\old\Default suite\testng.xml.html
    [Utils] Directory E:\backup\Training\WDDF\test-output\old\Default suite exists: true
    [Utils] Attempting to create E:\backup\Training\WDDF\test-output\old\index.html
    [Utils] Directory E:\backup\Training\WDDF\test-output\old exists: true
    [TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@761df304: 73 ms
    [Utils] Attempting to create E:\backup\Training\WDDF\test-output\testng-failed.xml
    [Utils] Directory E:\backup\Training\WDDF\test-output exists: true
    [Utils] Attempting to create E:\backup\Training\WDDF\test-output\Default suite\testng-failed.xml
    [Utils] Directory E:\backup\Training\WDDF\test-output\Default suite exists: true
    [TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 12 ms

    ReplyDelete
  37. Hi Aravind,

    Thank you for your tutorial. I have been doing it since the beginning. And only this I have encountered an error like this "Exception in thread "main" com.beust.jcommander.ParameterException: Unknown option: -protocol
    at com.beust.jcommander.JCommander.parseValues(JCommander.java:742)
    at com.beust.jcommander.JCommander.parse(JCommander.java:282)
    at com.beust.jcommander.JCommander.parse(JCommander.java:265)
    at com.beust.jcommander.JCommander.(JCommander.java:210)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:162)"

    Do you know what is this mean?

    ReplyDelete
  38. I resolve the issue by deleting all jars and adding same jars in the build path configuration.

    ReplyDelete
  39. @ All - Please add all the jars and follow each step else you will run through errors.

    Arvind - thanks for tutorial for a beginner it helps a lot.

    In Suiteonecaseone. Java file - I cant understand code below:

    TestCaseName = this.getClass().getSimpleName();

    ReplyDelete
  40. Hello,
    I just started learning and stuck at step to execute . I ma getting init() method undefined error , please help me

    ReplyDelete
  41. HI,

    I'm getting the following error can you please help.


    java.lang.RuntimeException: java.lang.RuntimeException: unsupported cell
    at org.testng.internal.MethodInvocationHelper.invokeMethodNoCheckedException(MethodInvocationHelper.java:45)
    at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:110)
    at org.testng.internal.Parameters.handleParameters(Parameters.java:436)
    at org.testng.internal.Invoker.handleParameters(Invoker.java:1253)
    at org.testng.internal.Invoker.createParameters(Invoker.java:980)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1070)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
    at org.testng.TestRunner.privateRun(TestRunner.java:753)
    at org.testng.TestRunner.run(TestRunner.java:607)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:368)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:363)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:321)
    at org.testng.SuiteRunner.run(SuiteRunner.java:270)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1284)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1209)
    at org.testng.TestNG.runSuites(TestNG.java:1124)
    at org.testng.TestNG.run(TestNG.java:1096)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)
    Caused by: java.lang.RuntimeException: unsupported cell
    at com.stta.utility.Read_XLS.cellToString(Read_XLS.java:226)
    at com.stta.utility.Read_XLS.retrieveTestData(Read_XLS.java:202)
    at com.stta.utility.SuiteUtility.getTestDataUtility(SuiteUtility.java:28)
    at com.stta.SuiteOne.SuiteOneCaseOne.SuiteOneCaseOneData(SuiteOneCaseOne.java:47)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:51)
    at org.testng.internal.MethodInvocationHelper.invokeMethodNoCheckedException(MethodInvocationHelper.java:41)
    ... 22 more

    ReplyDelete
  42. Hi,

    Thanks for your such a nice tutorial on selenium.
    I have followed all the steps given from 1 to 7 but i am getting error
    "The static field Cell.CELL_TYPE_STRING should be accessed in a static way"
    in Read_XLS.java file in the following line.
    Object data[][] = new Object[rowNum-1][colNum-2];

    for (int i=0; i<rowNum-1; i++){
    HSSFRow row = ws.getRow(i+1);
    for(int j=0; j< colNum-2; j++){
    if(row==null){
    data[i][j] = "";
    }
    else{
    HSSFCell cell = row.getCell(j);

    if(cell==null){
    data[i][j] = "";
    }
    else{
    cell.setCellType(cell.CELL_TYPE_STRING);
    String value = cellToString(cell);
    data[i][j] = value;
    }
    }
    }
    }

    return data;

    Tried a lot to resolve this error but unable to.Please help.

    ReplyDelete
  43. Can someone explain below lines:

    FilePath = TestCaseListExcelOne;

    return SuiteUtility.GetTestDataUtility(FilePath, TestCaseName);

    Are we passing the objects directly.

    ReplyDelete
  44. Please note that if using eclipse you will need to install testng through the eclipse marketplace, as well if on linux or mac change suitebase.java to use forward slashes or the path won't work

    ReplyDelete
  45. HI,

    I have below error , please help to me. how to resolve

    Error CELL_TYPE_STRING cannot be resolved or is not a field

    I have followed all the steps given from 1 to 7 but i am getting error
    "The static field Cell.CELL_TYPE_STRING should be accessed in a static way"
    in Read_XLS.java file in the following line.
    Object data[][] = new Object[rowNum-1][colNum-2];

    for (int i=0; i<rowNum-1; i++){
    HSSFRow row = ws.getRow(i+1);
    for(int j=0; j< colNum-2; j++){
    if(row==null){
    data[i][j] = "";
    }
    else{
    HSSFCell cell = row.getCell(j);

    if(cell==null){
    data[i][j] = "";
    }
    else{
    cell.setCellType(cell.CELL_TYPE_STRING);
    String value = cellToString(cell);
    data[i][j] = value;
    }
    }
    }
    }

    return data;

    Tried a lot to resolve this error but unable to.Please help.

    ReplyDelete