PageFactory使用Appium测试Windows桌面应用程序

时间:2020-07-20 07:19:54

标签: java appium desktop-application winappdriver

我曾经在Appium中测试Android和IOS,但现在进行了一些Windows PC应用程序自动化,并希望使用与移动应用程序中相同的设计模式-页面对象。
对于我应用程序中的每个元素,我都有automationId值,我正尝试使用WindowsFindBy注释对其进行分配,如下所示:

@WindowsFindBy(id = "textBoxDirectory")
WebElement textBoxDirectory;

我尝试使用可访问性值,但得到的结果与驱动程序日志中看到的结果相同。

@WindowsFindBy(accessibility = "textBoxDirectory")
WebElement textBoxDirectory;

页面构造函数执行以下操作:

public PageObject(WindowsDriver driver) {
    this.driver = driver;
    PageFactory.initElements(driver, this);
}

在WinAppDriver日志中,我看到驱动程序试图按名称而不是按 ID 来按预期方式查找元素:

{"using":"name","value":"textBoxDirectory"}
HTTP/1.1 404 Not Found
Content-Length: 139
Content-Type: application/json

{"status":7,"value":{"error":"no such element","message":"An element could not be located on the page using the given search parameters."}}

当我尝试以原始方式访问字段时:textBoxDirectory = driver.findElementByAccessibilityId("textBoxDirectory");我成功地获得了元素。
非常感谢您的帮助!

0 个答案:

没有答案