我们可以在appium找到的元素通过ID [英] Can we find element by ID in appium
问题描述
下面的链接中提到,我们可以通过给ID查找元素......但我无法找到它。
following link mentions that we can find element by giving id... but i am unable to find it.
<一个href="https://github.com/appium/appium/blob/master/docs/finding-elements.md">https://github.com/appium/appium/blob/master/docs/finding-elements.md
按名找到(即文本,标签,或开发人员生成的ID又名元素的accessibilityIdentifier')
find by "name" (i.e., the text, label, or developer-generated ID a.k.a 'accessibilityIdentifier' of an element)
我尝试以下code:
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
编写如下code -
write the following code -
driver.findElement(By.id("com.example.testapp:id/txtLogin")).sendKeys("abc");
这篇关于我们可以在appium找到的元素通过ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!