无法找到应用登录的定位器 - Xamarin.UI 自动化测试

问题描述

随着我们的应用登录页面从 ADAL 库升级到 MSAL 库。我们无法通过自动化找到用于登录选项的定位器(自动化 ID)。

我们试过了

Dim FiletoOpen As Variant
dim tempFile as workbook
dim tempWs as worksheet
dim thisWs as worksheet

Application.ScreenUpdating = False
set thisWs = ThisWorkbook.Worksheets("Sheet1")

FiletoOpen = Application.GetopenFilename _
(Title:="Please choose a Excel File to Open",_
FileFilter:="Excel Files *.xlsx(*.xlsx),")
If VarType(FiletoOpen) = vbBoolean Then
   MsgBox "No file selected",vbExclamation,"Sorry!"
   Exit Sub
End If
Debug.Assert VarType(FiletoOpen) = vbString
set tempFile =Workbooks.Open(FiletoOpen)
set tempWs  = tempFile.worksheets(1)

tempWs  .cells.copy thisWs.Range("A1")
tempFile .close 

set tempFile = nothing
set tempWs  = nothing

Application.ScreenUpdating = true

但该值未输入用户名字段并低于异常异常:System.Exception:文本输入不可见键盘。 在 Xamarin.UITest.iOS.iOSApp+c__displayClass19_0.b__0 () [0x0002b] 在 :0

识别用户名字段的任何建议。

解决方法

您需要先将 Xamarin.UITest 添加到 Xamarin.Forms 解决方案中。

并为条目设置 AutomationId

xml:

 <Entry AutomationId="UserID" />
        <Entry AutomationId="Password" />

UITest:

 [Test]
    public void test3()
    {

        app.EnterText("UserID","5");//UserID is 5
        app.PressEnter();
        app.EnterText("Password","123456");//password is 123456
        app.PressEnter();

    }

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...