Search code examples
seleniumxpathrelative-locators

How to write following sibling CSS/Xpath expression of username field?


HTML Code:

<form autocomplete="on" xpath="1">
  <div class="IiD88i _351hSN">
     <input  class="_2IX_2- VJZDxU" autocomplete="off" type="text" value="">
     <span class="_36T8XR"></span>

I can write this one : //input[@type='text']

enter image description here

But how to write it in "following sibling" CSS/xpath of the above code?


Solution

  • If you want to fetch input node based on its sibling, try:

    //label[.='Enter Email/Mobile number']/preceding-sibling::input