I agree with most people that would say the least efficient way to locate webElements in WebDriver scripts is to use 'xpaths', however I have found there are some circumstances where, when constructed in an effective way, using xpath can add value to your test by combining location and assertion into one.

An example of this can be seen on my WebDriver test page, there is a table with various rows, 2 of them have the same background colour, green. If you wanted to verify in your test that a row existed in the table with a green background and contained the name 'Mark' for example, then you could write a couple of assertions, one to validate the background colour of the row and one to validate the name is 'Mark' in that row. Or you could use a well constructed xpath to combine them, let's take a look at how:

We know we want to locate a table row (<tr>), it should have a background colour of green (or in this case class="success") and that the text is 'Mark'.

The xpath needed to locate this webElement is: //tr[@class="success"]/td[contains(.,"Mark")]

By using this xpath we can write our WebDriver assertion to just check this webElement is displayed on the page and we have actually verifed 3 things; the webElement is displayed, the background colour is green and the text is 'Mark' - using TestNG assertions it would look similar to this:

assertTrue("WebElement cannot be found.",
driver.findElement(By.xpath('//tr[@class="success"]/td[contains(.,"Mark")]').isDisplayed()));