python-3.x - 如何使用selenium重新连接到webdriver打开的浏览器?

标签 python-3.x selenium session selenium-webdriver webdriver

由于某些未知原因,我的浏览器打开远程服务器的测试页面非常缓慢。所以我在想,如果我可以在退出脚本后重新连接到浏览器,但不执行 webdriver.quit() 这将使浏览器保持打开状态。它可能是一种 HOOK 或网络驱动程序句柄。 我查了selenium API 文档但没有找到任何函数。 我正在使用 Chrome 62、x64、windows 7、selenium 3.8.0。 无论问题能否解决,我将不胜感激。

最佳答案

,退出脚本后您无法重新连接到之前的网络浏览 session 。即使您能够从之前的浏览上下文中提取Session IDCookies和其他 session 属性,您仍然无法将这些属性作为 HOOK 传递给 WebDriver .

更简洁的方法是调用 webdriver.quit(),然后跨越新的浏览上下文

<小时/>

深入探讨

围绕将WebDriver重新连接到现有正在运行的浏览上下文进行了很多讨论和尝试。讨论中Allow webdriver to attach to a running browser Simon Stewart [Creator WebDriver] 明确提到:

  • Reconnecting to an existing Browsing Context is a browser specific feature, hence can't be implemented in a generic way.
  • With , it's possible to iterate over the open windows in the OS and find the right IE process to attach to.
  • and needs to be started in a specific mode and configuration, which effectively means that just attaching to a running instance isn't technically possible.
<小时/>

tl;博士

webdriver.firefox.useExisting not implemented

关于python-3.x - 如何使用selenium重新连接到webdriver打开的浏览器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54420718/

相关文章:

python - 获取比较多个列的最大值并返回特定值

java - org.openqa.selenium.SessionNotCreatedException : Unable to find a matching set of capabilities

python - 缺少 1 个必需的位置参数

session - 如果不打开引用页面或父页面,则超链接 url 不会打开

php - 我的 php session 文件夹中不需要的 session 文件

python - 获取一对括号内的文本,但不获取双方括号内的文本

python - 尝试在 pythonanywhere 上使用 praw 提交图像时出现 WebSocketProxyException 403

python - numpy.rint 可以返回一个 Int32 吗?

java - HP ALM 12 REST 不返回 QCSession cookie

java - 如何在 Jenkins 上自动重新运行失败的 TestNG 测试