Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
How do I get the HTML in an element using Capybara?
2 Posts
How do I get the HTML in an element using Capybara?

Try this:

page.has_xpath?("//tr[2]//td[@class='comments' and contains(string(), 'these are the comments')]").should true

I can't figure it out how to access the seventh , so instead I would add it the "comments" class.

I'm writing a cucumber test where I want to get the HTML in an element.

For example:

within 'table' do

# this works
find('//tr[2]//td[7]').text.should == "these are the <b>comments</b>"
# I want something like this (there is no "html" method)
find('//tr[2]//td[7]').html.should == "these are the &lt;b&gt;comments&lt;/b&gt;"

end

Anyone know how to do this?

2 Posts
Login to add your message