last

The command to get the last Element in a list of Elements.

Syntax

Elements.last() -> Element

Usage

correct usage
py.find("li").last()

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

last = py.xpath("//a").last()

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

py.get("ul > li").children().last().click()
incorrect usage
# Errors, 'get' yields Element, not Elements
py.get("ul > li").last()

Arguments

  • None

Yields

  • Element - The last Element in a list of Elements

Raises

  • IndexError if Elements is empty

Last updated