Skip to content
CodeKruPro

Find the input next to a label with an XPath axis

QuizMediumAsked in: Accenture, Infosys

The page has <label for="email">Email</label><input id="email"> inside one form. Which XPath finds the input that comes right after the label?

  • //label[text()='Email']/following-sibling::input[1]
  • //label[text()='Email']/parent::input
  • //input[text()='Email']
  • //label/input[@text='Email']

This question is part of Pro+

Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.

See Pro+

Already have Pro+? Sign in