PageFactory 使用 Appium 测试 Windows 桌面应用

问题描述 投票:0回答:1

我习惯在Appium中测试Android和IOS,但现在做一些Windows PC应用程序自动化,想使用与移动应用程序相同的设计模式——Page Object。
对于我的应用程序中的每个元素,我都有

automationId
值,我正在尝试使用
WindowsFindBy
annoatation 分配它,如下所示:

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

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

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

页面构造函数这样做:

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

在 WinAppDriver 日志中,我看到驱动程序正试图通过 name 而不是预期的 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");
我成功获得了元素。
非常感谢您的帮助!

java appium desktop-application winappdriver
1个回答
-1
投票

你能找到答案吗?非常感兴趣,因为我正在考虑沿着相同的路径使用 AutomationID 作为 Windows 桌面应用程序的 UI 元素。

© www.soinside.com 2019 - 2024. All rights reserved.