如何在带有换行符的文本中使用期望?

问题描述

我正在使用capybaracucumberwebdriver进行一些自动化测试。

我的目标是知道是否在页面上加载了文本,但是其中有一个css属性white-space会打断文本,并且期望值找不到。

我的代码是这样的。

HTML

<p style="white-space: pre-wrap;">
    Some 
    cool 
    text
</p>

黄瓜。功能

expect(page).to have_selector('p',text: 'Some')
expect(page).to have_selector('p',text: 'cool')
expect(page).to have_selector('p',text: 'text')

我正在寻找类似的东西

#This text will failure in teste
expect(page).to have_selector('p',text: 'Some cool text')

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)