I used Selenium with Python Chrome webdriver. In my code I used:
driver = webdriver.Chrome(executable_path = PATH_TO_WEBDRIVER)
to point the webdriver to the webdriver executable. Is there a way to point webdriver to the Chrome Browser binaries?
In https://sites.google.com/a/chromium.org/chromedriver/capabilities they have the following (which I assume it what I'm looking for):
ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/other/chrome/binary");
Anyone has an example for Python?
ChromeOptions optionsBeta = new ChromeOptions(); optionsBeta. setBinary(“path\\to\\chrome\\browser\\beta\\binary”); WebDriver driver = new ChromeDriver(optionsBeta);
Go to the terminal and type the command: sudo nano /etc/paths. Enter the password. At the bottom of the file, add the path of your ChromeDriver. Type Y to save.
You can set Chrome Browser Binary location through ChromeDriver using Python ing the following different ways:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"
driver = webdriver.Chrome(chrome_options=options, executable_path="C:/Utility/BrowserDrivers/chromedriver.exe", )
driver.get('http://google.com/')
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
cap = DesiredCapabilities.CHROME
cap = {'binary_location': "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"}
driver = webdriver.Chrome(desired_capabilities=cap, executable_path="C:\\Utility\\BrowserDrivers\\chromedriver.exe")
driver.get('http://google.com/')
from selenium import webdriver
import selenium.webdriver.chrome.service as service
service = service.Service('C:\\Utility\\BrowserDrivers\\chromedriver.exe')
service.start()
capabilities = {'chrome.binary': "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"}
driver = webdriver.Remote(service.service_url, capabilities)
driver.get('http://www.google.com')
Thanks a lot I was struggling with this for 2.5 hours as I did not know how to set the Chrome Executable path in Python. Works now
options = Options()
options.binary_location = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"
driver = webdriver.Chrome(chrome_options=options, executable_path="C:/Utility/BrowserDrivers/chromedriver.exe", )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With