已到达错误页面:仅在Firefox

时间:2019-05-16 17:31:17

标签: python-3.x selenium-webdriver geckodriver

我正在浏览一些Selenium实例,并且能够在所有浏览器中启动。最近几天,我无法连接到我在Firefox中使用过的网址。我得到Firefox“无法连接”屏幕。

环境:

MacBook Pro 2017 莫哈韦河10.14.5 Firefox Quantum 66.0.5(64位) 硒版本3.141.0

我尝试更新Selenium,但是我使用的是最新版本。

我已丢弃Gecko驱动程序并重新安装。

我可以进入浏览器设置(Firefox->“首选项”->“网络设置”->“设置”->),我可以单击无代理并且可以手动连接到站点,但是启动新测试时永远不会保存此设置。

from selenium import webdriver
from selenium.webdriver.common.by import By
import time

class CalendarSelection():

    def test1(self):
        baseUrl = "http://www.expedia.com"
        driver = webdriver.Firefox()
        driver.maximize_window()
        driver.get(baseUrl)
        driver.implicitly_wait(3)

        # Click flights tab
        driver.find_element_by_id("tab-flight-tab-hp").click()
        # Find departing field
        departingField = driver.find_element_by_id("flight-departing-hp-flight")
        # Click departing field
        departingField.click()
        # Find the date to be selected
        # Expedia website has changed the DOM after the lecture was made
        # Updated new xpath
        dateToSelect = driver.find_element(By.XPATH,
                                           "//div[@class='col gcw-date-field']//div[2]//table[1]//tbody[1]//tr[2]//td[5]//button[1]")
        # Click the date
        dateToSelect.click()

        time.sleep(3)
        driver.quit()

ff = CalendarSelection()
ff.test1()

traceback (most recent call last):
  File "/Users/kodycarling/Desktop/Selenium/Selenium Udemy Class 1/Python_files/Selenium initial Examples/my_code/calendar-selection_pract.py", line 32, in <module>
    ff.test1()
  File "/Users/kodycarling/Desktop/Selenium/Selenium Udemy Class 1/Python_files/Selenium initial Examples/my_code/calendar-selection_pract.py", line 11, in test1
    driver.get(baseUrl)
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 333, in get
    self.execute(Command.GET, {'url': url})
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Reached error page: about:neterror?e=connectionFailure&u=http%3A//www.expedia.com/&c=UTF-8&f=regular&d=Firefox%20can%E2%80%99t%20establish%20a%20connection%20to%20the%20server%20at%20www.expedia.com.

0 个答案:

没有答案