我在Java中使用远程驱动程序(chrome)。对于版本2.53,我通过以下方式获取会话:
httpCommandExecutor.execute (new Command (sessionId, "getAllSessions"));
对于新版本(3.141),似乎不起作用。我得到了:
org.openqa.selenium.WebDriverException: No command or response codec has been defined. Unable to proceed
有什么主意吗?
答案 0 :(得分:0)
好的,我用相同的方法解决了这个问题:
httpCommandExecutor.execute (new Command (sessionId, "getAllSessions"));
但是不同的是,在创建新会话之后,我正在运行此代码。因此,我正在检查会话ID,以免杀死新创建的会话:
Response response = httpCommandExecutor.execute (new Command (newSessionId, "getAllSessions"));
// Don't kill the new session
for (HashMap<String, Object> sessionParams : (ArrayList<HashMap<String, Object>>) response.getValue ()) {
SessionId sessionId = new SessionId ((String) sessionParams.get("id"))
if (!newSessionId.equals(sessionId)){
httpCommandExecutor.execute (new Command (sessionId, "quit"));
}
}