I've been having difficulty getting Selenium-dependent programs in Python to work (when they did in the past).
#Loading Webdriver
options = webdriver.ChromeOptions()
# options.add_argument('--headless')
#Set download folder to newly created folder
prefs = {"download.default_directory" : newfilepath}
options.add_experimental_option("prefs", prefs)
driver = webdriver.Chrome(executable_path=r'C:\Users\ujcho\Desktop\chromedriver.exe', options=options)
wait = WebDriverWait(driver,10)
#Calibrate url to find corresponding file in Karpel
url = "[insert url link here]"
driver.get(url)
login(driver)
For some reason, when the headless argument is added, the program seems to work fine. But when that line is commented out, I get the following error:
Traceback (most recent call last):
File "c:\Users\ujcho\Desktop\StanfordLabs2\test.py", line 80, in <module>
driver = webdriver.Chrome(executable_path=r'C:\Users\ujcho\Desktop\StanfordLabs2\chromedriver.exe', options=options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ujcho\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 84, in __init__
super().__init__(
File "C:\Users\ujcho\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 104, in __init__
super().__init__(
File "C:\Users\ujcho\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 286, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Users\ujcho\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 378, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ujcho\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 440, in execute
self.error_handler.check_response(response)
File "C:\Users\ujcho\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited normally.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location C:\Program Files\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
In the past, the code above would open a new window where the remaining program would automate the processes I instructed it to do. Now, it just opens an empty tab on a current window with "data;" in the url bar.
I don't know if this is relevant to the current problem I'm posing, but since I've been prompted to update my ChromeDriver to 113, Selenium has just been breaking down on me. Any help would be appreciated... I've tried reinstalling Google Chrome and that hasn't worked.
What web browser do you recommend using for Python Selenium (esp. for Windows 11)? Curious if Chrome maybe just ain't it.