Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 运行ChromeDriver的多个实例_Python_Selenium_Selenium Chromedriver - Fatal编程技术网

Python 运行ChromeDriver的多个实例

Python 运行ChromeDriver的多个实例,python,selenium,selenium-chromedriver,Python,Selenium,Selenium Chromedriver,使用selenium和python,我有几个测试需要并行运行。为了避免使用相同的浏览器,我添加了使用特定配置文件目录和用户数据的参数(见下文)。问题是我不能同时运行它们,一个测试需要等待另一个测试完成。否则,我将从chromedriver获得以下错误: Starting ChromeDriver 2.29.461591 (62ebf098771772160f391d75e589dc567915b233) on port 9515 Only local connections are allowe

使用selenium和python,我有几个测试需要并行运行。为了避免使用相同的浏览器,我添加了使用特定配置文件目录和用户数据的参数(见下文)。问题是我不能同时运行它们,一个测试需要等待另一个测试完成。否则,我将从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设置:

  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)
试试这个

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

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

--profile目录
用于同一浏览器中的多个配置文件

您是否尝试了ThreadPoolExecutor?