Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium opens browser but doesn't load page

This is an extension from a previous post which I could not get to work, but I am now getting a new error after updating Selenium.

I am using Python 3.5, Windows 8.1, and Selenium 3.0.1.

I know the code works because it works on my Mac, but when I bring it over to my work computer which is described above, the only thing that happens is the browser will open, but it won't load anything, not even a homepage.

From everything I could find on search I downloaded the geckodriver, renamed it to wires.exe, and I added the directory to the system PATH environment variable.

Sys

I am completely lost on what to do to get this to work. Here is the code I'm using:

from selenium import webdriver

driver = webdriver.Firefox()

driver.get('https://www.google.com')

Here are the errors I am getting:

Errors

like image 816
Senor Penguin Avatar asked Oct 21 '16 22:10

Senor Penguin


2 Answers

I did not add geckodriver to PATH (it is located in the same directory as Python script), and after the Selenium update to 3.0.1, use this code to start a Selenium session:

gecko = os.path.normpath(os.path.join(os.path.dirname(__file__), 'geckodriver'))
binary = FirefoxBinary(r'C:\Program Files (x86)\Mozilla Firefox\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary, executable_path=gecko+'.exe')

Additionally: you need update geckodriver to the latest version, 0.11.1.

like image 122
Andrew Avatar answered Sep 20 '22 23:09

Andrew


I got the same problem with my Ubuntu 20.10 (Groovy Gorilla) installation and fixed it with the terminal using this line:

sudo apt-get install firefox-geckodriver

You can do the same with a macOS machine:

brew install geckodriver
like image 27
reee Avatar answered Sep 22 '22 23:09

reee