*** Variables *** ${BROWSER} firefox ${URL} http://url/ ${Delay} 0
在我的settings.txt文件中,我有一个名为{BROWSER}的变量,并且关联值如上所示,它是firefox
但是我想要的是
*** Variables *** @{BROWSERS} firefox chrome IE ${URL} http://url/ ${Delay} 0
像上面的东西…所以当我首先运行测试套件时,它将在firefox中运行,并且在完成所有测试用例之后,它将关闭firefox,将打开chrome并在chrome浏览器上再次运行所有测试用例..依此类推它将在IE上运行
那么我们该怎么做呢?
我不想手动进行操作(我的意思是一一传递或编辑txt文件)。完全自动....一旦我运行测试,它将在所有浏览器中自动测试。
PS:这是在settings.txt文件中,我有两个文件夹,其中有test.txt文件。所以有一个主要问题..我必须循环访问这些文件夹
|-- main.py |-- settings.txt //in this file i have browser variable (or Array) |-- test1 | |-- testl.txt | |-- test1_settings.txt //this will contain all the variables and user defined keyword related to test1 and |-- test2 | |-- test2.txt | |-- test2_settings.txt //same as test1
我运行这样的测试用例 $pybot test1 test2
$pybot test1 test2
我看到两种方法。
1)循环浏览器并调用进行测试的关键字:
*** Variables *** @{BROWSERS} firefox chrome IE *** test cases *** test with several browser :FOR ${browser} IN @{BROWSERS} \ log to console call keyword that does your test with ${browser}
这是您通过此测试得到的结果:
[Mac]$ pybot . Browser.Ts ============================================================================== test with several browser call keyword that does your test with firefox call keyword that does your test with chrome call keyword that does your test with IE test with several browser | PASS | ------------------------------------------------------------------------------ Browser.Ts | PASS | 1 critical test, 1 passed, 0 failed 1 test total, 1 passed, 0 failed ==============================================================================
2)另一种方式(我更喜欢)是将$ {BROWSER}变量保留为单个值,并使用在命令行中给出的变量的新值多次调用测试用例:
[Mac]$ pybot --variable BROWSER:firefox ts.txt [Mac]$ pybot --variable BROWSER:chrome ts.txt [Mac]$ pybot --variable BROWSER:ie ts.txt