带有水豚步骤定义的黄瓜,用于检查体内某个类的存在

发布于 2024-10-10 16:51:47 字数 162 浏览 0 评论 0原文

我需要定义一个步骤定义来检查网页的正文标记中是否存在某个类。

例如

我想测试“home”是否是一个 body 类。

请记住,body 也可能包含其他类,

例如

感谢您的帮助。

I need to define a step definition to check for the existence of a certain class in a body tag of a web page.

eg <body class="home">

I want to test if "home" is a class of body.

Bear in mind that body may contain other classes as well

eg <body class="active home etc">

Thanks for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

停滞 2024-10-17 16:51:47
find(:xpath, "//body")[:class]

将为您获取类属性的字符串值。

如果您需要有关正则表达式匹配的帮助,我可以编辑,请告诉我 - 不要忘记您尝试匹配的类是另一个类的子字符串的情况(例如:class =“home_star_runner”)

find(:xpath, "//body")[:class]

will get you the string value of the class attribute.

I can edit if you need help with the regex to match, let me know-- don't forget about the case where the class you're trying to match is a substring of another class (ex: class="home_star_runner")

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文