小编tac*_*ack的帖子

django selenium LiveServerTestCase

我有selenium和LiveServerTestCase的问题.当我运行./manage.py test functional_tests它时,加载页面"标题:问题加载页面.正文:无法连接......"

functional_tests.py:

from selenium import webdriver
from django.test import LiveServerTestCase

class GeneralFunctionalTests(LiveServerTestCase):
    def setUp(self):
        self.browser = webdriver.Chrome()
        self.browser.implicitly_wait(3)

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

    def test_can_navigate_site(self):
        self.browser.get('http://localhost:8000')
        assert 'Django' in self.browser.title
Run Code Online (Sandbox Code Playgroud)

我尝试使用classmethod setUp和tearDown:

@classmethod
def setUpClass(cls):
    super(MySeleniumTests, cls).setUpClass()
    cls.browser = WebDriver()
...
Run Code Online (Sandbox Code Playgroud)

结果是一样的.但是我可以在网上加载任何其他页面self.browser.get('http://example.com').Selenium是最新的.

谢谢!

python django selenium

9
推荐指数
3
解决办法
5889
查看次数

标签 统计

django ×1

python ×1

selenium ×1