我在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
任何想法?
最佳答案
好的,我用相同的方法解决了这个问题:
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"));
}
}
关于java - 从Selenium服务器获取所有 session ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56887057/