Run Multiple Instances of ChromeDriver

我是研究僧i 提交于 2019-12-07 04:51:35

问题


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)

回答1:


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



来源:https://stackoverflow.com/questions/45788651/run-multiple-instances-of-chromedriver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!