get

The command to get a single Element that matches the CSS selector.

Syntax

py.get(css: str) -> Element
py.get(css: str, timeout: int) -> Element

---or---

Element.get(css: str) -> Element
Element.get(css: str, timeout: int) -> Element

Usage

correct usage
# Yield Element in .nav with tag name of a
py.get(".nav").get("a")

---or---

# Yield first Element in the DOM with id of 'button'
py.get("#button")

---or--- # store in a variable

element = py.get("#login")

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

py.get("#save-button").click()

---or--- # control the timeout in any of the above usages

py.get("a[href='/about']", timeout=5).click()
incorrect usage
# Errors, 'title' does not yield Element
py.title.get("QAP")

---or---

# Errors, 'get_cookie' does not yield Element
py.get_cookie().get("Cooke Monster")

Arguments

  • css (str) - The CSS selector to use

  • timeout=None (int) - The number of seconds for this command to succeed.

    • timeout=None will use the default wait_time in pylenium.json

    • timeout=0 will poll the DOM immediately with no wait

    • Greater than zero will override the default wait_time

Yields

  • Element - The first element that is found, even if multiple elements match the query.

Last updated