Target API

This is the Target class and its API.

Target

class Target(description: str)

Describe an element with a human-readable string and a locator.

Abilities Required:

UseAnAndroidDevice UseAnIOSDevice

Examples:

# assumes by Accessibility ID
Target.the("accept button").located_by('"Accept" Button')

# assumes by XPATH
Target.the("username field").located_by("//android.widget.EditText")

Target.the('"Log In" button').located((AppiumBy.NAME, "login"))
classmethod the(description: str) Target

Provide a human-readable description for the element.

located_by(locator: tuple[str, str] | str) Target

Set the locator for this Target.

Possible values for locator:
  • A tuple of an AppiumBy classifier and a string (e.g. (AppiumBy.NAME, "welcome"))

  • An Accessibility ID string (e.g. "Accept Button")

  • An XPATH string (e.g. "//div/h3")

located(locator: tuple[str, str] | str) Target

Set the locator for this Target.

Possible values for locator:
  • A tuple of an AppiumBy classifier and a string (e.g. (AppiumBy.NAME, "welcome"))

  • An Accessibility ID string (e.g. "Accept Button")

  • An XPATH string (e.g. "//div/h3")

get_locator() tuple[str, str]

Return the stored locator.

Raises:

TargetingError: if no locator was set.

found_by(the_actor: Actor) WebElement

Retrieve the WebElement as viewed by the Actor.

all_found_by(the_actor: Actor) list[WebElement]

Retrieve a list of WebElement objects as viewed by the Actor.