在目标机器上装好Python,RF以及你需要的库,比如你在远程机器上需要运行Selenium2Library和AutoItLibrary这两个库,写一个简易的server脚本mysrv.py,然后在远程机器上打开cmd窗口运行 python mysrv.py 10.22.33.44 8270,如果显示Robot Framework remote server at 10.22.33.44:8270 starting.就说明启动监听服务了。然后在本地RF上加载远程库http://10.22.33.44:8270并取个短的别名myremote: Library | Remote | http://10.22.33.44:8270 | WITH NAME | myremote,加载之后如果显示为黑色而不是红色,说明远程库连接成功。接着就可以在本地RF运行远程Selenium2Library和AutoItLibrary的关键字了(如果本地也运行这俩库,那么记得关键字加前缀指明本地还是远程,比如myremote.Open Browser是远程执行,而Selenium2Library.Open Browser则是本地执行)。
附注mysrv.py代码(Xiaoping原创)
from Selenium2Library import Selenium2Library
from AutoItLibrary import AutoItLibrary
import sys
class MyRemote(Selenium2Library,AutoItLibrary):
def __init__(self):
Selenium2Library.__init__(self)
AutoItLibrary.__init__(self)
def print_message(self,message):
print message
if __name__ == '__main__':
from robotremoteserver import RobotRemoteServer
RobotRemoteServer(MyRemote(), *sys.argv[1:])