[英]How to run Selenium in existing (manually created) browser session
Selenium
默认情况下,在运行时会打开一个新的浏览器 window。 但是,我希望Selenium
在现有浏览器 session 中运行(特别是Google Chrome
,如果有帮助的话)。 我找到了解决这个请求的问题,但他们最终在Java
或Python
中给出了解决方案。 我想要一个有效的解决方案Javascript
。
我使用 Node.js,并使用npm
selenium-webdriver
因此在形成您的答案时可能会有所帮助。
使用调试端口启动 chrome:
<path>\chrome.exe" --remote-debugging-port=1559
在 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.