简体   繁体   中英

Page is not loaded in Selenium WebDriver using Python on Windows

I am using Python 3.5 on a Windows computer. When I run this code on my Mac it works perfect, no issues what so ever. But when I bring the code to my Windows computer it doesn't work.

Basically a blank page is shown instead of the home page. I don't get any error messages.

from selenium import webdriver

driver = webdriver.Firefox()
driver.get('https://www.google.com')
cookies = driver.get_cookies()

print(cookies)

Once I close the web browser I get this message in the shell:

"The browser appears to have exited " selenium.common.exceptions.WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.

From what I've been able to find online (most is for Java) it looks like I may need to setup a profile? Is this correct and could anyone help with this?

It looks like your client doesn't have the fix for the new switch to launch the gecko driver:

https://github.com/SeleniumHQ/selenium/commit/c76917839c868603c9ab494d8aa0e9d600515371

Make sure that you have the latest beta version installed (selenium-3.0.0b2) if you which to use the geckodriver v0.10.0 and above:

pip install -U selenium --pre

Note that you need the --pre flag to install the beta version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM