Home > Net >  Get child element from complicated xpath
Get child element from complicated xpath

Time:03-23

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?

Looking forward to your help and reply.

CodePudding user response:

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

  • Related