简体   繁体   English

在python中使用机器人框架

[英]Using the robot framework in python

Is it possible to use the Robot Framework programmatically in python? 是否可以在python中以编程方式使用Robot Framework? All I find are resources on using Java. 我发现的只是使用Java的资源。

I don't think you are understand what Robot Framework exactly does. 我认为您不了解Robot Framework的功能。 Robot Framework is build on Python and if you like you can use it within Java by a Maven plugin. Robot Framework是基于Python构建的,如果愿意,您可以通过Maven插件在Java中使用它。 Because of speed issues the preferred way is to use it directly on python. 由于速度问题,首选方法是直接在python上使用它。

See the Quick start for more information 有关更多信息,请参见快速入门。

Yes, it is possible to use robot framework programmatically, if by that you're asking if you can create and run test suites written purely in python. 是的,如果您询问是否可以创建和运行纯粹用python编写的测试套件,则可以以编程方式使用机器人框架。 When you do that, you're missing the point of robot framework. 当您这样做时,您会丢失机器人框架的要点。

To see how to do it, read the robot framework API documentation . 要查看操作方法,请阅读机器人框架API文档 Here is an example: 这是一个例子:

from robot.api import TestSuite

suite = TestSuite('Activate Skynet')
suite.imports.library('OperatingSystem')
test = suite.tests.create('Should Activate Skynet', tags=['smoke'])
test.keywords.create('Set Environment Variable', args=['SKYNET', 'activated'], type='setup')
test.keywords.create('Environment Variable Should Be Set', args=['SKYNET'])

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

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