contains
The command to get a single Element containing the given text.
Syntax
py.contains(text: str) -> Element
py.contains(text: str, timeout: int) -> Element
---or---
Element.contains(text: str) -> Element
Element.contains(timeout: int) -> ElementUsage
# Yield Element in .nav containing "About"
py.get(".nav").contains("About")
---or---
# Yield first Element in document containing 'Hello'
py.contains("Hello")
---or--- # store in a variable
element = py.contains("About")
---or--- # chain an Element command
py.contains("About").click()
---or--- # control the timeout in any of the above usages
py.contains("Deck Builder", timeout=5).click()# Errors, 'title' does not yield Element
py.title().contains("QAP")
---or---
# Errors, 'get_cookies' does not yield Element
py.get_cookies().contains("Cooke Monster")Arguments
text (str)- The text to look fortimeout=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 waitAny value 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