使用 Id 查找元素无法定位元素

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

我正在执行一些 UI 自动化并使用 Appium Inspector 检查 Microsoft 登录凭据屏幕的用户名文本字段。 通过 Id 引用元素时出现错误:“使用给定的搜索参数无法在页面上找到元素。”

我正在为 Appium 2.0 使用 Appium Inspector,根据推荐的选择器,我可以使用任一 id xpath 但是,id 在使用 xpath 时给我错误

失败的代码行:

driver.FindElementById("i0116").SendKeys("test");

为什么会这样?

我的环境是:

  • Appium 服务器 2.0
  • Android Studio - 电鳗
  • Windows 10
  • 使用 OpenQA.Selenium.Appium C# 库的 Visual Studio 2022

"desiredCapabilities": {
    "platformName": "Android",
    "appium:automationName": "UIAutomator2",
    "appium:deviceName": "PixelSix",
    "appium:app": "C:\\Users\\slai6\\Downloads\\MyApp.1.apk",
    "appium:platformVersion": "11",
    "appium:ensureWebviewsHavePages": true,
    "appium:nativeWebScreenshot": true,
    "appium:newCommandTimeout": 3600,
    "appium:connectHardwareKeyboard": true
  }

appium appium-android appium-desktop
© www.soinside.com 2019 - 2024. All rights reserved.