imports...
browser = webdriver.Firefox()
browser.get('http://google.com')
I'm trying to execute the code above. It used to work and now it doesn't: Firefox doesn't even open. The code, Python, Selenium and all the other libraries, Firefox and geckodriver have not changed at all since when it worked. What changed was that I installed many new apps in my Windows PC, such as: Plex media server, Eclipse, Java development kit and many Java libraries, Maven, Postgresql and Git.
Here's all that appears in the terminal when I run:
Traceback (most recent call last):
File "C:\Users\hougy\OneDrive\Documentos\plij\seleniumtest.py", line 26, in <module>
browser = webdriver.Firefox()
File "C:\Users\hougy\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 175, in __init__
self.service.start()
File "C:\Users\hougy\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\common\service.py", line 108, in start
raise WebDriverException("Can not connect to the Service %s" % self.path)
selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service geckodriver
When it was working, the message "1636932662336 geckodriver INFO Listening on 127.0.0.1:49684" appeared in the geckodriver.log, followed by a lot of stuff. Now, only that message appears. Each time, the code before "geckodriver INFO" and the port are different.
I was thinking that maybe the problem was that they all try to use localhost. So I made sure Plex and Postgre were not running. I also tried a solution that wanted you to make sure 127.0.0.1 was mapped to localhost in a Windows file.
I also tried many of the common selenium solution such adding some options, making sure the geckodriver is found and updating everything.
If I run the same code in another PC that's also in my home, it works perfectly, but I need to make it work in this PC.
It's been more than a year since I need to use Selenium and I was working with Chrome and chromedriver before, but I had problems and had to waste a lot of time debugging all the time, probably because Chrome update frequently. So recently, when I couldn't solve the latest problem, I found out I could use Firefox just for this and configure it to never update. I thought my pain was over, but here I am again. Here's the problem I couldn't fix last time with chromedriver: