假设您在windows平台上,并且您希望运行的robot文件位于其他目录中
您可以使用子流程模块为您完成下面提到的任务from subprocess import Popen
from subprocess import Popen, CREATE_NEW_CONSOLE,PIPE,STDOUT
import platform
class Server:
def __init__(self):
pass
def run_robotfiles(self,terminal,command1):
if platform.system()=='Windows':
self.terminal=terminal
self.command1=command1
self.command_server1=self.terminal+' '+self.command1
self.server1_start=Popen(self.command_server1,creationflags=CREATE_NEW_CONSOLE)
abc=Server()
#you can give path till the robot file or you can use a batch file
#K option tells cmd to run the command and keep the command window from closing. You may use /C instead to close the command window after the command finishes.
abc.run_robotfiles('cmd','/K pybot D:\Users\process.robot')