Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top