我正在使用selenium进行geckodriver和firefox的功能测试.
我看到主机是,http://localhost:62305并且在该类中生成:
@classproperty
def live_server_url(cls):
return 'http://%s:%s' % (cls.host, cls.server_thread.port)
Run Code Online (Sandbox Code Playgroud)
在我创建的功能中,我为用户提供了一种方法来创建具有自己子域的租户,但出于单元测试的目的,它可以是域.
因此,例如,我使用域创建租户example.com,如何
StaticLiveServerTestCase在同一个功能测试方法中将该域名指向同一端口上当前正在运行的应用程序.
我查看了这篇建议编辑的帖子 /etc/hosts.问题在于它不仅适用于CI和其他人的计算机.
你可以这样做。
class SeleniumTests(StaticLiveServerTestCase):
@classmethod
def setUpClass(cls):
cls.host = 'host.com'
cls.port = 3000
super(SeleniumTests, cls).setUpClass()
....
Run Code Online (Sandbox Code Playgroud)
在你的测试类中,一旦你这样做了
self.selenium.get('%s%s' % (self.live_server_url), 'some_url')
您的浏览器将使用这样的正确 URL 启动
http://host.com:3000/some_url/,请注意设置端口和主机后如何进行超级调用。
| 归档时间: |
|
| 查看次数: |
60 次 |
| 最近记录: |