[英]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.