使用Mozmill测试Firefox插件

2024-04-28 16:53:39 发布

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

我有一个Mozilla Firefox插件,想测试一下。我找到了Mozmill,并编写了一个小的Python脚本,它只需要获取每个Firefox版本,然后像这样运行命令:

mozmill --binary=C:\browsers\firefox\38.0.1\firefox.exe 
--addon=C:\my_ext\ext 
--test=C:\my_ext\tests\mozmill\

下面是脚本unit_test_runner_public.py

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from subprocess import check_output
import time

firefox_binary_path = 'C:\\browsers\\firefox\\'
ff_addon_location = 'C:\\my_ext\\ext'
tests_folder = 'C:\\my_ext\\tests\\mozmill\\'
ff_versions = ['38.0.1', '37.0.2', '36.0.4', '35.0.1', '34.0.5', '33.1.1',
               '32.0.3', '31.0', '30.0', '29.0.1', '28.0', '27.0.1', '26.0',
               '25.0.1', '24.0', '23.0.1', '22.0', '21.0', '20.0.1', '19.0.2',
               '18.0.2', '17.0.1', '16.0.2', '15.0.1', '14.0.1', '13.0.1']


def build_ff_path(ff_version):
    return "%s%s%s" % (firefox_binary_path, ff_version, "\\firefox.exe")


for item in ff_versions:
    print "##### Started unit tests for Mozilla Firefox %s #####" % item
    current_run = "mozmill --binary=%s --addon=%s --test=%s" % \
        (build_ff_path(item), ff_addon_location, tests_folder)
    test_run_result = check_output(current_run, shell=True)
    print "##### Finished unit tests for Mozilla Firefox %s #####" % item

    time.sleep(10)

所以Mozmill启动浏览器,运行测试,然后关闭浏览器,对从38.0.1到13.0.1的每一个Firefox版本进行测试

问题是,几乎每次它都挂在某个随机的Firefox版本上。所以它打开浏览器实例,运行测试,但是它没有关闭浏览器,Firefox窗口挂起一段时间,然后我在终端中看到这样的异常:

##### Finished unit tests for Mozilla Firefox 16.0.2 #####
##### Started unit tests for Mozilla Firefox 15.0.1 #####
mozversion INFO | application_buildid: 20120905151427
mozversion INFO | application_changeset: 0b774a1067fe
mozversion INFO | application_display_name: Firefox
mozversion INFO | application_id: {ec8030f7-c20a-464f-9b0e-13a3a9e97384}
mozversion INFO | application_name: Firefox
mozversion INFO | application_repository: http://hg.mozilla.org/releases/mozilla
-release
mozversion INFO | application_vendor: Mozilla
mozversion INFO | application_version: 15.0.1
mozversion INFO | platform_buildid: 20120905151427
mozversion INFO | platform_changeset: 0b774a1067fe
mozversion INFO | platform_repository: http://hg.mozilla.org/releases/mozilla-re
lease
mozversion INFO | platform_version: 15.0.1
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\mozmill\__init__.py", line 878, in run
    mozmill.run(tests, self.options.restart)
  File "C:\Python27\lib\site-packages\mozmill\__init__.py", line 473, in run
    self.stop_runner()
  File "C:\Python27\lib\site-packages\mozmill\__init__.py", line 595, in stop_ru
nner
    raise Exception('client process shutdown unsuccessful')
Exception: client process shutdown unsuccessful
Traceback (most recent call last):
  File "unit_test_runner_public.py", line 24, in <module>
    test_run_result = check_output(current_run, shell=True)
  File "C:\Python27\lib\subprocess.py", line 573, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command 'mozmill --binary=C:\browsers\firefox\15.
0.1\firefox.exe --addon=C:\my_ext\ext --test=C:\my_ext\tests\mozmill\' returned 
non-zero exit status 1

C:\my_ext>

而且每次随机版本的Firefox都会出现这种情况,所以在某些特定的Firefox版本中没有类似模式的问题。你知道吗

系统详细信息如下:

  • 操作系统:Microsoft Windows 7 Enterprise SP1 x86
  • Python:2.7.9版
  • 莫兹密尔:2.0.10

以及pip列表的输出:

blessings (1.6)
jsbridge (3.0.3)
ManifestDestiny (0.5.7)
manifestparser (1.1)
mozcrash (0.14)
mozdevice (0.45)
mozfile (1.1)
mozinfo (0.7)
mozlog (2.11)
mozmill (2.0.10)
moznetwork (0.24)
mozprocess (0.22)
mozprofile (0.23)
mozrunner (5.35)
mozversion (1.0)
pip (1.5.6)
setuptools (7.0)

有人有过这样的经历吗?你知道吗


Tags: runpytestinfomozillaapplicationmytests
1条回答
网友
1楼 · 发布于 2024-04-28 16:53:39

所以,在Mozmill Developers Google Groups上发布了一个问题之后,我得到了Henrik Skupin的答案,他是Mozmill的负责人。你知道吗

简言之,他们也遇到了这个问题,但是Mozmill很快就要停产了——最好开始使用新的框架firefox-ui-tests。不幸的是,它还不能像Mozmill那样指定 addon,但是bug(featurerequest);)已经创建好了,所以很可能这个功能会在将来的版本中添加。同时,如果您需要测试Firefox加载项,您可以指定 profile到已经预构建的Firefox配置文件中,其中包含预安装的加载项。你知道吗

相关问题 更多 >