Skip to main content

BrowseTheWebWithProtractor

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

constructor

  • Parameters

    • browser: ProtractorBrowser

      An instance of a protractor browser

    Returns BrowseTheWebWithProtractor

Methods

staticusing

param

  • 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

    • path: string

    Returns T

currentPage

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


    Returns Promise<Page<ElementFinder>>

allPages

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


    Returns Promise<Page<ElementFinder>[]>

browserCapabilities

  • browserCapabilities(): Promise<BrowserCapabilities>
  • Returns basic meta-data about the browser associated with this ability.


    Returns Promise<BrowserCapabilities>