Top xpath loactors

Technical
Medium
Infosys
141K views

Direct Answer

Question about XPath locators used in test automation.

Why Interviewers Ask This

XPath is a critical tool for locating elements in web automation. The interviewer wants to assess the candidate's proficiency in writing efficient and reliable selectors for testing.

How to Answer This Question

List common XPath strategies like by ID, name, text, and axis-based navigation. Explain the difference between absolute and relative XPath. Recommend using relative XPath for better stability. Mention best practices for avoiding brittle locators.

Key Points to Cover

  • Attribute-based locators
  • Relative XPath
  • Axis navigation
  • Best practices

Sample Answer

Top XPath locators include using attributes like id, name, and class, as well as text content. Relative XPath expressions, such as //div[@id='login'] or //button[text()='Submit'], are preferred over absolute paths for st…

Common Mistakes to Avoid

  • Using absolute paths
  • Relying on indexes
  • Ignoring dynamic IDs

Sound confident on this question in 5 minutes

Answer once and get a 30-second AI critique of your structure, content, and delivery. First attempt is free — no signup needed.

Try it free

Related Interview Questions

Browse all 180 Technical questionsBrowse all 149 Infosys questions