Created
July 14, 2010 01:36
-
-
Save chrisdarroch/474870 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You can try running these in FireBug console on the above html file. | |
$x("//li[@id='two']//preceding::li") | |
// => [ li#first, li#second, li#third, li#one ] | |
$x("//li[@id='two']//preceding-sibling::li") | |
// => [ li#one ] | |
$x("//ul[@class='outside']/li[1]//preceding::li") | |
// => [li#first, li#second, li#third, li#fourth, li#one, li#two, li#three, li#fifth] | |
$x("//ul[@class='outside']/preceding::li[1]") | |
// => [li#fifth] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<ol> | |
<li id="first">Number one</li> | |
<li id="second">Number two</li> | |
<li id="third">Third time's a charm</li> | |
<li id="fourth"> | |
<ul> | |
<li id="one">Sub one</li> | |
<li id="two">Second sub</li> | |
<li id="three">Third and final sub</li> | |
</ul> | |
</li> | |
<li id="fifth">One more for good measure</li> | |
</ol> | |
<ul class="outside"> | |
<li>Another list item.</li> | |
<li>Just one more...</li> | |
</ul> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Running a custom XPath in capybara involves the following | |
# (assuming you're in a step_definition file, thus your execution context is Cucumber::Rails::World | |
page.has_xpath?('//xpath/to/element') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment