简体   繁体   English

如何使用appium在移动应用程序中找到xpath

[英]How to find xpath in mobile app using appium

I tried using Find element by id but it is not inserting required data. 我尝试按ID使用Find元素,但它没有插入所需的数据。 Then I used Find element by xpath //android.widget.ScrollView[0]/android.widget.RelativeLayout[0]/android.widget.TextView[0]/ndroid.widget.TextView[1]/android.widget.EditText[2]")).sendKeys("Check@localmail.com"); 然后我通过xpath使用Find元素//android.widget.ScrollView[0]/android.widget.RelativeLayout[0]/android.widget.TextView[0]/ndroid.widget.TextView[1]/android.widget.EditText[2]")).sendKeys("Check@localmail.com");

but still it is not working. 但它仍然无法正常工作。 在此输入图像描述

请使用此Xpath,我希望这可以解决您的问题:

By.xpath("//android.widget.EditText[@text='Email ID']")

更好的方法如下 -

driver.findElement(By.xpath("//EditText[contains(@text,'Edit ID')]"));

u can do it in another way ,u know that there are 5 textfields , hence write the code as below. 你可以用另一种方式来做,你知道有5个文本字段,因此编写如下代码。

driver.findelements(By.tagname("textfield")).get(0).sendkeys("abc@gmail.com")); driver.findelements(By.tagname( “文本框”))得到(0).sendkeys( “abc@gmail.com”))。

this means that you are trying to pass the abc@gmail.com value in the first text field "get(0)". 这意味着您尝试在第一个文本字段“get(0)”中传递abc@gmail.com值。

使用contains查找移动应用的xpath

driver.findElement(By.xpath("//android.widget.TextView[contains(@text, 'Call')]")).isDisplayed())

通过使用可用属性 - 索引和类名,您可以尝试使用以下xpath

//android.widget.EditText[@index='2']

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM