0

我是 WinAppDriver 基于 Windows 的自动化的新手。请帮助我通过 winappdriver 启动我的 Windows 应用程序。

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
4

3 回答 3

1

这对我有用:

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);
于 2019-06-03T11:15:03.670 回答
0

应用程序路径不正确。使用以下步骤复制 exe 文件的路径:

转到应用程序文件夹

按 SHIFT 键并右键单击应用程序图标

从上下文菜单中选择“复制为路径”

现在回到您的代码并将这个值粘贴到那里。

在字符串前加一个@

例如,记事本的路径如下所示。

@"C:\Windows\System32\notepad.exe"

于 2019-08-30T14:25:57.677 回答
0

看看这是否有效

    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);
于 2019-06-13T12:21:11.090 回答