Unable to find element using "text"

Hi,

In the latest version of appium, I cannot use “text” to find an element with xpath.

driver.findElement(By.xpath("//[@class=‘android.view.View’ and ./[@text=‘Everyday Offset’]]")).click();
driver.findElement(By.xpath("//[@class=‘android.view.View’ and ./[@text=‘To:’]]")).click();
driver.findElement(By.xpath("(//[@class=‘android.view.View’ and ./parent::[@class=‘android.view.View’ and ./parent::[@class=‘android.view.View’ and (./preceding-sibling:: | ./following-sibling::)[@text=‘Select Account’]] and (./preceding-sibling:: | ./following-sibling::)[@class=‘android.view.View’]]]/[./[@text=‘A C Green - 138899729’]])[1]")).click();
driver.findElement(By.xpath("//
[@class=‘android.view.View’ and ./[@text=‘Amount:’]]")).click();
driver.findElement(By.xpath("//
[@class=‘android.widget.EditText’ and ./parent::[(./preceding-sibling:: | ./following-sibling::)[@text]]]")).sendKeys(“12.25”);
driver.findElement(By.xpath("//
[@class=‘android.view.View’ and ./[@text=‘Description:’]]")).click();
driver.findElement(By.xpath("//
[@class=‘android.widget.EditText’ and ./parent::[./parent::[./parent::[./parent::[(./preceding-sibling::* | ./following-sibling::)[@text=‘Description:’]]]]]]")).sendKeys(“Test”);
driver.findElement(By.xpath("//
[@text=‘Continue’]")).click();
driver.findElement(By.xpath("//*[@text=‘Make payment’]")).click();

even by classname:
driver.findElement(By.className(“android.widget.Button[@text=‘Everyday Offset’]”)).click();

I’ve tried all the methods I’ve found on google but nothing works, even contains not working.

is text an attribute or a function? Does By.xpath("//[@class=‘android.view.View’ and .//[.=‘Description:’]]") work?

1 Like

Hi @mykola-mokhnach,

It is a text attribute, also, it doesn’t work.

Thanks for the reply.