find
The command to get a list of Elements that match the CSS selector.
Syntax
py.find(css: str) -> Elements
py.find(css: str, timeout: int) -> Elements
---or---
Element.find(css: str) -> Elements
Element.find(css: str, timeout: int) -> Elements
Usage
# Yield Elements in .nav with tag name of a
py.get(".nav").find("a")
---or---
# Yield all Elements in the DOM with id of 'button'
py.find("#button")
---or--- # store in a variable
elements = py.find("li")
---or--- # chain an Elements command
element = py.find("ul > li").first()
---or--- # control the timeout in any of the above usages
py.find("li", timeout=5).last()
# Errors, 'title' does not yield Element
py.title.find("QAP")
---or---
# Errors, 'get_cookie' does not yield Element
py.get_cookie().find("Cooke Monster")
Arguments
css (str)
- The CSS selector to usetimeout=None (int)
- The number of seconds for this command to succeed.timeout=None
will use the default wait_time in pylenium.jsontimeout=0
will poll the DOM immediately with no waitGreater than zero will override the default wait_time
Yields
Elements - A list of elements that match the query.
Examples
# If you expect the elements not to be present
assert py.find("ul > li").should().be_empty()
# Otherwise, just use the default
elements = py.find("ul > li")
Last updated