虽然firefox会打开一个窗口,但是firefox仍然在运行一个测试

2024-03-29 13:12:44 发布

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

我使用Selenium在django(Python框架)中编写测试。当我跑步时:

python manage.py test myapp

然后,一个firefox窗口打开,但仍为空白。它停留了几秒钟,然后关闭,给我一个巨大的错误信息。很遗憾,由于安全问题,我无法发布错误消息。在

我使用的firefox版本是:Mozilla firefox 39
selenium版本是:2.4.2

我的测试测试.pymyapp中的文件:

from selenium import webdriver  
from django.test import TestCase

class MySampleTest(TestCase):  
    def setUp(self):  
        self.browser = webdriver.Firefox()  
        self.browser.implicitely_wait(3)  

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

    def test_mytest(self):  
        self.browser.get('http://www.google.com')  

当我运行我的测试时,它会在这一行显示一个错误:

self.browser = webdriver.Firefox()

请帮忙。谢谢您。在


Tags: djangofromtestimportself版本browserdef
1条回答
网友
1楼 · 发布于 2024-03-29 13:12:44

最有可能的是,根据您所描述的并考虑到Selenium2.4.2非常古老,这是由于selenium和{}之间的兼容性问题。升级selenium至最新版本(当前为2.46):

pip install  upgrade selenium

相关问题 更多 >