如何使用Capybara在元素中获取HTML? [英] How do I get the HTML in an element using Capybara?
本文介绍了如何使用Capybara在元素中获取HTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在写一个黄瓜测试,我想在一个元素中获取HTML。
例如:
$ b $
in $ table $ do
find('// tr [2] // td [7] ]')。text.should ==这些是注释
#我想要这样的东西(没有html方法)
find('// tr [2 ] // td [7]')。html.should ==这些是& lt; b& gt;注释& lt; / b& gt;
end
任何人都知道如何做?
<如果你使用的是Selenium,你可以调用Selenium的属性 innerHTML
在方括号中: find('// tr [2] // td [7]')['innerHTML']
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 comments"
# I want something like this (there is no "html" method)
find('//tr[2]//td[7]').html.should == "these are the <b>comments</b>"
end
Anyone know how to do this?
解决方案 If you are using Selenium, you can call Selenium's attribute innerHTML
in square brackets:
find('//tr[2]//td[7]')['innerHTML']
这篇关于如何使用Capybara在元素中获取HTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文