How to get following sibling using xpath?



  • I want to target a textbox that appears in a list that comes after the label "First Name" and send a first name to the box, but can't seem to be able to target the textBox

    <li class="WPTO WKVO" role="presentation" data-automation-id="formLabelRequired">
    
    <div class="WBUO WETO WDUO">
    <label id="56$551056--uid24-formLabel" data-automation-id="formLabel" for="56$551056--uid24-input">First Name</label>
    <div class="WEUO wd-c8594868-6b31-4526-9dda-7d146648964b" aria-hidden="true">First Name</div>
    </div>
    
    <div data-automation-id="decorationWrapper" id="56$551056" class="WFUO">
    <div class="WICJ">
    <div class="WMP2 textInput WLP2 WJ5" data-automation-id="textInput" id="56$551056--uid24" data-metadata-id="56$551056" style="visibility: visible;">
    <input type="text" class="gwt-TextBox WEQ2" data-automation-id="textInputBox" tabindex="0" role="textbox" id="56$551056--uid24-input" aria-invalid="false" aria-required="true">
    </div>
    </div>
    </div>
    
    </li>
    


  • Try with below two Xpaths

    1. //label[text()='First Name']//parent::div/following-sibling::div
    2. //label[text()='First Name']//parent::div/following-sibling::div//input
    

Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2