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> |
|
public |
Resolves to an array of CSS classes of the |
Static Public Methods
public static of(target: Question<ElementFinder> | ElementFinder): CSSClasses source
Params:
Name | Type | Attribute | Description |
target | Question<ElementFinder> | ElementFinder |
Tests:
Public Constructors
public constructor(target: Question<ElementFinder> | ElementFinder) source
Params:
Name | Type | Attribute | Description |
target | Question<ElementFinder> | ElementFinder |
Public Methods
public answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<void> source
Params:
Name | Type | Attribute | Description |
actor | AnswersQuestions & UsesAbilities |
Returns:
Promise<void> |