集成测试HTML特殊字符 [英] Integration Testing HTML Special Characters
问题描述
我的有问题的测试如下所示:
contextcast a vote,js:true do do $ b之前的
$ b sign_in user
click_link'✔'
sleep 0.2
end
it {should have_content(Vote cast!)}
结束
我得到的失败消息是(可预测的):
失败/错误:click_linkraw('✔')
Capybara :: ElementNotFound:
无法找到链接 raw('✔')
非常感谢您的帮助。
Capybara没有看到HTML,它通过DOM运行,然后看到这些东西编码的实际值。您必须将原始代码作为包含代码点本身的UTF- {8,16}字符串发送。
大多数语言都会显示HTML' ✔'
作为\\\က4
,所以试试。 Kind of a strange one, but in my views I have a tick (✔) and a cross (×) used as links (in lieu of images). Is there any way of finding these elements and testing them using RSpec and Capybara-webkit, or should I try and target say the title attribute instead and ignore this route?
My test in question looks like this:
context "casting a vote", js: true do
before do
sign_in user
click_link '✔'
sleep 0.2
end
it { should have_content("Vote cast!") }
end
The failure message I get is (predictably):
Failure/Error: click_link "raw('✔')"
Capybara::ElementNotFound:
Unable to find link "raw('✔')"
Thanks in advance for your help.
Capybara doesn't see the HTML, it runs thru the DOM, which then sees the actual values those things encode. You must send the raw code as a UTF-{8,16} string containing the code point itself.
Most languages would present an HTML '✔'
as "\u10004"
, so try that.
这篇关于集成测试HTML特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!