【问题标题】:python nose tests: specifying which node the test should be run in Selenium Gridpython鼻子测试:指定测试应该在Selenium Grid中运行的节点
【发布时间】:2013-04-19 21:44:58
【问题描述】:

我正在尝试更新我的支持 Selenium Grid Hub 的测试以通过 nose tests 框架运行。

目前,没有鼻子测试,如果我想启动一个进程并让它在特定节点上运行,我会在 SelRunner.py 文件中添加这种类型的代码

p1 = subprocess.Popen('python Tst_Ayusa_Nmo.py 5564 WINDOWS chrome')

这会将 5564 WINDOWS chrome 的系统参数传递到我的测试文件中,它会知道它应该执行哪个 Grid 节点。

#execute test on this node: 5564 WINDOWS chrome
def setUp(self):
        if len(sys.argv) > 1:
            args = sys.argv
            port = args[1]
            platform = args[2]
            browser = args[3]

现在我在这里查看了关于鼻子的各种帖子,但我不太确定如何在下面完成同样的事情:

if __name__ == '__main__':

    argv = ['--with-xunit', 'Tst_Ayusa_Nmo.py 5564']
    nose.main(argv=argv)
======================================================================
ERROR: Failure: AttributeError ('module' object has no attribute 'py 5564')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\nose\loader.py", line 402, in loadTestsFromName
    module = resolve_name(addr.module)
  File "C:\Python27\lib\site-packages\nose\util.py", line 321, in resolve_name
    obj = getattr(obj, part)
AttributeError: 'module' object has no attribute 'py 5564'

----------------------------------------------------------------------
Ran 1 test in 0.001s

FAILED (errors=1)

一如既往地感谢!
附言除了命令行之外,我对传递节点配置的其他方法持开放态度。

【问题讨论】:

    标签: python selenium webdriver nose


    【解决方案1】:

    我使用 TestConfig 插件。所以我启动了如下鼻子测试:

    nose.run(argv=['nosetests','-v','-s','--with-xunit','--tc-file','./configFile'], 
                 plugins=[TestConfig(),Capture(),Xunit()])
    

    我做的内部测试

    from testconfig import config
    import sys
    class testModule_1:
        def test_M1_1(self):
            print 'Module 1 Test 1 Config: ' + config['rc_configuration']['command']
    

    我的配置文件示例:

    [TEST_CONFIG]
    xunitFile = firefoxTests.xml
    
    [rc_configuration]
    command = GoogleChrome
    

    '

    【讨论】:

    • 太好了,成功了。详细地说,您的配置文件是您放置端口号等的位置。例如:[TEST_CONFIG] xunitFile = android_ANDROID_5554.xml [rc_configuration] browser = android platform = ANDROID node = 8080 hostport = 8080
    猜你喜欢
    • 2018-09-02
    • 1970-01-01
    • 2015-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-31
    • 1970-01-01
    相关资源
    最近更新 更多