我正在使用 Appium 测试移动应用程序。当我使用 xpath 时它工作正常但我无法处理该应用程序的 ID。
//This is working fine
remoteDriver.findElementByXPath("/linear[1]/window[2]/linear[1]/linear[1]/linear[2]/linear[1]/text[2]").click(); // Click on signIn button
// This doesn't recognize the element
remoteDriver.findElementById("ButtonSignIn").click(); // Click on signIn button
如果有人在 appium 上使用过 id,请分享您的经验。
谢谢
最佳答案
仅适用于 Android API 级别 18 或更高级别 (Jelly Bean) 才能使用 Id。如果您使用 uiautomatorviewer ,那么在 Node Details 中您将看到“resource-id”,它可以很容易地用于自动化应用程序,但相同的 id 不适用于 android API 级别 < 18。解决方法是使用其他元素属性像 - xpath、tagName、className 等。有关更多详细信息,请使用链接 - https://github.com/appium/appium/blob/master/docs/finding-elements.md
关于java - Appium:任何使用元素的 id 来自动化应用程序的工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20783402/