import {CSSClasses} from '@serenity-js/protractor/lib/screenplay/questions'
public class | source

CSSClasses

Resolves to an array of CSS classes of a given WebElement, represented by ElementFinder or Question<ElementFinder>.

Extends:

Question → CSSClasses

Implements:

Examples:

Example widget
 <ul id="shopping-list" class="active favourite">
   <li class="bought">Coffee<li>
   <li class="buy">Honey<li>
   <li class="buy">Chocolate<li>
 </ul>
Retrieve CSS classes of a given WebElement
 import { actorCalled } from '@serenity-js/core';
 import { Ensure, equals } from '@serenity-js/assertions';
 import { BrowseTheWeb, CSSClasses, Target } from '@serenity-js/protractor';
 import { by } from 'protractor';

 const shoppingList = () =>
     Target.the('shopping list').located(by.id('shopping-list'))

 actorCalled('Lisa')
     .whoCan(BrowseTheWeb.using(protractor.browser))
     .attemptsTo(
         Ensure.that(CSSClasses.of(shoppingList()), equals([ 'active', 'favourite' ])),
     )
Find WebElements with a given class
 import { actorCalled } from '@serenity-js/core';
 import { Ensure, equals } from '@serenity-js/assertions';
 import { BrowseTheWeb, CSSClasses, Target } from '@serenity-js/protractor';
 import { by } from 'protractor';

 class ShoppingList {
     static items = () =>
         Target.all('items')
             .located(by.css('#shopping-list li'))

     static outstandingItems = () =>
         ShoppingList.items
             .where(CSSClasses, contain('buy'))
 }

 actorCalled('Lisa')
     .whoCan(BrowseTheWeb.using(protractor.browser))
     .attemptsTo(
         Ensure.that(
             Text.ofAll(ShoppingList.outstandingItems()),
             equals([ 'Honey', 'Chocolate' ])
         ),
     )

Static Method Summary

Static Public Methods
public static

of(target: Question<ElementFinder> | ElementFinder): CSSClasses

Constructor Summary

Public Constructor
public

constructor(target: Question<ElementFinder> | ElementFinder)

Method Summary

Public Methods
public

answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<void>

Makes the provided Actor answer this Question.

public

of(parent: Question<ElementFinder> | ElementFinder): Question<Promise<string[]>>

Resolves to an array of CSS classes of the target element, located in the context of a parent element.

Static Public Methods

public static of(target: Question<ElementFinder> | ElementFinder): CSSClasses source

Params:

NameTypeAttributeDescription
target Question<ElementFinder> | ElementFinder

Returns:

CSSClasses

Tests:

Public Constructors

public constructor(target: Question<ElementFinder> | ElementFinder) source

Params:

NameTypeAttributeDescription
target Question<ElementFinder> | ElementFinder

Public Methods

public answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<void> source

Makes the provided Actor answer this Question.

Params:

NameTypeAttributeDescription
actor AnswersQuestions & UsesAbilities

Returns:

Promise<void>

public of(parent: Question<ElementFinder> | ElementFinder): Question<Promise<string[]>> source

Resolves to an array of CSS classes of the target element, located in the context of a parent element.

Params:

NameTypeAttributeDescription
parent Question<ElementFinder> | ElementFinder

Returns:

Question<Promise<string[]>>