Back to all steps

Element has class

Step fields
1 selector (text)
2 class name (text)
In a scenario, fields are joined with |.
Assert the element has the given CSS class. Format: selector|class_name (without dot).
Example: #tab-orders|active — tab #tab-orders has class active
Usage example

Check that an element has the given CSS class.

Format: selector|class_name (the class name without the dot).

Selector examples:

  • #login-btn — by id
  • .my-button — by class
  • [name=email] — by attribute
  • button.submit — a button with a class
  • nav > a.active — a nested selector

Full example: to check that <button id="tab1" class="tab active"> has the class active:

  • selector: #tab1
  • class name: active
  • resulting string: #tab1|active