【问题标题】:info needed on "Take Screenshot" keyword to take screen shot of remote machine“截屏”关键字所需的信息以截取远程机器的屏幕截图
【发布时间】: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


    【解决方案1】:

    我认为你无法按照自己的想法去做。

    标准Take Screenshot 关键字在远程主机上起作用的唯一方法是设置remote library interface,您已经这样做了。在此之后您需要在远程主机上定义一个新的截图关键字,并使用该关键字,您将无法在远程主机上使用本地关键字。

    我可能不会一开始就使用远程库接口,而是安装SSHLibrary 并使用它在远程主机上运行终端命令。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-10
      • 1970-01-01
      • 2021-07-12
      • 2021-06-28
      相关资源
      最近更新 更多