Cucumber with capybara step definition for checking existence of certain class in body
-
25-09-2019 - |
문제
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.
해결책
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")
제휴하지 않습니다 StackOverflow