Additional Questions

These are the Questions added in ScreenPy Selenium.

Attribute

Aliases: TheAttribute

class Attribute(attribute: str)

Ask about an attribute on an element.

Abilities Required:

BrowseTheWeb

Examples:

the_actor.should(
    See.the(
        Attribute("value").of_the(NAME_INPUT), ReadsExactly("Jessica Walters")),
    ),
    See.the(
        Attribute("aria-label").of_the(BALLOONS), ContainsTheText("balloon")),
    ),
)
of_the(target: Target) Attribute

Target the element to get the attribute from.

of(target: Target) Attribute

Target the element to get the attribute from.

of_the_first_of_the(target: Target) Attribute

Target the element to get the attribute from.

of_all(target: Target) Attribute

Target the elements, plural, to get the attribute from.

BrowserTitle

Aliases: TheBrowserTitle

class BrowserTitle

Ask what the title of the browser’s active window is.

Abilities Required:

BrowseTheWeb

Examples:

the_actor.should(See.the(BrowserTitle(), ReadsExactly("Welcome!")))

BrowserURL

Aliases: TheBrowserURL

class BrowserURL

Ask what the url of the browser’s active window is.

Abilities Required:

BrowseTheWeb

Examples:

the_actor.should(See.the(BrowserURL(), ContainsTheText("/screenplays")))

Cookies

Aliases: TheCookies

class Cookies

Ask about the cookies on the Actor’s web browsing session.

Abilities Required:

BrowseTheWeb

Examples:

the_actor.should(
    See.the(CookiesOnTheWebSession(), ContainTheEntry(type="oatmeal raisin"))
)

Element

Aliases: TheElement

class Element(target: Target)

Ask to retrieve a specific element.

Abilities Required:

BrowseTheWeb

Examples:

the_actor.should(See.the(Element(WELCOME_BANNER), IsVisible()))

List

Aliases: TheList

class List(target: Target)

Ask for a list of elements.

Abilities Required:

BrowseTheWeb

Examples:

the_actor.should(See.the(List.of(CONFETTI), IsEmpty()))
classmethod of_the(target: Target) Self

Target the element(s) to list.

Aliases:
  • of_all_the()

  • of_all()

  • of()

classmethod of_all_the(target: Target) Self

Alias for of_the().

classmethod of_all(target: Target) Self

Alias for of_the().

classmethod of(target: Target) Self

Alias for of_the().

Number

Aliases: TheNumber

class Number(target: Target)

Ask how many of a certain element are on the page.

Abilities Required:

BrowseTheWeb

Examples:

the_actor.should(See.the(Number.of(SEARCH_RESULTS), IsEqualTo(4)))
classmethod of(target: Target) Self

Target the element to be counted.

Selected

Aliases: TheSelected

class Selected(target: Target, multi: bool = False)

Ask for the text of selected option(s) in a dropdown or multi-select field.

Abilities Required:

BrowseTheWeb

Examples:

the_actor.should(
    See.the(Selected.option_from(THE_STATE_DROPDOWN), ReadsExactly("Minnesota"))
)

the_actor.should(See.the(Selected.options_from(INDUSTRIES), HasLength(5)))
classmethod option_from_the(target: Target) Self

Get the option.

Get the option that is currently selected in a dropdown or the first option selected in a multi-select field.

Note: if this method is used for a multi-select field, only the first selected option will be returned.

Aliases:
  • option_from()

classmethod option_from(target: Target) Self

Alias of option_from_the().

classmethod options_from_the(multiselect_target: Target) Self

Get all the options that are currently selected in a multi-select field.

Note: this method should not be used for single-select dropdowns, that will cause a NotImplemented error to be raised from Selenium when answering this Question.

Aliases:
  • options_from()

classmethod options_from(multiselect_target: Target) Self

Alias of options_from_the().

Text

Aliases: TheText

class Text(target: Target, multi: bool = False)

Ask what text appears in an element or elements.

Abilities Required:

BrowseTheWeb

Examples:

the_actor.should(
    See.the(Text.of(THE_WELCOME_HEADER), ReadsExactly("Welcome!"))
)

the_actor.should(
    See.the(Text.of_all(SEARCH_RESULTS), ContainsTheItem("Rear Window"))
)
classmethod of_the(target: Target) Self

Target the element to extract the text from.

Aliases:
  • of()

  • of_the_first_of_the()

classmethod of(target: Target) Self

Alias of of_the().

classmethod of_the_first_of_the(target: Target) Self

Alias of of_the().

classmethod of_all(multi_target: Target) Self

Target the elements, plural, to extract the text from.

TextOfTheAlert

Aliases: TheTextOfTheAlert

class TextOfTheAlert

Ask what text appears in the alert.

Abilities Required:

BrowseTheWeb

Examples:

the_actor.should(
    See.the(TextOfTheAlert(), ReadsExactly("Danger, Will Robinson!"))
)