An SDET's thoughts on test automation, TDD, BDD, ruby, CI, devops and software development

XPath Queries in Chrome

Running xpath queries shouldn’t be hard. It used to be that you’d have to install plugins into whatever browser you were using. They were often clumsy and always buggy. And, even though querying using CSS selectors has grown more popular in the automated-acceptance-web-test world, there are still sometimes that xpath is the only option.

It turns out that Chrome has built in support for xpath queries in its dev tools. Simply run the following in the console tab:


For example, run the following command in the console when the page is loaded:


Here’s a screenshot of $x("your_xpath") in action:

Hope that helps!