我用的是码头硒和Django。我刚刚意识到我是在我的生产数据库上做测试,而我想在StaticLiveServerTestCase自生成的数据库上进行测试。
我试着跟踪那个教程
@override_settings(ALLOWED_HOSTS=['*'])
class BaseTestCase(StaticLiveServerTestCase):
host = '0.0.0.0'
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.host = socket.gethostbyname(socket.gethostname())
cls.selenium = webdriver.Remote(
command_executor='http://hub:4444/wd/hub',
desired_capabilities=DesiredCapabilities.CHROME,
)
cls.selenium.implicitly_wait(5)
@classmethod
def tearDownClass(cls):
cls.selenium.quit()
super().tearDownClass()
class MyTest(BaseTestCase):
def test_simple(self):
self.selenium.get(self.live_server_url)我没有错误试图连接到铬-集线器,但当我试图打印我的page_source,我不是在我的django应用程序,但铬错误信息。这里有一部分:
<div class="error-code" jscontent="errorCode" jstcache="7">ERR_CONNECTION_REFUSED</div>我使用的是码头-合成1. Selenium.yml:
chrome:
image: selenium/node-chrome:3.11.0-dysprosium
volumes:
- /dev/shm:/dev/shm
links:
- hub
environment:
HUB_HOST: hub
HUB_PORT: '4444'
hub:
image: selenium/hub:3.11.0-dysprosium
ports:
- "4444:4444"
expose:
- "4444"
app:
links:
- hub我想我在我的文件里做错了什么,但我想不出是什么。
提前谢谢!
PS:live_server_url = http://localhost:8081
发布于 2022-01-16 06:49:21
https://stackoverflow.com/questions/50601185
复制相似问题