Issue
I've renamed the chrome executable to rome.exe
for experimenting purposes, and well, it doesn't open the webpage by driver.get()
but it does open the chrome, by debugging I found out that I've lost control over the browser once it opens, the code works completely fine if i dont specify the executable path, i.e just driver = webdriver.Chrome()
Below is my code.
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
chrome_path = r"C:\Program Files\Google\Chrome\Application\rome.exe"
Driver_service = Service(executable_path=chrome_path)
driver = webdriver.Chrome(service=Driver_service)
driver.get(r"https://stackoverflow.com/")
driver.quit()
To be noted that it isn't the chromedriver, but the chrome executable, if I run the above code when the executable is named anything apart from chrome it throws an error
Solution
You pass the chrome binary(chrome.exe
) into the driver
using ChromeOptions
and not Service
class.
In the Service
class, you can pass chromedriver.exe
.
Refer the code below to supply chrome.exe
binary manually:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
chrome_path = r"C:\Program Files\Google\Chrome\Application\crome.exe"
chrome_options = webdriver.ChromeOptions()
chrome_options.binary_location = chrome_path
driver = webdriver.Chrome(options=chrome_options)
driver.get(r"https://stackoverflow.com/")
driver.quit()
Answered By - Shawn
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.