I am testing Excel file using winium and TestNg. When I am manually starting winium driver that time the test cases are working properly. When I am trying to start Winium service from java that time it is giving me problem to start the Winium Driver. Code is as belows :
package testcases;
import java.io.*;
import java.nio.file.Paths;
import java.text.*;
import java.util.*;
import org.openqa.selenium.winium.WiniumDriverService;
import org.testng.*;
import org.testng.collections.Lists;
import HelperClass.ExcelFiles;
public class WiniumRunner {
private static final DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
public static void main(String[] args) throws InterruptedException, IOException {
File file = new File(Paths.get(".").toAbsolutePath().normalize().toString());
String winiumDriverPath = file + "\\Winium.Desktop.Driver\\Winium.Desktop.Driver.exe";
System.out.println("Starting service of Winium Desktop Driver");
WiniumDriverService service = new WiniumDriverService.Builder().usingDriverExecutable(new
File(winiumDriverPath)).usingPort(9999).withVerbose(true).withSilent(false).buildDesktopService();
service.start(); // Build and Start a Winium Driver service
Thread.sleep(5000);
System.out.println("Started service of Winium Desktop Driver");
String cDateTime = "";
Date date = new Date();
cDateTime = cDateTime + (sdf.format(date));
cDateTime = file+"\\Reports\\Mockito_Test_Reports\\";
ExcelFiles EF= new ExcelFiles();
EF.createExcelFile();
TestListenerAdapter tla = new TestListenerAdapter();
TestNG testng = new TestNG();
testng.setOutputDirectory(cDateTime);
List<String> suites = Lists.newArrayList();
System.out.println("**********Test Report Location :"+file+"\\src\\props\\testng2.xml");
suites.add(file+"\\src\\test\\java\\testcases\\testng2.xml");
testng.setTestSuites(suites);
testng.addListener(tla);
testng.run();
Process process = Runtime.getRuntime().exec("taskkill /F /IM Winium.Desktop.Driver.exe");
process.waitFor();
process.destroy();
}
}
I am getting below Exception :
Starting service of Winium Desktop Driver
Starting Windows Desktop Driver on port 9999
16:53:39 [DEBUG] Waiting for a connection...
16:53:40 [DEBUG] ACCEPTED REQUEST GET /status HTTP/1.1
16:53:40 [INFO] COMMAND status
{}
16:53:40 [DEBUG] RESPONSE:
OK: {
"sessionId": "AwesomeSession",
"status": 0,
"value": {
"build": {
"version": "1.2.0.0"
},
"os": {
"arch": "x64",
"name": "windows",
"version": "Microsoft Windows NT 6.2.9200.0"
}
}
}
16:53:40 [DEBUG] Client closed
16:53:40 [DEBUG] Waiting for a connection...
Started service of Winium Desktop Driver
log4j:WARN No appenders could be found for logger
(org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
16:53:47 [DEBUG] ACCEPTED REQUEST POST /session HTTP/1.1
16:53:47 [INFO] COMMAND newSession
16:53:47 [INFO] COMMAND newSession
{
"desiredCapabilities": {
"app": null
}
}
16:53:47 [DEBUG] RESPONSE:
OK: {
"sessionId": "AwesomeSession",
"status": 13,
"value": {
"error": "unknown error",
"stacktrace": " at Winium.Cruciatus.Application..ctor(String
executableFilePath)\r\n at Winium.Desktop.Driver.CommandExecutors.NewSessionExecutor.InitializeApplication(Boolean debugDoNotDeploy)\r\n at Winium.Desktop.Driver.CommandExecutors.NewSessionExecutor.DoImpl()\r\n at Winium.Desktop.Driver.CommandExecutors.CommandExecutorBase.Do()",
"message": "Value cannot be null.\r\nParameter name: executableFilePath"
}
}
16:53:47 [DEBUG] Client closed
16:53:47 [DEBUG] Waiting for a connection...
org.openqa.selenium.WebDriverException: Value cannot be null.
Parameter name: executableFilePath (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 208 milliseconds
Build info: version: '2.48.2', revision: '41bccdd10cf2c0560f637404c2d96164b67d9d67', time: '2015-10-09 13:08:06'
System info: host: 'DESKTOP-5A26C5Q', ip: '192.168.225.198', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.winium.WiniumDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:247)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
at org.openqa.selenium.winium.WiniumDriver.<init>(WiniumDriver.java:84)
at testcases.UserRegistrationForm.intiallizeTest(UserRegistrationForm.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:134)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:63)
at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:348)
at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:302)
at org.testng.TestRunner.invokeTestConfigurations(TestRunner.java:619)
at org.testng.TestRunner.beforeRun(TestRunner.java:609)
at org.testng.TestRunner.run(TestRunner.java:580)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:384)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337)
at org.testng.SuiteRunner.run(SuiteRunner.java:286)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1187)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1109)
at org.testng.TestNG.runSuites(TestNG.java:1039)
at org.testng.TestNG.run(TestNG.java:1007)
at testcases.WiniumRunner.main(WiniumRunner.java:50)
I am not able to debug the Error. If someone can suggest Changes in code.
Thanks in Advance.
The reason you see the exception
is because
executableFilePathis null in the Application constructor. As a resultDesiredCapabilitiesis not set:According to the README you should set
DesktopOptionsbefore creating the instance of theWebDriverclass: