microsoft / WinAppDriver

Windows Application Driver
MIT License
3.7k stars 1.4k forks source link

Code not working after opening WinAppDriver.exe programmatically . #1059

Open angad16 opened 4 years ago

angad16 commented 4 years ago

Hi i have automated a Windows application suing WinAppDriver and it is working absolutely fine. Now i am trying to open WinAppDriver.exe from my java code by using ProcessBuilder class here is the code : ProcessBuilder p = new ProcessBuilder(); p.command("C:\Users\Administrator\WinAppDriver\WinAppDriverTool\WinAppDriver.exe"); Process process = p.start();

it is also working good and launches the winappdriver.exe, and i am also able to open the application but after that it is no working, neither it is failing nor working.

vineetgulati commented 4 years ago

Hi, I am using the exactly same code but I am getting this below error. What I am missing here? Any idea I am running in inteliij

java.lang.NoClassDefFoundError: org/openqa/selenium/remote/internal/JsonToWebElementConverter

at demoTest.setup(demoTest.java:32)
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:567)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:134)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:597)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:173)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:816)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:146)
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:1507)
at org.testng.TestRunner.privateRun(TestRunner.java:766)
at org.testng.TestRunner.run(TestRunner.java:587)
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 com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:110)

Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.remote.internal.JsonToWebElementConverter at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ... 28 more

angad16 commented 4 years ago

Hi @vineetgulati please can you please share your code?

anshul1goel commented 4 years ago

Is the WinAppDriver process launching with administrator privileges?

MoatazFarid commented 3 years ago

@angad16 Can you explain how it is not working?! also, You can try this way

            String command = "C:\\Program Files (x86)\\Windows Application Driver\\WinAppDriver.exe";
            ProcessBuilder builder = new ProcessBuilder(command).inheritIO();
            try {
                builder.start();
            } catch (IOException e) {
                e.printStackTrace();
            }

I have just noticed that this is a very OLD question, I wonder how your problem was solved?