【问题标题】:Unable to locate element on a Dialog in Android无法在 Android 的 Dialog 上找到元素
【发布时间】:2015-05-24 16:59:48
【问题描述】:

Android 中的应用有一个弹出的登录对话框。 我需要在 Appium 中测试它(使用 Selenium java) 当我单击登录按钮时,它将打开对话框,但 selenium 命令无法找到我需要输入 emailpassword 的文本框>.

driver.findElement(By.id("login_sign_in_button")).click(); // works fine
driver.findElement(By.id("email_address")).sendKeys("abc@xxx.com");// unable to locate the element**

【问题讨论】:

  • 究竟是什么错误?喜欢堆栈跟踪?
  • Selenium 给我这个错误:“线程“主”org.openqa.selenium.NoSuchElementException 中的异常:使用给定的搜索参数无法在页面上找到一个元素。(警告:服务器没有不提供任何堆栈跟踪信息)”
  • 你能得到html 并提供吗?
  • > info: [debug] [BOOTSTRAP] [debug] 使用:UiSelector[INSTANCE=0, RESOURCE_ID=com.abc.abc/email_address] > info: [debug] [BOOTSTRAP] [debug]使用:UiSelector[DESCRIPTION=email_address, INSTANCE=0] > info: [debug] [BOOTSTRAP] [debug] 未能定位元素。清除辅助功能缓存并重试。 > info: [debug] [BOOTSTRAP] [debug] 使用带有 contextId 的 ID 查找 email_address:multiple: false > info: [debug] [BOOTSTRAP] [debug] 返回结果:{"value":"No element found","状态”:7}
  • 你的意思是对话框的xml?

标签: android selenium android-alertdialog appium


【解决方案1】:

您可能需要在对话框出现之前添加一些等待。请尝试以下代码

WebDriverWait driverWait = new WebDriverWait(driver, 30);
driverWait.until(ExpectedConditions.visibilityOfElementLocated(By.Id("email_address")));

之前

driver.findElement(By.id("email_address")).sendKeys("abc@xxx.com");

【讨论】:

    猜你喜欢
    • 2018-08-01
    • 2020-02-04
    • 2012-08-11
    • 2014-07-13
    • 1970-01-01
    • 2020-05-20
    • 1970-01-01
    • 2015-06-22
    • 2017-10-03
    相关资源
    最近更新 更多