如何在多个远程调试端口上打开多个google-chrome?

发布于 2025-01-17 16:34:54 字数 1280 浏览 0 评论 0原文

打开 chrome 将 selenium 连接到现有的 chrome 会话

我通过使用"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir="C:\ selenum\ChromeProfile"

chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
chrome_options.add_argument('--headless')
chrome_options.add_argument('--remote-debugging-port=9222') # Recommended is 9222
chrome_driver =  "Data/chromedriver.exe"
driver = webdriver.Chrome(chrome_driver, chrome_options=chrome_options)

我正在做一个项目,我必须在 chrome 的不同端口上打开多个 chrome 窗口。因此,我希望在端口 9222 和端口 9223 上打开另一个实例,

但是当我执行

“C:\Program Files\Google\Chrome\Application\chrome.exe”时 --remote-debugging-port=9223 --user-data- dir="C:\selenum\ChromeProfile"

chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:9223")
chrome_options.add_argument('--headless')
chrome_options.add_argument('--remote-debugging-port=9223') # Recommended is 9222
chrome_driver =  "Data/chromedriver.exe"
driver = webdriver.Chrome(chrome_driver, chrome_options=chrome_options)

它响应为

Opening in existing browser session. 

这意味着它不是在不同端口上而是在同一端口上打开该会话。我想控制谷歌浏览器的第二个实例,而不是第一个已经打开的实例。

如何避免这种情况并在不同端口上打开多个 google chrome 实例?

I connect selenium to an existing chrome session by opening chrome with

"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir="C:\selenum\ChromeProfile"

chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
chrome_options.add_argument('--headless')
chrome_options.add_argument('--remote-debugging-port=9222') # Recommended is 9222
chrome_driver =  "Data/chromedriver.exe"
driver = webdriver.Chrome(chrome_driver, chrome_options=chrome_options)

I am doing a project where I would have to open multiple windows of chrome on different ports for chrome. So I am looking to open another instance on port 9222 and port 9223

but when I do

"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9223 --user-data-dir="C:\selenum\ChromeProfile"

chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:9223")
chrome_options.add_argument('--headless')
chrome_options.add_argument('--remote-debugging-port=9223') # Recommended is 9222
chrome_driver =  "Data/chromedriver.exe"
driver = webdriver.Chrome(chrome_driver, chrome_options=chrome_options)

It responds with

Opening in existing browser session. 

Which means it's not opening that session on a different port but on the same one. I want to control the second instance of google chrome, not the first already opened.

How can I avoid this and open multiple google chrome instances on different ports?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

只涨不跌 2025-01-24 16:34:54

使用最新版本的Chrome,我正在使用(104.0.5112.102)

创建一些空文件夹,例如C:\ Selenum \ 9222 C:\ Selenum \ 9223(Windows System)

上次设置快捷方式路径,如下面的

快捷方式,您会看到结果

“ C:\ Program Files \ Google \ Chrome \ Chrome \ Application \ Chrome.exe” - remote-debugging-port = 9123 -user-data-data-dir = c:\ selenum \ 9222

” c:\ program files \ google \ google \ chrome \ application \ chrome.exe“ - remote-debugging-port = 9123 -user-data-dir = c:\ selenum \ 9223

Use the latest version of Chrome, I'm using(104.0.5112.102)

create some empty folders like C:\selenum\9222 C:\selenum\9223 (Windows system)

last set shortcuts path like below

run shortcuts,and you will see the result

"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9123 --user-data-dir=C:\selenum\9222

"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9123 --user-data-dir=C:\selenum\9223

戏舞 2025-01-24 16:34:54
  1. 使用Chrome Portable(S)或Chrome+Chrome Portable

  2. different users on the same windows same computer

  3. different computers.

  4. 边缘和铬

Haven't found any way to do this with two instances of chrome.

  1. use Chrome portable (s) or chrome+chrome portable

  2. different users on the same windows same computer

  3. different computers.

  4. Edge and Chrome

Haven't found any way to do this with two instances of chrome.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文