getx
The command to get a single Element using an XPath selector.
Syntax
py.getx(xpath: str) -> Element
py.getx(xpath: str, timeout: int) -> Element
---or---
Element.getx(xpath: str) -> Element
Element.getx(xpath: str, timeout: int) -> ElementUsage
# Yield the first Element in .nav with tag name of a
py.get(".nav").getx("//a")
---or---
# Yield the first Element in document with id of 'button'
py.getx("//*[@id='button']")
---or--- # store in a variable
element = py.getx("//*[@id='button']")
---or--- # chain an Element(s) command
# chain an action
py.getx("//*[@id='button']").click()
---or--- # control the timeout in any of the above usages
py.getx("//a[@href='/about']", timeout=5).click()Arguments
xpath (str)- The XPATH selector to usetimeout=None (int)- The number of seconds for this command to succeed.timeout=Nonewill use the default wait_time in pylenium.jsontimeout=0will poll the DOM immediately with no waitGreater than zero will override the default wait_time
Yields
Element - The first element found, even if multiple elements match the query.
Examples
Last updated