externalabstractBrowseTheWeb <Native_Element_Type>
Hierarchy
- Ability
- BrowseTheWeb
Index
Constructors
Methods
Constructors
externalconstructor
Type parameters
- Native_Element_Type = any
Parameters
externalsession: BrowsingSession<Page<Native_Element_Type>>
Returns BrowseTheWeb<Native_Element_Type>
Methods
externaltoJSON
Returns a JSON representation of the ability and its current state, if available. The purpose of this method is to enable reporting the state of the ability in a human-readable format, rather than to serialise and deserialise the ability itself.
Returns SerialisedAbility
externalabilityType
Returns the most abstract type of this Ability instance, specifically the first class in the inheritance hierarchy that directly extends the
Ability
class.import { Ability } from '@serenity-js/core';
class MyAbility extends Ability {}
class MySpecialisedAbility extends MyAbility {}
new MyAbility().abilityType(); // returns MyAbility
new MySpecialisedAbility().abilityType(); // returns MyAbilityReturns AbilityType<Ability>
externalcurrentPage
externalallPages
Returns an array of pages representing all the browser tabs available in the current
BrowsingSession
.Returns Promise<Page<Native_Element_Type>[]>
externalbrowserCapabilities
Returns basic meta-data about the browser associated with this ability.
Returns Promise<BrowserCapabilities>
The ability to
BrowseTheWeb
enables an actor to interact with and retrieve information from Web-based user interfaces.BrowseTheWeb
wraps test integration tools such as Playwright, Protractor, or WebdriverIO, and together with Serenity/JS Web models, such asPage
orPageElement
- offers a standardised way to write Web-based tests following the Screenplay Pattern.The consistent and portable design of abstractions provided by the
@serenity-js/web
module also helps to make your tests portable across the various test integration tools and helps to make your test code easier to reuse across projects and teams.Giving the actors an ability to
BrowseTheWeb
To give an actor an ability to
BrowseTheWeb
, provide the integration tool-specific implementation viaActor.whoCan
inCast.prepare
, or viaCast.where
.Learn more
To learn more about using Serenity/JS with your chosen test integration tool, follow their respective documentation:
BrowseTheWebWithPlaywright
BrowseTheWebWithProtractor
BrowseTheWebWithWebdriverIO
Using the ability to
BrowseTheWeb
To use the ability to
BrowseTheWeb
in a customInteraction
orQuestion
, use the generic methodBrowseTheWeb.as
to retrieve it.This generic method retrieves the integration tool-specific implementation of
BrowseTheWeb
present on theActor
, such asBrowseTheWebWithPlaywright
orBrowseTheWebWithWebdriverIO
, usingActor.abilityTo
.This decoupling mechanism helps to make your test code portable across test integration tools, since the only part of your test suite that needs to know about the test integration tool used are the actors. The rest of your test code, so tasks, interactions, and questions, remain fully agnostic of the underlying tool.
Pro tip: Use the specific
BrowseTheWebWith<test integration tool name>
to give the actor the ability, and genericBrowseTheWeb.as(actor)
to retrieve it.Learn more
Ability
Actor.whoCan
Cast.where
Cast.prepare