1
我正在研究一个应用程序,其中文本有条件地出现在::before
伪元素的内容属性中并呈现在页面上。代码更改导致此重要文本意外消失后,我希望能够编写能够在错误再次发生时捕获错误的测试,但是存在挑战伪选择器内容的挑战。我正在寻找类似的东西:水豚:测试CSS中的内容PsuedoElements
#scss
.content-div {
&.condition-true {
&:before {
content: "conditional text";
}
}
}
#coffeescript
if @someCondition
$('content-div').addClass('condition-true')
else
$('content-div').removeClass('condition-true')
#spec
context "when true" do
it "should have the conditional text" do
# do thing that makes it true
expect(page).to have_content("conditional text")
end
end
解决方案不是那么容易,我想我会在这里分享,让别人评论,或提供其他解决方案。
我使用的是水豚2.3.0和Poltergeist 1.5.1。