我如何重新连接使用硒的webdriver打开的浏览器? [英] How can I reconnect to the browser opened by webdriver with selenium?

查看:130
本文介绍了我如何重新连接使用硒的webdriver打开的浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些未知原因,我的浏览器非常缓慢地打开了远程服务器的测试页.因此,我在考虑是否可以在退出脚本后重新连接到浏览器,但不执行webdriver.quit(),这将使浏览器保持打开状态.这可能是HOOK或Webdriver句柄. 我查找了硒API文档,但未找到任何功能. 我正在使用Chrome 62,x64,Windows 7,硒3.8.0. 这个问题能否解决,我将不胜感激.

For some unknown reasons ,my browser open test pages of my remote server very slowly. So I am thinking if I can reconnect to the browser after quitting the script but don't execute webdriver.quit() this will leave the browser opened. It is probably kind of HOOK or webdriver handle. I have looked up the selenium API doc but didn't find any function. I'm using Chrome 62,x64,windows 7,selenium 3.8.0. I'll be very appreciated whether the question can be solved or not.

推荐答案

,退出脚本后,您将无法重新连接到先前的 Web浏览会话.即使您能够从以前的浏览上下文中提取Session IDCookies和其他会话属性,您仍将无法通过 HOOK传递这些属性 WebDriver .

No, you can't reconnect to the previous Web Browsing Session after you quit the script. Even if you are able to extract the Session ID, Cookies and other session attributes from the previous Browsing Context still you won't be able to pass those attributes as a HOOK to the WebDriver.

一种更干净的方法是调用webdriver.quit(),然后跨越一个新的浏览上下文.

A cleaner way would be to call webdriver.quit() and then span a new Browsing Context.

围绕如何将 WebDriver 重新连接到现有的正在运行的浏览上下文进行了很多讨论和尝试.在讨论中允许网络驱动程序附加到正在运行的浏览器上 Simon Stewart [Creator WebDriver]明确提到:

There had been a lot of discussions and attempts around to reconnect WebDriver to an existing running Browsing Context. In the discussion Allow webdriver to attach to a running browser Simon Stewart [Creator WebDriver] clearly mentioned:

  • 重新连接到现有的浏览上下文是特定于浏览器的功能,因此无法以通用方式实现.
  • 使用 ,可以遍历操作系统中打开的窗口并找到要附加的正确IE进程.

webdriver.firefox.use现有的未实现


tl; dr

webdriver.firefox.useExisting not implemented

这篇关于我如何重新连接使用硒的webdriver打开的浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆