Global

Type Definitions


AttributeMap

Maps attribute name to value (empty string if the attribute is not set).

Type:
  • Object

Dialog

Represents a pop-up dialog of type alert, prompt, confirm, or beforeunload

Type:
  • Object
Properties:
Name Type Description
aOrAn string

Appropriate for describing the type of dialog, e.g. 'an alert' or 'a prompt'

type string

One of ['alert', 'prompt', 'confirm', 'beforeunload']

message string

The message that appeared in the dialog.


DialogCallback(dialog, api)

Use this to perform additional validation of the dialog, or pass the test case and skip any further dialog handling.

Parameters:
Name Type Description
dialog Dialog

The dialog object that just popped up.

api TestCaseAPI

DOMNode

Properties:
Name Type Description
tag string

tag name of the node, e.g. html or h3

name string

name attribute of the node, e.g. "frog" in <p name="frog">, or undefined.

attributes Map.<string, string>

A map of attribute name to value.

value string

The value from the node, if this is meaningful, the empty string if not.


FailedRequest

Contains information relating to an HTTP request that failed within the user page. This might be due to a bad src attribute on an img tag, or an incorrectly used relative URL. Note that requests for resources inside the student's workspace (eg. a local .js file) will appear as a relative url.

Type:
  • Object
Properties:
Name Type Description
url string
status number

HTTP status code

statusText string

Short description of the failure.


FailureReportOptions

This object allows you to specify or override various parts of the failure report, when an expect* API hook results in test failure. All strings are formatted HTML. The failure report shows the details in the following order: [message] [details] [actions] [hint]. You can override parts of the failure report (except the message) to fine-tune what information is shown to the student.


For example:
[message] The text in the top text display element is incorrect. The text was

Yellow Sunflowers
when it was meant to be:
Yellow Submarine
[details]
[actions != []] We performed these actions before checking:
  • Entered "Hello World" into the top text entry element
  • Entered "Some more text" into the top text entry element
  • [hint] Did you remember to add an event listener to the top text entry element?

    Type:
    • Object
    Properties:
    Name Type Argument Description
    details string | BaseString

    More details, if useful. This comes after the message and before the report for 'actions performed so far'. Defaults to an empty string.

    actions Array.<(string|BaseString)> <optional>

    A list of strings to report as the actions performed so far. By default we use the actions recorded during the test. Set to an empty list to suppress the actions report.

    hint string | BaseString

    Additional hint to follow the action report (e.g. 'Did you hook up an event handler to the "Add" button?'). Defaults to an empty string.


    PageElementFunction(element, args)

    This function is executed inside the browser context, ie. the student page.

    Parameters:
    Name Type Argument Description
    element DOMElement

    An HTML DOM Element.

    args * <repeatable>

    Additional arguments as specified when registering the function.


    PageElementGroupFunction(elements, args)

    This function is executed inside the browser context, ie. the student page.

    Parameters:
    Name Type Argument Description
    elements Array.<DOMElement>

    A list of DOM Elements.

    args * <repeatable>

    Additional arguments as specified when registering the function.


    PageFunction()

    This function is executed inside the browser context, ie. the student page.


    StyleAttributeMap

    Maps style attribute name to BaseString value ('none' if the attribute is not set, or as appropriate to the style).

    Type:
    • Object

    UnexpectedNavigationCallback(api)

    This callback is invoked when there is an unexpected page navigation, and is expected to fail the test case with a suitable message.

    Parameters:
    Name Type Description
    api TestCaseAPI