Hello Testers – as many readers are probably aware, both FirefoxFirebug and Chrome have a console panel for evaluating JavaScript, testing XPath expressions / CSS selectors (i.e. inspecting the DOM), and analyzing the HTML. To learn more about the Console, check out the following:

Google: http://code.google.com/chrome/devtools/docs/console.html

Firebug: http://getfirebug.com/commandline

The syntax used for inspecting the DOM of XPath and CSS is slightly different.

XPath syntax:


CSS syntax:


Given the code block:

<div><a href=”https://www.google.com/”>Google</a> , <a href=”https://www.amazon.com/”>Amazon</a></div>

The HTML output is:


Some associated XPath and CSS selectors are:

$x(“//div[starts-with(@class,'element')]//a[contains(@href, 'google.com')]“)

$x("//a[contains(text(), 'Google')]")
$x("//div[@class='element-block']//a[last()]") selects Amazon
$x("//div[@class='element-block']//a[2]") selects Amazon
$$("a[href*='google']") * = Contains
$$("a[href^='https://www.google']") ^ = Begins With
$$("a[href$='.com/']") $ = Ends With
$$("div.element-block a[href*='google'] + a") selects Amazon