Selenium opens browser but doesn't load page

寵の児 提交于 2019-11-27 06:20:09

问题


this is an extension from a previous post I made Here 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, 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 wont 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.

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

from selenium import webdriver

driver = webdriver.Firefox()

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

Here are the errors I am getting:


回答1:


I did not add geckodriver to PATH (it is located in the same directory as Python script), and after selenium update to 3.0.1 use this code to start 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.




回答2:


You need to set geckodriver path as mentioned below:

self.driver = webdriver.Firefox(executable_path = 'D:\Selenium_RiponAlWasim\geckodriver-v0.18.0-win64\geckodriver.exe')

Download geckodriver for you suitable OS --> Extract it in a folder of your choice --> Set the path correctly.

I'm using Python 3.6.2 and Selenium WebDriver 3.4.3




回答3:


For windows10 downloadgechodriver

and extract it on like below . customize it for yourself. my username is yasin in windows10

C:\Users\yasin\AppData\Local\Programs\Python\Python37\Scripts


来源:https://stackoverflow.com/questions/40186299/selenium-opens-browser-but-doesnt-load-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!