How to use following sibilings using a list web element?

Hi All…

I would be need to select the element from a Linear layout after verifying one element in the list view…

There is a list of Linear Layout, and one of which i need to verify the respective date is displayed and if so then i need to select the respective proceed button…

Please have a look in to the code…

@FindBy(how = How.CLASS_NAME, using ="android.widget.LinearLayout")
private WebElement partialEnrollment_List;

try
{
List list = partialEnrollment_List.findElements(By.id(“com.fi.kyc:id/date”));

	for(int i=0;i<list.size();i++)
	{
		
		System.out.println("List of dates "+list.get(i).getText());
		Thread.sleep(500);
		if(list.get(i).getText().equals(date))
		{
			System.out.println("True");
			list.get(i).findElement(By.id("com.fi.kyc:id/view")).click();
		}	break;
	}  

here the “com.fi.kyc:id/view”)" is the id of proceed button as you can seen in the attached screen shot…
but clicking on proceed button is not happening as it throws “No such element exception”…

Can anyone please give me an idea to select the respective element “Proceed”

Please look in to the screen shot attached

Appreciate for your help…

String text = "text you are looking for";
WebElement parent = ((AndroidDriver) driver).findElement(MobileBy.xpath("//*[@text = '" + text + "']/.."));
parent.findElement(MobileBy.className("android.widget.Button")).click()

Aleksei, I’m not sure if that will work, as there are 2 buttons with that class name and it could throw a non-unique/“more then 1” type exception. You can also try a single xpath statement, something like…

//android.widget.TextView[@text='<Your date string>']/following-sibling::android.widget.Button[@text='Proceed']