[英]How to run Selenium in existing (manually created) browser session
Selenium
, by default, opens a new browser window when it runs. Selenium
默认情况下,在运行时会打开一个新的浏览器 window。 However, I want Selenium
to run in an existing browser session ( Google Chrome
specifically, if that helps).但是,我希望Selenium
在现有浏览器 session 中运行(特别是Google Chrome
,如果有帮助的话)。 I have found questions which address this request, but they end up giving solutions in Java
or Python
.我找到了解决这个请求的问题,但他们最终在Java
或Python
中给出了解决方案。 I would like a valid solution in Javascript
.我想要一个有效的解决方案Javascript
。
I use Node.js, and have installed selenium-webdriver
using npm
, so it may help when forming your answer.我使用 Node.js,并使用npm
selenium-webdriver
因此在形成您的答案时可能会有所帮助。
Start chrome with debug port:使用调试端口启动 chrome:
<path>\chrome.exe" --remote-debugging-port=1559
And in selenium use:在 selenium 中使用:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:1559")
driver = webdriver.Chrome(options=chrome_options)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.