from selenium import webdriver
from selenium.webdriver.chrome.service import Service
s = Service('executables/chrome-win64/chrome.exe')
chromeOptions = webdriver.ChromeOptions()
chromeOptions.add_argument("--start-maximized")
driver = webdriver.Chrome(service=s, options=chromeOptions)
print("Hello.....")
# Launch the application
driver.get("https://chromedriver.chromium.org/downloads")
driver.close()
Program is getting hanged at step
driver = webdriver.Chrome(service=s, //options=chromeOptions)
and application is not getting launched.
Root cause of the issue: You need to pass the location of browser driver which is chromedriver.exe
in the Service argument. And not the location of browser binary(chrome.exe
).
Solution: Change the line of code as below:
s = Service('<full path>/chromedriver.exe')
Suggestion: Having said the above, since you are using latest selenium version, you do not have to worry about manually setting the chrome driver location. Selenium will download and manage the driver automatically for you. Your code can be simplified as below:
from selenium import webdriver
chromeOptions = webdriver.ChromeOptions()
chromeOptions.add_argument("--start-maximized")
driver = webdriver.Chrome(options=chromeOptions)
print("Hello.....")
# Launch the application
driver.get("https://chromedriver.chromium.org/downloads")
driver.close()
Refer this answer for more details about browser driver management by Selenium: