gpt4 book ai didi

java - 从selenium服务器获取所有 session

转载 作者:行者123 更新时间:2023-12-02 03:30:46 24 4
gpt4 key购买 nike

我正在使用带有 java 的远程驱动程序(chrome)。对于 2.53 版本,我通过以下方式获取 session :

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"));

但不同的是我在创建新 session 后运行它。所以我检查 session ID,以免终止新创建的 session :

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com