2015-05-27 124 views
0

任何人都可以提出在水豚页面上寻找斜体的最佳方法。我有一项功能测试,可以在页面内搜索特定的文本。本文以斜体显示,也与页面上其他所有内容不同。我认为寻找斜体将优于搜索颜色值,但我不确定如何做。用水豚测试斜体

<div class="text-control"> 
    <p class="body">Test text is here and then<i>italics</i> are there</p> 
</div> 

的功能测试如下记载:

Then(/^the word should be highlighted in the example sentence$/) do 
end 

回答

1

这听起来像只需要检查句话,p元素,包含了一句话,i元素。要做到这一点,你可以这样做:

# Get the element containing the sentence 
sentence_element = find('p.body') 

# Check that the sentence includes the italics element with a specific text 
expect(sentence_element).to have_css('i', text: 'italics') 
0

断言文本中存在的特定元素,听起来很有道理......你可以做到这一点使用贾斯汀暗示...

测试文本是在斜体......这不是您想要在此测试层中添加的测试或实际上在任何层中添加的测试...