繁体   English   中英

Python-运行Selenium测试时,firefox窗口打开,但保持空白

[英]Python - While running a Selenium test, firefox window opens but remains blank

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

python manage.py测试myapp

然后,Firefox窗口打开,但保持空白。 它停留了几秒钟,然后关闭,给了我一个巨大的错误消息。 不幸的是,由于安全问题,我无法发布错误消息。

我使用的Firefox版本是:Mozilla Firefox 39
硒版本为:2.4.2

我在myapp中的tests.py文件中进行测试:

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()

请帮忙。 谢谢。

根据您所描述的内容,并考虑到硒2.4.2非常老,这很可能是由于seleniumFirefox之间的兼容性问题所致。 selenium升级到最新版本(当前为2.46):

pip install --upgrade selenium

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM