Cucumber with capybara step definition for checking existence of certain class in body
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")
精彩评论