开发者

Cucumber with capybara step definition for checking existence of certain class in body

开发者 https://www.devze.com 2023-02-02 22:41 出处:网络
I need to define a step definition to check for the existence of a cer开发者_高级运维tain class in a body tag of a web page.

I need to define a step definition to check for the existence of a cer开发者_高级运维tain 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.


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")

0

精彩评论

暂无评论...
验证码 换一张
取 消