type

The command to type keys into a field, input or text box.

Replaces send_keys from Selenium

Syntax

Element.type(*args) -> Element

Usage

correct usage
py.get("#username").type("my-username")

---or--- # combine with other keys and strings

# import the Keys from selenium
py.get("#search").type("puppies", Keys.ENTER)

---or--- # chain an Element command

py.get("#email").type("[email protected]").get_attribute("value")
incorrect usage
# Errors, 'type' may have no effect on other types of elements
py.get("a").type("foo")

Arguments

  • *args (Any) - A comma-separated list of arguments to type

Yields

  • Element - The current Element so you can chain commands

Examples

Given this HTML:

We could type credentials into the fields and submit the form to login:

Last updated