Reputation: 113
I am new to the WinAppDriver Windows Based Automation. Kindly help me to launch my windows application through winappdriver.
String applicationPath = System.getProperty("user.dir")+"/Data/TestData/StudioSetup.exe";
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("app", applicationPath);
WindowsDriver driv = new WindowsDriver(new URL("http://127.0.0.1:4723"), capabilities);
It launches my application, but it takes long time to open the window. In the meanwhile, it throws the below exception in the 4th line: -
org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: Failed to locate opened application window with appId: C:\Users\Peenu\git\Uptime/Data/TestData/StudioSetup.exe, and processId: 7208 (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 7.17 seconds
Upvotes: 0
Views: 9071
Reputation: 1025
The application path is incorrect. Copy the path of your exe file using these steps:
Go to the application folder
Press the SHIFT key and right click the application icon
Select "Copy as path" from context menu
Now go back to your code and paste this value there.
Put an @ before the string
For example, the path to notepad looks like the following.
@"C:\Windows\System32\notepad.exe"
Upvotes: 0
Reputation: 186
See if this works
Process.Start(@"<WinappDriver.exe path>");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability("deviceName", "WindowsPC");
capabilities.SetCapability("app", @"<Path to application.exe>");
BasePage.WindowsDriver = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), capabilities);
Thread.Sleep(10000); //Uncomment if required
BasePage.WindowsDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
Upvotes: 0
Reputation: 794
This worked for me:
AppiumOptions appOptions = new AppiumOptions();
appOptions.AddAdditionalCapability("app", "PATH TO YOUR EXE");
appOptions.AddAdditionalCapability("deviceName", "WindowsPC");
appOptions.SetLoggingPreference(OpenQA.Selenium.LogType.Server, OpenQA.Selenium.LogLevel.All); //optional
WindowsDriver<WindowsElement> driv = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), appOptions);
Upvotes: 1