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
Abilityclass.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
BrowseTheWebenables an actor to interact with and retrieve information from Web-based user interfaces.BrowseTheWebwraps test integration tools such as Playwright, Protractor, or WebdriverIO, and together with Serenity/JS Web models, such asPageorPageElement- 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/webmodule 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
BrowseTheWebTo give an actor an ability to
BrowseTheWeb, provide the integration tool-specific implementation viaActor.whoCaninCast.prepare, or viaCast.where.Learn more
To learn more about using Serenity/JS with your chosen test integration tool, follow their respective documentation:
BrowseTheWebWithPlaywrightBrowseTheWebWithProtractorBrowseTheWebWithWebdriverIOUsing the ability to
BrowseTheWebTo use the ability to
BrowseTheWebin a customInteractionorQuestion, use the generic methodBrowseTheWeb.asto retrieve it.This generic method retrieves the integration tool-specific implementation of
BrowseTheWebpresent on theActor, such asBrowseTheWebWithPlaywrightorBrowseTheWebWithWebdriverIO, 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
AbilityActor.whoCanCast.whereCast.prepare