Skip to content
Advertisement

Run Multiple Instances of ChromeDriver

Using selenium and python I have several tests that need to run in parallel. To avoid using the same browser I added the parameter of using a specific profile directory and user data (see below). The problem is that I cannot run them simultaneously, one test needs to wait for the other to finish. Otherwise I get the following error from chromedriver:

Starting ChromeDriver 2.29.461591 (62ebf098771772160f391d75e589dc567915b233) on port 9515
Only local connections are allowed.
[0.000][SEVERE]: bind() returned an error: Only one usage of each socket address (protocol/network address/port) is normally permitted. (0x2740)

Selenium setup:

  chrome_options = webdriver.ChromeOptions()
  chrome_options.add_argument('--user-data-dir=C:/ChromeProfile')
  chrome_options.add_argument("--profile-directory=Profile1")#Profile2,Profile3, etc
  chrome_options.add_argument('--start-maximized')
  chrome_options.add_argument('--incognito')
  self.driver = webdriver.Chrome(executable_path='C:/Chrome/chromedriver.exe',chrome_options=chrome_options)

Advertisement

Answer

Try this

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--user-data-dir=C:/ChromeProfile/Profile1')#Profile2,Profile3, etc.

Do not use

chrome_options.add_argument("--profile-directory=Profile1")

The --profile-directory is for multiple profiles in same browser

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement