I am testing an app and have a difficulty to click a button which another element contains a text as seen below.
I want to click on "DETAILS" button which has "UPCOMING" word above it.
I have tried to do it but none of it does the job.
First
for booking_card in context.driver.find_element_by_xpath("//*(@class='android.view.ViewGroup')"):
if booking_card.text == "UPCOMING":
context.driver.find_element_by_xpath("//*[contains(@text, 'DETAILS')]").click()
Second
context.driver.find_element_by_xpath("//*[contains(@text, 'UPCOMING')]//*[@text='DETAILS']").click()
Third I tried to find the details button using the parent, sibling and ancestor method but still failed.
//*[@class='android.view.ViewGroup']//*[contains(@text, 'UPCOMING')]/following-sibling::*[contains(@text, 'DETAILS')]
here is the Hierarchy of the elements:

I really appreciate any help, thank you. If there's something else I need to explain, let me know.
