如何让 Capybara 找到 HTML 条评论?
How do you make Capybara find an HTML comment?
我希望我的测试能够获得 HTML 评论 HTML 我想在构建水豚时进行测试使用 SimpleNode 的节点似乎已删除所有 HTML 注释。
例如
html = "<div>before <!– check –> after</div>"
node = Capybara::Node::Simple.new(html)
node.native.to_html
# => "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"
\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n<html><body>
<div>before after</div></body></html>\n"
文本部分 before
和 after
已在 HTML 中完全删除。
如何保存它们以便在测试中检测到它们?
HTML 评论需要在
html = "<div>before <!-- check --> after</div>"
node = Capybara::Node::Simple.new(html)
node.native.to_html
=> "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">\n<html><body><div>before <!-- check --> after</div></body></html>\n"
我希望我的测试能够获得 HTML 评论 HTML 我想在构建水豚时进行测试使用 SimpleNode 的节点似乎已删除所有 HTML 注释。
例如
html = "<div>before <!– check –> after</div>"
node = Capybara::Node::Simple.new(html)
node.native.to_html
# => "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"
\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n<html><body>
<div>before after</div></body></html>\n"
文本部分 before
和 after
已在 HTML 中完全删除。
如何保存它们以便在测试中检测到它们?
HTML 评论需要在
html = "<div>before <!-- check --> after</div>"
node = Capybara::Node::Simple.new(html)
node.native.to_html
=> "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">\n<html><body><div>before <!-- check --> after</div></body></html>\n"