I don't know why but yeasterday and the day before it worked but today no. I changed nothing and the PATH is always at the same place.
from selenium import webdriver
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.common.by import By
from webdriver_manager.firefox import GeckoDriverManager
import pandas as pd
import re
import time
driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
driver.get(("https://cordis.europa.eu/search/fr?q=contenttype%3D%27project%27%20AND%20programme%2Fcode%3D%27H2020%27&p=1&num=10&srt=/project/contentUpdateDate:decreasing"))
I have that big error message :
--------------------------------------------------------------------------
SessionNotCreatedException Traceback (most recent call last)
C:\Users\JOHAN~1.ROC\AppData\Local\Temp/ipykernel_6336/1824966143.py in <module>
----> 1 driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
2 driver.get(("https://cordis.europa.eu/search/fr?q=contenttype%3D%27project%27%20AND%20programme%2Fcode%3D%27H2020%27&p=1&num=10&srt=/project/contentUpdateDate:decreasing"))
3
4
5 #link = driver.find_element(By.XPATH,"/html/body/app-root/ng-component/main/div/div/section[2]/section[2]/app-card-search[1]/div/div[2]/a")
~\Anaconda3\lib\site-packages\selenium\webdriver\firefox\webdriver.py in __init__(self, firefox_profile, firefox_binary, timeout, capabilities, proxy, executable_path, options, service_log_path, firefox_options, service_args, desired_capabilities, log_path, keep_alive)
168 executor = FirefoxRemoteConnection(
169 remote_server_addr=self.service.service_url)
--> 170 RemoteWebDriver.__init__(
171 self,
172 command_executor=executor,
~\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in __init__(self, command_executor, desired_capabilities, browser_profile, proxy, keep_alive, file_detector, options)
155 warnings.warn("Please use FirefoxOptions to set browser profile",
156 DeprecationWarning, stacklevel=2)
--> 157 self.start_session(capabilities, browser_profile)
158 self._switch_to = SwitchTo(self)
159 self._mobile = Mobile(self)
~\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in start_session(self, capabilities, browser_profile)
250 parameters = {"capabilities": w3c_caps,
251 "desiredCapabilities": capabilities}
--> 252 response = self.execute(Command.NEW_SESSION, parameters)
253 if 'sessionId' not in response:
254 response = response['value']
~\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in execute(self, driver_command, params)
319 response = self.command_executor.execute(driver_command, params)
320 if response:
--> 321 self.error_handler.check_response(response)
322 response['value'] = self._unwrap_value(
323 response.get('value', None))
~\Anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py in check_response(self, response)
240 alert_text = value['alert'].get('text')
241 raise exception_class(message, screen, stacktrace, alert_text)
--> 242 raise exception_class(message, screen, stacktrace)
243
244 def _value_or_default(self, obj, key, default):
SessionNotCreatedException: Message: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line
If you have an idea of why it why it does not work and why doesn't it work anymore.
Possibly the issue is with
get()
. While invokingget()
you need to pass the url_string as the argument. So instead ofget(("url_string"))
it should have beenget("url_string")
.Effectively, your line of code would be: