0

我知道 RIDE 运行 .robot 文件并将 txt 转换为 Python robots.api 调用。我正在尝试查看 Ride 中的某些内容如何转换为 robots.api 中的调用方式

有没有办法查看 Ride 在 Ride 中运行测试套件时如何使用 Robot.Api 调用?

澄清示例:

Ride中的.Robot文件:

*** Settings ***
Library           DateTime

*** Test Case ***
A_Test_Case
Should Be Equal    1    1

是相同的:

Python机器人.api:

from robot.api import TestSuite

suite = TestSuite(name='Test_Suite')
suite.resource.imports.library('DateTime')
testcase = suite.tests.create('Test_Case')
testcase.keywords.create('Should Be Equal', args=[1, 1])

我需要知道是否有办法查看 .robot 文件如何转换为其对应的 python。

4

1 回答 1

2

有没有办法查看 Ride 在 Ride 中运行测试套件时如何使用 Robot.Api 调用?

它并不像你想的那样工作。机器人将您问题中的第一个代码块转换为您的第二个代码块是没有时间点的。

我需要知道是否有办法查看 .robot 文件如何转换为其对应的 python。

It's open-source, so you can just dig into the code and look around. The place to start would be in the src/robot/parsing module. Be aware that what you are looking for doesn't exist in the format you're probably wanting to see.

Instead of converting the robot text into a python script, the robot.parsing.parser module tokenizes the data via the robot.parsing.lexer and then converts the data to various internal models. There is no intermediate step where it outputs python code.

On github is an issue for the work that went into creating the new parser. From that issue you can see commits for the new lexer and all of the other parts of the parsing process as it evolved.

于 2020-04-09T18:28:58.643 回答