gpt4 book ai didi

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

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

由于某些未知原因,我的浏览器打开远程服务器的测试页面非常缓慢。所以我在想,如果我可以在退出脚本后重新连接到浏览器,但不执行 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/57075876/

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