检查文本是否为粗体
我正在测试搜索的输出,我想确保我会得到文本并且它会是粗体。 例如,我希望名称包含“ar”。作为输出,我将得到:
但我想确保名称中包含“ar”,但在职位、部门等方面会忽略它。 片段的来源是:
<td style="width: 80%;">
<ul style="font-size: 20px;width: 50%;">
<li><b>Cecil Bonaparte</b></li>
<li style="font-size: 12px;">Software Engineer</li>
<li style="font-size: 12px;">Development</li>
<li style="font-size: 12px;">HQ - CA</li>
<li style="font-size: 12px;">
[email protected] </li>
</ul>
</td>
是否有一个选项可以检查元素是否具有文本并且该文本是否为粗体? 我当前的代码是:
$("[class=odd]").shouldHave(text("char"));
我的游乐场可以在 https://opensource-demo 找到.orangehrmlive.com/index.php/auth/login ,目录选项卡
I am testing the output of a search and I want to be sure that I will get the text and that it would be bold.
For example I want the name to include "ar". As an output I will get:
But I want to be sure that I will have "ar" in name, but will ignore it in position, department, etc.
The source of the fragment is:
<td style="width: 80%;">
<ul style="font-size: 20px;width: 50%;">
<li><b>Cecil Bonaparte</b></li>
<li style="font-size: 12px;">Software Engineer</li>
<li style="font-size: 12px;">Development</li>
<li style="font-size: 12px;">HQ - CA</li>
<li style="font-size: 12px;">
[email protected] </li>
</ul>
</td>
Is there an option to check if an element has the text and this text is bold?
My current code is:
$("[class=odd]").shouldHave(text("char"));
My playground could be found at https://opensource-demo.orangehrmlive.com/index.php/auth/login , Directory tab
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的解决方案如下。检查应用于文本的样式有点困难,但我们很幸运,因为
innerHtml()
方法将公开内联样式。我应该指出,不建议使用innerHtml()
,但我目前不知道一个合适的替代方案。My solution for this is below. It is a little difficult to check the styling applied to text but we are fortunate here as the
innerHtml()
method will expose the inline styling. I should point out that usinginnerHtml()
is not recommended, but I currently do not know a decent alternative.