Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

SeleniumBase specify path to chromedriver #3087

Answered by mdmintz
FindingBen asked this question in Q&A
Discussion options

I have my lambda code deployed on ECR and I have a script that downloads the crome driver for linux. I know that seleniumbase initiation downloads the chrome automatically but the problem is it uses downloaded_files folder and my lambda can't write it since it has limitations. I tried making /tmp folder where lambda seems to have writing permission but it doesn't work.

Can I manually specify the path where my chromedriver gets downloaded and use it like its being used in selenium?

Something like this:

driver = Driver(undetectable=True,headless2=True,binary_location="/opt/chrome/chrome-linux64/chrome", executable_path=...here for example?...)

You must be logged in to vote

There are 2 places SeleniumBase checks for drivers:

  1. The seleniumbase/drivers folder.
  2. Each folder of os.environ["PATH"], in order.

If you don't want to use the seleniumbase/drivers folder for driver storage, then you can download chromedriver manually to a folder on your System PATH. The version of chromedriver must match your version of Chrome, or else SeleniumBase will automatically download a matching driver to the seleniumbase/drivers folder, which can't be changed. You can, however, change os.environ["PATH"] at runtime so that you can add a folder to the front that isn't already there.

Replies: 2 comments 7 replies

Comment options

There are 2 places SeleniumBase checks for drivers:

  1. The seleniumbase/drivers folder.
  2. Each folder of os.environ["PATH"], in order.

If you don't want to use the seleniumbase/drivers folder for driver storage, then you can download chromedriver manually to a folder on your System PATH. The version of chromedriver must match your version of Chrome, or else SeleniumBase will automatically download a matching driver to the seleniumbase/drivers folder, which can't be changed. You can, however, change os.environ["PATH"] at runtime so that you can add a folder to the front that isn't already there.

You must be logged in to vote
3 replies
Comment options

And what if two different SB instances are running, both on a different driver ?
it appears the chromedriver is called uc_driver.exe on windows, no way to specify which driver is being used ?

Comment options

From the same virtual environment, you'll have one drivers/ folder containing a single chromedriver and a single uc_driver, shared by all tests. If you have different versions of Chrome installed on the same machine, use a different Python virtual environment for each. The driver version will match the browser version.

Comment options

@FindingBen There's now a way to override the default drivers dir. See: #3859

from seleniumbase.core import browser_launcher
browser_launcher.override_driver_dir("./temp")

(Make sure the folder already exists first.)

Answer selected by mdmintz
Comment options

Ok So I managed to get the files up and running but there is an issue. Since Lambda runtime environment allows the writing only on /tmp folder I am getting issue of : OSError: [Errno 30] Read-only file system: '/var/lang/lib/python3.12/site-packages/seleniumbase/drivers/uc_driver'

My question is I guess, can I use seleniumbase on lambda AWS given its runtime environment restricitons?

You must be logged in to vote
4 replies
Comment options

You could try this thread: #2459

Comment options

This doesn't really help my case because I cannot even initate the Driver. I have problem with the Lambda environment and I was hoping there is some kind of workaround in this.

Also I am using Driver() and in that thread the guy was using SB context

Comment options

The Driver() doesn't have the special virtual display code that SB() has.

Comment options

To override the drivers dir, you can now do something like this:

from seleniumbase.core import browser_launcher
browser_launcher.override_driver_dir("./temp")

Add to an __init__.py file, or into the script itself.

Make sure the folder already exists first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /