Selenium停止使用Firefox,使用Safari

时间:2018-12-16 20:35:56

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

一段时间以来,我一直在使用Selenium和Python 3。昨天它停止工作了。我尝试卸载并重新安装所有内容,但没有成功。我为Safari启用了驱动程序,并且可以运行,但是我不知道发生了什么变化。我试图去一个我已经有一段时间没有使用但运行了的项目,以为我的代码把它扔了下来,但它也不起作用。我知道还有其他类似的帖子,但是它们并没有帮助,我不确定是否应该就此问题与Mozilla / Selenium联系。这是我的详细信息:

Python 3.7.1
Django 2.1
Firefox 64
Selenium 3.141.0
Geckodriver 0.23.0

我正在虚拟环境中运行它们。还有其他问题,请告诉我。真的很困惑。

这是与启动浏览器有关的所有代码:

class FunctionalTest(StaticLiveServerTestCase):

    def setUp(self):
        self.browser = webdriver.Firefox()


    def get_page(self, url_extention, window=None):
        window_size = [900, 700]
        if window == 'xs':
            window_size = [500, 700]
        elif window == 'sm':
            window_size = [700, 500]
        elif window == 'md':
            window_size = [900, 700]
        elif window == 'lg':
            window_size = [1024, 768]
        elif window == 'xl':
            window_size = [1400, 800]

        return (
            self.browser.get(
                self.live_server_url + url_extention
            ),
            self.browser.set_window_size(
                window_size[0],
                window_size[1]
            )
        )

class PageFunctionTest(FunctionalTest):

    def test_customer_page(self):
        self.get_page('/customer/profile/1/', window='xs')
        # I also tried this just to check:
        self.browser.get(self.live_server_url)

基本上,浏览器将打开,引发错误,然后退出。这是浏览器窗口中显示的内容:

  

地址栏:http // localhost:59905 / customer / profile / 1 /

     

浏览器错误:Firefox无法在localhost:59905建立与服务器的连接。

这是回溯:

  

回溯(最近通话最近):文件   “ tests / functional_tests / test_function_profile_update_phone_number.py”,   第21行,在test_update_profile_phone_number中       self.get_page(f'/ customer / profile / 1 /',window ='xs')文件“ /base_tests/base_FunctionalTest.py”,第70行,位于get_page       self.live_server_url + url_extension文件“ /lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py”,   输入333行       self.execute(Command.GET,{'url':url})文件“ /lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py”,   第321行,在执行中       self.error_handler.check_response(响应)文件“ /lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py”,   第242行,在check_response中       引发exception_class(消息,屏幕,堆栈跟踪)selenium.common.exceptions.WebDriverException:消息:已达到错误   页:   关于:neterror?e = connectionFailure&u = http%3A // localhost%3A59905 / customer / profile / 1 /&c = UTF-8&f = regular&d = Firefox%20can%E2%80%99t%20建立%20a%20connection%20to%20the %20server%20at%20localhost%3A59905。

0 个答案:

没有答案
相关问题