Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/351.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将Selenium与Django一起使用时,服务器未正确创建_Python_Django_Selenium_Functional Testing - Fatal编程技术网

Python 将Selenium与Django一起使用时,服务器未正确创建

Python 将Selenium与Django一起使用时,服务器未正确创建,python,django,selenium,functional-testing,Python,Django,Selenium,Functional Testing,我最近重新安装了Django和Selenium,大多数东西似乎都正常工作,但当我尝试运行功能测试时,webdriver显然找不到LiveServer地址 代码如下所示: from selenium import webdriver from selenium.webdriver.common.keys import Keys from django.test import LiveServerTestCase import unittest class GeneralFunctionalTes

我最近重新安装了Django和Selenium,大多数东西似乎都正常工作,但当我尝试运行功能测试时,webdriver显然找不到LiveServer地址

代码如下所示:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from django.test import LiveServerTestCase
import unittest

class GeneralFunctionalTests(LiveServerTestCase):

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

    def tearDown(self):
        self.browser.quit()

    def test_can_navigate_site(self):
        self.browser.get(self.live_server_url)

        # some tests from here
webdriver将启动,但主页无法正确加载到使用python manage.py runserver的普通浏览器上,因此所有测试都会失败,因为找不到任何元素。self.live\u服务器\u url等于http://localhost:8081,这对我来说很合适


有关于我在这里遗漏什么的线索吗?

好吧,没关系。又一次,是杀毒软件在不应该的地方搞砸了。如果您有相同的问题,并且您的防病毒软件是Avast!,尝试在“活动保护设置”选项卡中禁用Web屏蔽。

当它失败时,您会收到什么错误消息?webdriver将加载到“未找到服务器”页面。然后测试失败,例如,find_element_by_id函数引发异常,因为它们无法找到此类元素。