Как запустить мое приложение через winappdriver? - PullRequest
0 голосов
/ 01 июня 2019

Я новичок в WinAppDriver Windows Based Automation. Пожалуйста, помогите мне запустить мое приложение Windows через 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);

Он запускает мое приложение, но для открытия окна требуется много времени. В то же время в 4-й строке выдается следующее исключение: -

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

Ответы [ 2 ]

0 голосов
/ 13 июня 2019

Посмотрите, работает ли это

    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);
0 голосов
/ 03 июня 2019

Это сработало для меня:

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);
...