我正在尝试使用 WinAppDriver 执行 .bat 文件。一切都很好,但是创建了 2 个会话。
预期:Chrome 浏览器必须启动一次,并且只能导航到 stackoverflow 页面一次
我的java代码片段:
@BeforeClass
public static void setDesiredCapabilities() {
try {
System.out.println("Executing...");
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("app", "C:\Users\karan\Desktop\chrome.bat");
SkypeSession = new WindowsDriver(new URL("http://127.0.0.1:4723"), desiredCapabilities);
System.out.println("Is browsert?" +SkypeSession.isBrowser());
} catch (Exception ex) {
ex.printStackTrace();
}
}
我的 .bat 打开 chrome 浏览器并导航到 stackoverflow start "" http://www.stackoverflow.com
下面是由 winAppDriver 生成的错误日志
POST /session HTTP/1.1
Accept-Encoding: gzip,deflate
Connection: Keep-Alive
Content-Length: 143
Content-Type: application/json; charset=utf-8
Host: 127.0.0.1:4723
User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_131)
{"capabilities":[{"desiredCapabilities":{"app":"C:\Users\karan\Desktop\chrome.bat","platformName":"Windows"}},{"requiredCapabilities":{}}]}
HTTP/1.1 400 Bad Request
Content-Length: 141
Content-Type: application/json
{"status":100,"value":{"error":"invalid argument","message":"Bad capabilities. Specify either app or appTopLevelWindow to create a session"}}
实际:Chrome 浏览器启动一次,但 stackoverflow 在 2 个相邻选项卡中启动两次。请帮忙..谢谢!