1 回答

TA贡献1834条经验 获得超8个赞
我以这种方式解决了问题(使用了phantom-js而不是HTMLUNIT,因为它是唯一剩余的稳定版本的代码)。
from django.test import LiveServerTestCase
from selenium import webdriver
from os import environ
class SeleniumTestCase(LiveServerTestCase):
__test__ = False
@classmethod
def setUpClass(cls):
environ['NO_PROXY'] = '127.0.0.1' # The key point
cls.selenium = webdriver.PhantomJS(service_args=['--proxy-type=none'])
super(SeleniumTestCase, cls).setUpClass()
@classmethod
def tearDownClass(cls):
cls.selenium.close()
cls.selenium.quit()
super(SeleniumTestCase, cls).tearDownClass()
class TestFoo(SeleniumTestCase):
def setUp(self):
# do something before every test method runs
pass
def test_foo(self):
# test
pass
添加回答
举报