DataDriven Framework does not work when we just execute .xml file | Selenium Forum
S
Steve Posted on 21/04/2021

/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/bin/java -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar=58480:/Applications/IntelliJ IDEA CE.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar:/Applications/IntelliJ IDEA CE.app/Contents/plugins/testng/lib/testng-plugin.jar:/Users/sgomes/Documents/Selenium_Code/selenium code/Testng Datadriven Framework/DataDrivenFramework/target/test-classes:/Users/sgomes/Documents/Selenium_Code/selenium code/Testng Datadriven Framework/DataDrivenFramework/target/classes:/Users/sgomes/.m2/repository/org/seleniumhq/selenium/selenium-java/3.141.59/selenium-java-3.141.59.jar:/Users/sgomes/.m2/repository/org/seleniumhq/selenium/selenium-api/3.141.59/selenium-api-3.141.59.jar:/Users/sgomes/.m2/repository/org/seleniumhq/selenium/selenium-chrome-driver/3.141.59/selenium-chrome-driver-3.141.59.jar:/Users/sgomes/.m2/repository/org/seleniumhq/selenium/selenium-edge-driver/3.141.59/selenium-edge-driver-3.141.59.jar:/Users/sgomes/.m2/repository/org/seleniumhq/selenium/selenium-ie-driver/3.141.59/selenium-ie-driver-3.141.59.jar:/Users/sgomes/.m2/repository/org/seleniumhq/selenium/selenium-opera-driver/3.141.59/selenium-opera-driver-3.141.59.jar:/Users/sgomes/.m2/repository/org/seleniumhq/selenium/selenium-remote-driver/3.141.59/selenium-remote-driver-3.141.59.jar:/Users/sgomes/.m2/repository/org/seleniumhq/selenium/selenium-safari-driver/3.141.59/selenium-safari-driver-3.141.59.jar:/Users/sgomes/.m2/repository/org/seleniumhq/selenium/selenium-support/3.141.59/selenium-support-3.141.59.jar:/Users/sgomes/.m2/repository/net/bytebuddy/byte-buddy/1.8.15/byte-buddy-1.8.15.jar:/Users/sgomes/.m2/repository/org/apache/commons/commons-exec/1.3/commons-exec-1.3.jar:/Users/sgomes/.m2/repository/com/google/guava/guava/25.0-jre/guava-25.0-jre.jar:/Users/sgomes/.m2/repository/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar:/Users/sgomes/.m2/repository/org/checkerframework/checker-compat-qual/2.0.0/checker-compat-qual-2.0.0.jar:/Users/sgomes/.m2/repository/com/google/errorprone/error_prone_annotations/2.1.3/error_prone_annotations-2.1.3.jar:/Users/sgomes/.m2/repository/com/google/j2objc/j2objc-annotations/1.1/j2objc-annotations-1.1.jar:/Users/sgomes/.m2/repository/org/codehaus/mojo/animal-sniffer-annotations/1.14/animal-sniffer-annotations-1.14.jar:/Users/sgomes/.m2/repository/com/squareup/okhttp3/okhttp/3.11.0/okhttp-3.11.0.jar:/Users/sgomes/.m2/repository/com/squareup/okio/okio/1.14.0/okio-1.14.0.jar:/Users/sgomes/.m2/repository/org/seleniumhq/selenium/selenium-firefox-driver/3.141.59/selenium-firefox-driver-3.141.59.jar:/Users/sgomes/.m2/repository/com/aventstack/extentreports/4.1.5/extentreports-4.1.5.jar:/Users/sgomes/.m2/repository/org/freemarker/freemarker/2.3.29/freemarker-2.3.29.jar:/Users/sgomes/.m2/repository/org/apache/httpcomponents/httpclient/4.5.2/httpclient-4.5.2.jar:/Users/sgomes/.m2/repository/org/apache/httpcomponents/httpcore/4.4.4/httpcore-4.4.4.jar:/Users/sgomes/.m2/repository/commons-codec/commons-codec/1.9/commons-codec-1.9.jar:/Users/sgomes/.m2/repository/org/apache/httpcomponents/httpmime/4.5.2/httpmime-4.5.2.jar:/Users/sgomes/.m2/repository/com/google/code/gson/gson/2.8.6/gson-2.8.6.jar:/Users/sgomes/.m2/repository/org/mongodb/mongodb-driver/3.12.0/mongodb-driver-3.12.0.jar:/Users/sgomes/.m2/repository/org/mongodb/mongodb-driver-core/3.12.0/mongodb-driver-core-3.12.0.jar:/Users/sgomes/.m2/repository/org/mongodb/bson/3.12.0/bson-3.12.0.jar:/Users/sgomes/.m2/repository/commons-io/commons-io/2.8.0/commons-io-2.8.0.jar:/Users/sgomes/.m2/repository/com/googlecode/json-simple/json-simple/1.1/json-simple-1.1.jar:/Users/sgomes/.m2/repository/org/apache/poi/poi/3.6/poi-3.6.jar:/Users/sgomes/.m2/repository/commons-logging/commons-logging/1.1/commons-logging-1.1.jar:/Users/sgomes/.m2/repository/logkit/logkit/1.0.1/logkit-1.0.1.jar:/Users/sgomes/.m2/repository/avalon-framework/avalon-framework/4.1.3/avalon-framework-4.1.3.jar:/Users/sgomes/.m2/repository/javax/servlet/servlet-api/2.3/servlet-api-2.3.jar:/Users/sgomes/.m2/repository/log4j/log4j/1.2.13/log4j-1.2.13.jar:/Users/sgomes/.m2/repository/org/apache/poi/poi-ooxml/3.6/poi-ooxml-3.6.jar:/Users/sgomes/.m2/repository/org/apache/poi/poi-ooxml-schemas/3.6/poi-ooxml-schemas-3.6.jar:/Users/sgomes/.m2/repository/org/apache/geronimo/specs/geronimo-stax-api_1.0_spec/1.0/geronimo-stax-api_1.0_spec-1.0.jar:/Users/sgomes/.m2/repository/dom4j/dom4j/1.1/dom4j-1.1.jar:/Users/sgomes/.m2/repository/org/apache/xmlbeans/xmlbeans/2.3.0/xmlbeans-2.3.0.jar:/Users/sgomes/.m2/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar:/Users/sgomes/.m2/repository/io/github/bonigarcia/webdrivermanager/4.1.0/webdrivermanager-4.1.0.jar:/Users/sgomes/.m2/repository/org/slf4j/slf4j-api/1.7.30/slf4j-api-1.7.30.jar:/Users/sgomes/.m2/repository/org/apache/commons/commons-lang3/3.10/commons-lang3-3.10.jar:/Users/sgomes/.m2/repository/org/apache/httpcomponents/client5/httpclient5/5.0.1/httpclient5-5.0.1.jar:/Users/sgomes/.m2/repository/org/apache/httpcomponents/core5/httpcore5/5.0.1/httpcore5-5.0.1.jar:/Users/sgomes/.m2/repository/org/apache/httpcomponents/core5/httpcore5-h2/5.0.1/httpcore5-h2-5.0.1.jar:/Users/sgomes/.m2/repository/org/rauschig/jarchivelib/1.0.0/jarchivelib-1.0.0.jar:/Users/sgomes/.m2/repository/org/apache/commons/commons-compress/1.18/commons-compress-1.18.jar:/Users/sgomes/.m2/repository/org/jsoup/jsoup/1.13.1/jsoup-1.13.1.jar:/Users/sgomes/.m2/repository/org/testng/testng/7.0.0/testng-7.0.0.jar:/Users/sgomes/.m2/repository/com/beust/jcommander/1.72/jcommander-1.72.jar:/Applications/IntelliJ IDEA CE.app/Contents/plugins/testng/lib/jcommander-1.27.jar" org.testng.RemoteTestNGStarter -usedefaultlisteners false -socket58479 @w@/private/var/folders/c7/qrdy_4ls049g54rwht_5whg80000gn/T/idea_working_dirs_testng.tmp -temp /private/var/folders/c7/qrdy_4ls049g54rwht_5whg80000gn/T/idea_testng.tmp
----------Before Test---------
null
null
null
null

java.lang.NumberFormatException: null

at java.base/java.lang.Integer.parseInt(Integer.java:614)
at java.base/java.lang.Integer.parseInt(Integer.java:770)
at testbase.BaseTest.beforeTest(BaseTest.java:48)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:62)
at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:340)
at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:294)
at org.testng.TestRunner.invokeTestConfigurations(TestRunner.java:623)
at org.testng.TestRunner.beforeRun(TestRunner.java:613)
at org.testng.TestRunner.run(TestRunner.java:584)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:402)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355)
at org.testng.SuiteRunner.run(SuiteRunner.java:304)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1102)
at org.testng.TestNG.runSuites(TestNG.java:1032)
at org.testng.TestNG.run(TestNG.java:1000)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:73)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)

****Before Method****
***************************Test Skipped createPortFolioTest
***************************Test FailedcreatePortFolioTest
null
java.lang.NullPointerException
at listener.MyTestNGListener.onTestFailure(MyTestNGListener.java:15)
at org.testng.internal.TestListenerHelper.runTestListeners(TestListenerHelper.java:66)
at org.testng.internal.TestInvoker.runTestResultListener(TestInvoker.java:210)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:814)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:145)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
at org.testng.TestRunner.privateRun(TestRunner.java:770)
at org.testng.TestRunner.run(TestRunner.java:591)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:402)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355)
at org.testng.SuiteRunner.run(SuiteRunner.java:304)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1102)
at org.testng.TestNG.runSuites(TestNG.java:1032)
at org.testng.TestNG.run(TestNG.java:1000)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:73)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)

Process finished with exit code 255


S
Steve Replied on 21/04/2021

Json Runner works fine, but Runner (TestNG Runner) does not work


A
Ashish Replied on 21/04/2021

java.lang.NumberFormatException: null

at java.base/java.lang.Integer.parseInt(Integer.java:614)
at java.base/java.lang.Integer.parseInt(Integer.java:770)
at testbase.BaseTest.beforeTest(BaseTest.java:48)

 

Your conversion from Int to String in lin 48 BaseTest is not good


S
Steve Replied on 21/04/2021


@BeforeTest(alwaysRun = true)
public void beforeTest(ITestContext context) throws NumberFormatException, FileNotFoundException, IOException, ParseException {
System.out.println("----------Before Test---------");
String datafilpath = context.getCurrentXmlTest().getParameter("datafilpath");
String dataFlag = context.getCurrentXmlTest().getParameter("dataflag");
String iteration = context.getCurrentXmlTest().getParameter("iteration");
String sheetName = context.getCurrentXmlTest().getParameter("suitename");
// suitename(sheetname)
System.out.println(datafilpath);
System.out.println(dataFlag);
System.out.println(iteration);
System.out.println(sheetName);
// reading data from JSON
JSONObject data = new DataUtil().getTestData(datafilpath, dataFlag, Integer.parseInt(iteration));
//JSONObject data = new ReadingXLS().getTestData(sheetName, dataFlag, (Integer.parseInt(iteration)+1), datafilpath);
//JSONObject data = from xls
context.setAttribute("data", data);
String runmode = (String)data.get("runmode");

// what is the path to data json / xls
// what is the data flag
// what is the iteration number
// read the data and keep it in a map


// init the reporting for the test
rep = ExtentManager.getReports();
test =rep.createTest(context.getCurrentXmlTest().getName());
test.log(Status.INFO, "Starting Test "+context.getCurrentXmlTest().getName());
test.log(Status.INFO, "Data "+data.toString());

context.setAttribute("report", rep);
context.setAttribute("test", test);
if(!runmode.equals("Y")) {
test.log(Status.SKIP, "Skpping as Data Runmode is N");
throw new SkipException("Skpping as Data Runmode is N");
}

// init and share it with all tests
app = new ApplicationKeywords(); // 1 app keyword object for entire test -All @Test
app.setReport(test);
app.openBrowser("Chrome");
app.defaultLogin();
context.setAttribute("app", app);

}



FYI I have not made any changes in the code, just executed the given code,

still facing the same problem



S
Steve Replied on 24/04/2021

could anyone help with the same ?


A
Ashish Replied on 30/04/2021

Yes

Because you need to run it with JSON which we made in videos


Related Posts