我正在尝试使用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 开始“” 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。 请帮忙..谢谢!
答案 0 :(得分:0)
尝试使用Selenium ChromeDriver而不是WinAppDriver和批处理文件启动Chrome。请在此处共享您的.bat文件的内容。