The class  type is used to identify an element by its class attribute and is one of the six options available you get to choose from when setting a custom selector.

The value set for this class  selector must be a single class or the entire class attribute string.

This is critical and if set incorrectly, it will cause Robot Ninja to throw an error when trying to find an element and the test will be marked as failed.

Sample HTML

<article class="main_content wide dark"></article>

Using the above sample code, here are some examples of good and bad strings to set for the class  type.

  • main_content  ✅ 
  • main_content wide dark  ✅ 
  • main_content wide
  • wide dark

Other helpful links

FAQ

1. What selector type should I use to find an element using multiple classes?

The safest option is to use the CSS selector type and separate the classes with . for example ( CSS .main_content.wide ).

The CSS selector type can be used for single classes too.

Did this answer your question?