需求:
接收一个目录路径,自动遍历目录下以及子目录下的所有批处理(.bat) 文件并执行。
首先在..Python27Libsite-packages 目录下创建 CustomLibrary 目录,用于放自定义的 library 库。在其下面创建 runbat.py 文件:
if __name__ == "__main__":
path = u'D:\test_boject'
run = Runbat()
run.run_all_bat(path)
__init_.py
from runbat import Runbat __version__ = '0.1' class CustomLibrary(Runbat): """ 这里也可以装 x 的写上我们创建的 CustomLibrary 如何如何。 """ ROBOT_LIBRARY_SCOPE = 'GLOBAL'
这个文件中其实有用的信息就三行,但必不可少。robot framwork 在启动时会加载这个文件,因为 在这个文件里指明了有个 runbat 文件下面有个 Runbat 类。从而加载类里的方法(run_all_bat())。 下面,启动 RIDE,按 F5:
找到了我们创建的关键字,下面就是在具体的项目或测试套件中引用 CustomLibrary