尝试针对具有Appium Server的Windows应用程序运行Robot Framework测试用例-可能吗?

问题描述

我正在将Robot Framework与RIDE IDE一起使用。我正在运行一个Appium服务器会话。第一次尝试,我想编写一个Robot Framework测试用例以打开Windows记事本的实例。首先,这是否有可能,还是我被误导了?

Appium

以下是使用的设置:

远程主机:127.0.0.1

远程端口:4723

远程路径:/

SSL:已禁用

“所需功能”的设置由以下JSON表示:

{
    "app": "C:\\Windows\\system32\\notepad.exe"
}

WinAppDriver

它在端口4723上运行。

RIDE IDE

正在执行以下测试用例:

*** Settings ***
Library           AppiumLibrary

*** Test Cases ***
TC0
    Open Application    http://localhost:4723/wd/hub    app=C:\Windows\System32\notepad.exe

这会产生以下错误

[ WARN ] Keyword 'Capture Page Screenshot' Could not be run on failure: No application is open

这可能是什么原因?

编辑:附加信息-执行上述测试用例时,WinAppDriver控制台中将显示以下内容

enter image description here

解决方法

默认情况下,AppiumLibrary将在失败时运行Capture Page Screenshot
AppiumLibrary Documentation

最可能的顺序如下。

  1. 测试用例尝试打开记事本,但失败。
    Open Application http://localhost:4723/wd/hub app=C:\Windows\System32\notepad.exe

  2. 在发生此故障时AppiumLibrary尝试Capture Page Screenshot,但由于步骤1失败以来没有打开的应用程序而失败。

我相信您需要集中精力解决应用无法正常打开的原因。

如果您想抑制这种故障,可以将run_on_failure=No Operation设置为AppiumLibrary在失败时不捕获屏幕,请参见上面的链接文档。

Library AppiumLibrary run_on_failure=No Operation

,

一点关系不大,但我只是想提供一些使用winappdriver和robotframework的技巧,因为那里没有很多简洁的信息。

  1. 我个人发现通过appium运行winappdriver比独立运行winappdriver慢。
  2. 本地主机也比使用127.0.0.1慢,因为您的系统每次必须解析该地址:https://github.com/microsoft/WinAppDriver/issues/1269
  3. AppiumLibrary仍然非常适合移动自动化,因此它缺少桌面自动化中您需要的一些常用功能,例如“拖放”,“将鼠标悬停在元素上”,用于控制驱动程序设置/拆卸的关键字等。 。RobotFramework-Zoomba's DesktopLibrary extends AppiumLibrary and adds a lot of these keywords,如果您愿意尝试的话。关键字文档可在以下位置找到:https://accruent.github.io/robotframework-zoomba/DesktopLibraryDocumentation.html