Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Get child element from complicated xpath

So I have some complicated situation in the DOM where I need to create XPath and get its child element. I have the following XPath

((//p[contains(text(),'" + read_contract_title() + "')]/parent::div/parent::div)[2]//button)[2]

The above is basically a … more options button, that I need to click and then click the child element inside of it.

How do I get about getting the child element (button) inside the above XPath?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Looking forward to your help and reply.

>Solution :

In case parent element can be located with this XPath

"((//p[contains(text(),'" + read_contract_title() + "')]/parent::div/parent::div)[2]//button)[2]"

The button element inside it could be simply located with

"((//p[contains(text(),'" + read_contract_title() + "')]/parent::div/parent::div)[2]//button)[2]//button"

In case this is the only button element inside that parent element

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading