python不能在firefox中运行selenium测试,但是pytest可以

2024-06-26 17:43:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我用pytest和selenium。我有一个简单的设置:

browser = webdriver.Firefox()

使用py.test test_foo.py运行测试文件时 firefox浏览器正确启动,获得了url并顺利地执行了测试。在

然后我创建了另一个python文件testsuite1.py,其中包含 pytest.main('py.test test_foo.py')

我运行了python testsuite1.py,它打开了Firefox浏览器,但未能获得URL并完成测试。失败的错误:

WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.

我在谷歌上搜索了很多关于这个问题的帖子,但没有找到任何解决办法。我已经使用firefox40更新到Selenium 2.47.1。我不明白为什么它能和py.测试命令与否pytest.main在python中。在

有什么想法吗?在


Tags: 文件pytestbrowserurlfoopytestmain