Reputation: 1
I want to click the country on Country code page while registering.
However, I have tried every findbyElement
method i can to click the element, but it always result in
No Such Element Error.
Can anybody please help me in that.
PS: I have used xpath
, ID
and List
. But its not working, If you have any idea from the tried methods, please do share as I am new to Appium and can be wrong.
Thanks
Dumpfile screenshot DumpfileforUIautomator
Upvotes: 0
Views: 1647
Reputation: 2838
Based on the screenshot of the checkbox control, it looks like the resource id is -not- unique, which is probably why the element is designated as NAF (not accessible friendly).
Therefore, I would instead access the textview immediately following it, then use preceding-sibling to access the desired checkbox:
driver.findElement(By.xpath("//android.widget.TextView[@text='+91']/preceding-sibling::android.widget.CheckBox"))
Upvotes: 0
Reputation: 1481
The issue is that You are locating wrong control, You should be targeting radio-button/check-box control, not label next to it.
Try locating that control, not label.
driver.findElement(By.className("CheckBox Locator")).click();
try one of this solutions:
List<MobileElements> listElement = driver.findElements(By.id("com.bondevalue.BondEvalue:id/country_rb"))
System.out.println("Size: " + listElement.size());
and then check out if this is returning any result. If it does than elements are found.
Than You have to find parent layout com.bondevalue.BondEvalue:id/listlayout
and find every in list, and find child elements (checkboxes) like shown, and when found desired element by text (com.bondevalue.BondEvalue:id/labelk
) then click on check box (com.bondevalue.BondEvalue:id/country_rb
).
Hope this helps...
Upvotes: 0
Reputation: 882
You can try by using xpath
or name
driver.findElement(By.xpath("//android.widget.TextView[@text='India']")).click();
or
driver.findElement(By.Name("India")).click();
or
driver.findElement(new By.ByName("India")).click();
or
driver.findElement(By.xpath("//android.widget.TextView[@index='2']")).click();
Upvotes: 1