diegooli
diegooli

Reputation: 153

How to open multiple google-chrome on multiple remote debugging ports?

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?

Upvotes: 2

Views: 2349

Answers (2)

Junson
Junson

Reputation: 41

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

Upvotes: 4

Yaman Jain
Yaman Jain

Reputation: 31

  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.

Upvotes: 1

Related Questions