【问题标题】:APPIUM iOS 13 & Above: XCUIElementTypeTextField "Value" attribute shows ”OBJ" as supposed to Actual ValueAPPIUM iOS 13 及更高版本:XCUIElementTypeTextField“值”属性显示“OBJ”,如实际值一样
【发布时间】:2020-08-23 09:32:00
【问题描述】:

问题:对于“XCUIElementTypeTextField”元素(在 iOS 13 及更高版本上),当我尝试 Element.GetAttribute("value" )我得到“”。 请查看附件截图和页面来源

我试图获取页面源,甚至页面源不包含“XCUIElementTypeTextField”的值。

但是,当我在具有 12.4.1 操作系统的设备上尝试时,它工作得非常好,并在检查器和页面源中显示值。

我想知道是否有人面临同样的问题?

配置: * 出现问题的 Appium 版本(或 git 修订版):1.17.0 * 用于运行 Appium 的桌面操作系统/版本:macOS Catalina,10.15.4 * Npm 或 Yarn 包管理器: * 移动平台/测试版本:iOS * 真实设备或模拟器/模拟器:真实设备(iPhone X 13.4.1) * Java 客户端:7.3.0 * Xcode:11.4 * 设备操作系统:13.4.1

Appium Inspector Screenshot

页面源代码段:

                            </XCUIElementTypeStaticText>
                          </XCUIElementTypeOther>
                          <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" x="16" y="159" width="343" height="75">
                            **<XCUIElementTypeTextField type="XCUIElementTypeTextField" enabled="true" visible="true" x="16" y="161" width="343" height="53" label="" value="">
                            </XCUIElementTypeTextField>**
                            <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" x="28" y="159" width="50" height="30" name="Username" label="Username">
                              <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" enabled="true" visible="true" x="28" y="167" width="50" height="14" name="Username" label="Username" value="Username">
                              </XCUIElementTypeStaticText>
                            </XCUIElementTypeOther>
                          </XCUIElementTypeOther>
                          <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" x="16" y="232" width="343" height="75">
                            <XCUIElementTypeSecureTextField type="XCUIElementTypeSecureTextField" enabled="true" visible="true" x="16" y="234" width="343" height="53" label="" value=" ">
                            </XCUIElementTypeSecureTextField>
                            <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" x="28" y="232" width="49" height="30" name="Password" label="Password">
                              <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" enabled="true" visible="true" x="28" y="240" width="49" height="14" name="Password" label="Password" value="Password">

【问题讨论】:

    标签: ios13 appium-ios xcuitest appium-desktop


    【解决方案1】:

    我遇到了类似的问题。与 iOS 12 相比,iOS 13 添加了多余的 XCUIElementTypeOther 元素,这些元素改变了路径。

    为了在我的用例中解决这个问题,我为元素添加了一个唯一标识符以便直接访问(更快的查找),并且在无法使用唯一标识符的情况下(例如 WebView),我将选择器更改为首先依赖匹配。

    例如在 Appium 1.17.0 下:

    //XCUIElementTypeTextField[@name="foo"] 用于直接查找单个项目。

    //XCUIElementTypeWebView 用于查找所有多重匹配。

    假设屏幕上只有一个 WebView,在 iOS 12 上,通用查找会产生一个项目,而在 iOS 13 上它会产生 3 个(相互嵌套)。谢天谢地 capabilities.useFirstMatch 将其解析为 1。

    【讨论】:

    • //XCUIElementTypeTextField 方法是我使用 iOS 14 和 xcode 12.5+ 组合的方法
    猜你喜欢
    • 1970-01-01
    • 2020-01-06
    • 2020-04-05
    • 2020-04-15
    • 2021-03-07
    • 1970-01-01
    • 1970-01-01
    • 2014-06-25
    • 1970-01-01
    相关资源
    最近更新 更多