Run Multiple Instances of ChromeDriver

2024/10/10 0:28:58

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, etcchrome_options.add_argument('--start-maximized')chrome_options.add_argument('--incognito')self.driver = webdriver.Chrome(executable_path='C:/Chrome/chromedriver.exe',chrome_options=chrome_options)
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

https://en.xdnf.cn/q/69954.html

Related Q&A

numpy 2d array max/argmax

I have a numpy matrix:>>> A = np.matrix(1 2 3; 5 1 6; 9 4 2) >>> A matrix([[1, 2, 3],[5, 1, 6],[9, 4, 2]])Id like to get the index of the maximum value in each row along with the valu…

How do I add a python script to the startup registry?

Im trying to make my python script run upon startup but I get the error message windowserror access denied, but I should be able to make programs start upon boot because teamviewer ( a third-party prog…

Python: How can I filter a n-nested dict of dicts by leaf value?

Ive got a dict that looks something like this:d = {Food: {Fruit : {Apples : {Golden Del. : [Yellow],Granny Smith : [Green],Fuji : [Red], },Cherries : [Red],Bananas : [Yellow],Grapes …

contour plot - clabel spacing

I have trouble with matplotlib / pyplot / basemap. I plot contour lines (air pressure) on a map. I use clabel to show the value of the contour lines. But the problem is: the padding between the value a…

Class-based view has no attribute .as_view() error

Im following this tutorial, trying to make an API for my Products table.Heres my .views/API/apitest.py view:from my_app.views.API.serializers import ProductSerializer from my_app.models import Product …

Ordering query result by numeric strings in django (postgres backend)

I have a table with a name (varchar) field that only holds numeric string and I want to order my queries by this field. But name fields are being ordered by alphabetically but I want them to be ordered…

Resolve argparse alias back to the original command

Im using a subparser/subcommand that has an alias. Im using the dest option for the subparser to store the name of the subcommand so I can get it later.Currently if the subcommands name is reallyLongN…

Django: How do I make fields non-editable by default in an inline model formset?

I have an inline model formset, and Id like to make fields non-editable if those fields already have values when the page is loaded. If the user clicks an "Edit" button on that row, it would…

How to store result of an operation (like TOPK) per epoch in keras

I have written a custom layer in keras. in part of this custom layer lets say I have a matrix like this: c = tf.cast(tf.nn.top_k(tf.nn.top_k(n, tf.shape(n)[1])[1][:, ::-1], tf.shape(n)[1])[1][:, ::-1],…

How to start Firefox with with specific profile Selenium Python geckodriver

Here is my code:profile = webdriver.FirefoxProfile(C:\\Users\\Administrator\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\kvycjolb.Prdel) driver = webdriver.Firefox(profile)Im not getting any error an…