我们可以在appium中通过ID查找元素吗 [英] Can we find element by ID in appium

查看:24
本文介绍了我们可以在appium中通过ID查找元素吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下链接提到我们可以通过提供 id 来找到元素...但我找不到它.

following link mentions that we can find element by giving id... but i am unable to find it.

https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/finding-elements.md

按名称"查找(即文本、标签或开发人员生成的 ID,也就是元素的accessibilityIdentifier")

find by "name" (i.e., the text, label, or developer-generated ID a.k.a 'accessibilityIdentifier' of an element)

我尝试了以下代码:

WebElement el = driver.findElement(By.name("txtLogin"));

其中 txtLogin 是登录按钮的 id

where txtLogin is id for login button

它给出以下异常:

org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)

请任何人解释在appium中查找元素的所有方法

can please anyone explain what are all the ways there to find elements in appium

推荐答案

您可以使用元素 ID 如下:-

You can use element ID as following:-

包名:com.example.testap

元素 ID:txtLogin

编写如下代码-

 driver.findElement(By.id("com.example.testapp:id/txtLogin")).sendKeys("abc");

这篇关于我们可以在appium中通过ID查找元素吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆