sajczix
sajczix

Reputation: 13

Get XPath of parent

here's code:

<div class="x-form-item " tabindex="-1" role="presentation">
    <label class="x-form-item-label" style="width:180px;" for="x-auto-4005-input">Amount split option:</label>
    <div id="x-form-el-x-auto-4005" class="x-form-element x-form-el-x-auto-4005" style="padding-left:185px" role="presentation">
        <div id="x-auto-4005" class=" x-form-field-wrap x-component x-trigger-wrap-focus" role="combobox" style="width: 240px;">

I would like to access element with id "x-auto-4005", but without using this id. I can see that label element has identifier "Amount split option". How can I access my element using the label? I guess I would have to get XPATH of parent of all the elements?

Upvotes: 1

Views: 64

Answers (1)

JRodDynamite
JRodDynamite

Reputation: 12623

You can try the following xpath:

"//label[text()='Amount split option:']/following::div[2]"

Upvotes: 1

Related Questions