0
down vote
favorite
I want to select a checkbox from a list of fruit names .
Eg .
1.Apple [
]
2.Mango [
]
3.Banana [
]
This entire one row is in one relative layout , then text view and checkbox .
Relative layout[Parent]
1. //android.widget.TextView[@text='Mango']
2. //android.widget.CheckBox[@text='liked']
Now i have written function for selecting any fruit by clicking on checkbox , but my xpath is not returning any element.
public static void likeFruit(String fruitName){
driver.findElement(By.xpath("//android.widget.TextView[@text='"+fruitName+"']/following-sibling::android.widget.CheckBox[@text='liked']")).click();
}
I have tried below xpath as well , nothing is working .Am i doing anything wrong?
1.//android.widget.TextView[@text='"+fruitName+"']/../android.widget.CheckBox[@text='liked'] 2.//android.widget.TextView[@text='"+fruitName+"']/following-sibling::*[1]