-
Notifications
You must be signed in to change notification settings - Fork 1.4k
SeleniumBase specify path to chromedriver #3087
-
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?...)
Beta Was this translation helpful? Give feedback.
All reactions
There are 2 places SeleniumBase checks for drivers:
- The
seleniumbase/drivers
folder. - 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
-
There are 2 places SeleniumBase checks for drivers:
- The
seleniumbase/drivers
folder. - 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.
Beta Was this translation helpful? Give feedback.
All reactions
-
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 ?
Beta Was this translation helpful? Give feedback.
All reactions
-
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.
Beta Was this translation helpful? Give feedback.
All reactions
-
@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.)
Beta Was this translation helpful? Give feedback.
All reactions
-
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?
Beta Was this translation helpful? Give feedback.
All reactions
-
You could try this thread: #2459
Beta Was this translation helpful? Give feedback.
All reactions
-
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
Beta Was this translation helpful? Give feedback.
All reactions
-
The Driver()
doesn't have the special virtual display code that SB()
has.
Beta Was this translation helpful? Give feedback.
All reactions
-
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.
Beta Was this translation helpful? Give feedback.