我是WinAppDriver Windows Based Automation的新手。请帮助我通过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);
它启动了我的应用程序,但是打开该窗口需要很长时间。同时,它在第四行中引发以下异常:-
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
答案 0 :(得分:0)
这对我有用:
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);
答案 1 :(得分: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);
答案 2 :(得分:0)
应用程序路径不正确。使用以下步骤复制exe文件的路径:
转到应用程序文件夹
按SHIFT键,然后右键单击应用程序图标
从上下文菜单中选择“复制为路径”
现在返回您的代码并将此值粘贴到此处。
在字符串前加一个@
例如,记事本的路径如下所示。
@“ C:\ Windows \ System32 \ notepad.exe”