簡體   English   中英

在 Windows 上使用 Python 未在 Selenium WebDriver 中加載頁面

[英]Page is not loaded in Selenium WebDriver using Python on Windows

我在 Windows 計算機上使用 Python 3.5。 當我在 Mac 上運行此代碼時,它運行良好,沒有任何問題。 但是當我將代碼帶到我的 Windows 計算機時它不起作用。

基本上顯示一個空白頁面而不是主頁。 我沒有收到任何錯誤消息。

from selenium import webdriver

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

print(cookies)

關閉 Web 瀏覽器后,我會在 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.

從我在網上找到的內容(大多數是針對 Java 的)看來我可能需要設置一個配置文件? 這是正確的,有人可以幫忙嗎?

看起來您的客戶沒有修復用於啟動 Gecko 驅動程序的新開關:

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

如果要使用 geckodriver v0.10.0 及更高版本,請確保安裝了最新的測試版 (selenium-3.0.0b2):

pip install -U selenium --pre

請注意,您需要--pre標志來安裝測試版。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM