I am trying to launch the calculator via windows application driver with below versions
Selenium standalone : 3.141.59 Java Client : 7.2.0 Appium : 1.15.1 (Running on port 127.0.0.1:4723) Windows application driver : running like this WinAppDriver.exe 4727
Below is my code
package test;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.windows.WindowsDriver;
import io.appium.java_client.windows.WindowsElement;
public class Calculator {
public static WindowsDriver CalculatorSession;
public static WindowsElement CalculatorResult;
public static WebDriver driver;
@Test
public void LaunchApp() throws MalformedURLException, InterruptedException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "Windows");
capabilities.setCapability("deviceName", "WindowsPC");
capabilities.setCapability("app", "c://Windows//System32//calc.exe");
CalculatorSession = new WindowsDriver<WindowsElement>(new URL("http://127.0.0.1:4727"), capabilities);
System.out.println("driver value" + CalculatorSession);
CalculatorSession.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
Thread.sleep(4000);
CalculatorSession.findElementByName("One").click();
CalculatorSession.findElementByName("Plus").click();
CalculatorSession.findElementByName("Seven").click();
CalculatorSession.findElementByName("Equals").click();
}
}
When I am running the code then calculator opens for 1 time and then below error appears
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://Windows//System32//calc.exe, and processId: 2244 (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 2.30 seconds Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
I have tried using this path also : Microsoft.WindowsCalculator_10.1910.0.0_x64__8wekyb3d8bbwe but its also not working and giving below error
org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: The system cannot find the file specified (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 652 milliseconds Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
It should be "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App" instead of "c://Windows//System32//calc.exe".
You can find app id's by running powerShell command "get-StartApps"