[英]How can I find elements for native android app on Windows as Windows Appium inspector doesn't work?
[英]How can I find a NativeScript TextField with Appium on Android?
我正在嘗試使用nativescript-dev-appium設置自動化的e2e測試。 通過Android上的Appium運行NativeScript應用程序時,我不知道如何找到TextField。 我正在使用tns-core-modules v5.2.1和nativescript-angular 7.0.2。
我可以找到的唯一的NativeScript元素屬性似乎是用於自動化測試以找到元素的屬性是automationText
。 在iOS上設置automationText
時,可以使用Appium驅動程序的driver.findElementByAutomationId
或driver.findElementByAutomationText
查找文本字段。 但是,在Android上,這些方法都不返回正確的元素。 findElementByAutomationId
根本不起作用(我認為自動化ID可能是特定於iOS的),並且findElementByAutomationText
返回的標簽位於我的TextField旁邊,而不是TextField本身。
我的實際視圖中有很多TextField,但這是基本思想:
<StackLayout>
<Label text="Name"></Label>
<TextField automationText="Name" ...></TextField>
</StackLayout>
然后,在我的e2e測試中,我想這樣做
const nameInput = await driver.findElementByAutomationText("Name") // Returns the Label and not the TextField
由於在Android上findElementByAutomationText
似乎是按文本而不是按AutomationText搜索元素,因此在運行測試時找到TextField的最可靠方法是什么? 最好是,我想要一個跨平台的解決方案,所以我不必在iOS和Android上使用不同的查找策略。
您為什么不能要求開發人員為給定的組件設置ID定位器,並在下面的代碼段中使用。
await driver.findElementById("#name");
我看到您的組件沒有定位器,這也是可靠的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.