【发布时间】:2015-07-23 20:11:27
【问题描述】:
如何拍摄远程机器的屏幕截图。机器人框架在主机上运行。被测系统是一台远程机器。我曾尝试使用 Robot Framework 本身提供的远程服务器,但关键字“Take Screenshot”正在截取主机而不是远程桌面。
我能够使用用户定义的关键字成功获取远程桌面的屏幕表,该关键字又使用第三方工具 screenshot.exe,如下所述...我的偏好是使用内置关键字“截屏”
“远程截图”是我使用的用户定义关键字。该关键字又使用第三方工具 screenshot.exe。
下面给出了相应的python脚本和机器人框架脚本。下面是运行在远程服务器上的python脚本,作为先决条件,这个脚本需要先在远程服务器上启动,然后启动机器人框架。
#begin python script
import subprocess
class ExampleRemoteLibrary(object):
"""Example library to be used with Robot Framework's remote server.
"""
def remote_screenshot(self):
subprocess.call([r'C:\rg\screenshot.exe','-o',r'C:\rg\screenshot.png'], shell = True)
if __name__ == '__main__':
from robotremoteserver import RobotRemoteServer
RobotRemoteServer(ExampleRemoteLibrary(), host = 'xx.xx.xx.xx')
#end python script
以下是机器人框架脚本。
#begin script
*** Settings ***
Library Remote http://${ADDRESS}:${PORT}
Library Screenshot
*** Variables ***
${ADDRESS} xx.xx.xx.xx
${PORT} 8270
*** Test Cases ***
Take Screenshot
Remote Screenshot
#end script
【问题讨论】:
标签: robotframework