简体   繁体   中英

Python- Robot Framework Rebot Using List

I am attempting to use a list of output files to merge them into one single file. I need to use a list to store these different files but when I call the rebot function using the list I get the following error,

[ ERROR ] Reading XML source '<in-memory file>' failed: TypeError: expected str, bytes or os.PathLike object, not list

I have tried converting the list to a string value but that will read the list as one long string, which is not what I want. Does anyone know how I can use a list and the rebot function? Here is my example code:

import robot
list_1 = ["output1.xml", "output2.xml"]
robot.rebot(list_1)

I was able to find a simple solution by using robot.rebot_cli() instead of robot.rebot() . The answer to my example code shown above is as follows. Also, (a side note) running rebot_cli will terminate the program once it is finished merging the files together. To prevent this from happening I included exit=False :

import robot
list_1 = ["output1.xml", "output2.xml"]
robot.rebot_cli(list_1,exit=False)

From the Robot Framework API guide for Rebot the following example is given for this particular question:

from robot import rebot

with open('stdout.txt', 'w') as stdout:
    rebot('o1.xml', 'o2.xml', name='Example', log=None, stdout=stdout)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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