21 Dec 2024
Python code stucked on driver = webdriver.Chrome()
If your python code stucked on driver = webdriver.Chrome() and you are using linux then run below commands (for windows I haven't tried but you need to download chrome/chormimum browser/driver then it should work)
sudo apt update
sudo apt install -y chromium-chromedriver
export PATH=$PATH:/usr/lib/chromium-browser/
Run above commands step by step then it should work
Find Browser Executable Path of existing browser (below is not working for me)
Note: Just install chromium and follow above steps
I am using Linux for Brave, but you can do this for any Chromium-based browser.
# Linux
which brave-browser
# Arch-based Linux
which brave
You will get an output. For me, it's /usr/bin/brave
. Then, export this path as shown below:
export PATH=$PATH:/usr/bin/brave
Now you need to also change driver initialization code
## Before
# Initialize browser
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
driver = webdriver.Chrome(options=options)
## Now
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
brave_path = "/usr/bin/brave" # Update if needed for your system
# Set binary location for Brave
options.binary_location = brave_path
# Path to chromedriver
chromedriver_path = "/usr/bin/brave" # Update if needed
# Initialize WebDriver with Brave
driver_service = Service(chromedriver_path)
driver = webdriver.Chrome(service=driver_service, options=options)
You may also like
Start Chromium driver/browser with maximized window
Start Chromium driver/browser with maximized window
Continue readingPython for Web Testing: Automating Web Interactions with Selenium
This detailed blog explores the use of Python and Selenium for autom...
Continue readingPython Automation: Introduction to Web, File, and Task Automation
This blog provides an introduction to Python automation, including w...
Continue reading