Skip to main content

externalBrowseTheWebWithProtractor

This implementation of the ability to BrowseTheWeb enables the Actor to interact with web front-ends using Protractor.

Using Protractor to BrowseTheWeb

import { actorCalled } from '@serenity-js/core'
import { BrowseTheWebWithProtractor } from '@serenity-js/protractor
import { By, Navigate, PageElement, Text } from '@serenity-js/web'
import { Ensure, equals } from '@serenity-js/assertions'
import { protractor } from 'protractor'

const HomePage = {
title: () =>
PageElement.located(By.css('h1')).describedAs('title')
}

await actorCalled('Wendy')
.whoCan(BrowseTheWebWithProtractor.using(protractor.browser))
.attemptsTo(
Navigate.to(`https://serenity-js.org`),
Ensure.that(Text.of(HomePage.title()), equals('Serenity/JS')),
)

Learn more

Hierarchy

  • BrowseTheWeb<protractor.ElementFinder>
    • BrowseTheWebWithProtractor

Index

Constructors

externalconstructor

  • Parameters

    • externalbrowser: ProtractorBrowser

      An instance of a protractor browser

    Returns BrowseTheWebWithProtractor

Methods

staticexternalusing

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 MyAbility

    Returns AbilityType<Ability>

externalparam

  • param<T>(path: string): T
  • Returns Protractor configuration parameter at path.

    Configuring a custom parameter

    // protractor.conf.js
    exports.config = {
    params: {
    login: {
    username: 'jane@example.org'
    password: process.env.PASSWORD
    }
    }
    // ...
    }

    Retrieving config param by name

    BrowseTheWebWithProtractor.as(actor).param('login')
    // returns object with username and password

    Retrieving config param by path

    BrowseTheWeb.as(actor).param('login.username')
    // returns string 'jane@example.org'

    @param path
    Either a name or a dot-delimited path to the param.

    @throws [`ConfigurationError`](/api/core/class/ConfigurationError/)
    Throws a `ConfigurationError` if the parameter is `undefined`

    Type parameters

    • T = any

    Parameters

    • externalpath: string

    Returns T

externalcurrentPage

  • currentPage(): Promise<Page<ElementFinder>>
  • Returns a Page representing the currently active browser tab.


    Returns Promise<Page<ElementFinder>>

externalallPages

  • allPages(): Promise<Page<ElementFinder>[]>
  • Returns an array of pages representing all the browser tabs available in the current BrowsingSession.


    Returns Promise<Page<ElementFinder>[]>

externalbrowserCapabilities