Untitled
unknown
plain_text
a year ago
1.2 kB
9
Indexable
import robot.parsing.model as model
def parse_robot_file(file_path):
# Parse the robot file
with open(file_path, 'r') as file:
model_object = model.TestData(parent=None, source=file_path)
model_object.populate(file.read())
# Get the first test case
if model_object.testcase_table:
first_test = model_object.testcase_table.tests[0]
print(f"First Test Case: {first_test.name}")
print("Test Case Keywords:")
for step in first_test.steps:
if isinstance(step, model.Step):
print(f" {step.name}")
else:
print("No test cases found.")
# Get all keywords from the Keywords section
print("\nAll Keywords from Keywords section:")
if model_object.keyword_table:
for keyword in model_object.keyword_table.keywords:
print(f" {keyword.name}")
for step in keyword.steps:
if isinstance(step, model.Step):
print(f" {step.name}")
else:
print("No keywords found in the Keywords section.")
# Usage
file_path = 'path/to/your/robot_file.robot'
parse_robot_file(file_path)Editor is loading...
Leave a Comment