[rspec-users] Testing selector order

Andrew Premdas apremdas at gmail.com
Thu Mar 1 21:31:52 UTC 2012

On 1 March 2012 16:43, Mike Kim <fourcatrails at gmail.com> wrote:

> Could someone point me to a reference that explains how I would test
> the order of elements on an HTML page?
> For example, in RSpec I would like to verify that the content of one
> <p> element appears before the content of another.
> response.should have_selector("p", :content => "Should appear first")
> response.should have_selector("p", :content => "Should appear second")
> The two lines above test that the 2 contents appear, but I don't know
> how to test that the first content appears before the second.
> Thanks
> Mike
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

Have a look at sibling in x-path specification to do it correctly. As a
hack Capybara's all method in practice will return the paragraphs in order
(but this isn't guaranteed by specification).



Andrew Premdas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20120301/18582b8a/attachment.html>

More information about the rspec-users mailing list