Selenium Text Finding Utilities
Make your tests user-first by using these utilities to test against the presented content on the page, not the implementation detail of specific markup.
Find Elements by Text
The most powerful utilities are find_element_by_text(driver, text) and
find_elements_by_text(driver, text), which search the page for one or
multiple elements with content matching the given text, as efficiently as
possible. By default, the inner text must match exactly.
Call with the flag exact=False to find elements which simply
contain the text.
For example::
# Find the logout element and click it, whatever it might be
findtext.find_element_by_text(driver, 'Logout').click()
Form Helpers
You can locate and interact with form elements based on their labels, the way a user would find things on the page and the way your features are most likely to be documented.
fill_input_by_label(driver, element, label, value, timeout=None):
Interact with text fields on the page based on their visible label. Here is how you might fill in a login form:
fill_input_by_label(driver, None, "Username", username)
fill_input_by_label(driver, None, "Password", username)
Notice how you don't need to know anything about the markup on the page, the ID of the input elements, or if the label text is "Username" or "Username:".
If you only want to look at a part of the page, not the whole page, you can pass an optional element as the second parameter. The search will be done to descendents under that element.
fill_input_by_placeholder(driver, element, label, value):
You might also know youb can locate an element based on the placeholder text that can be read in the input. This function is called just like the previous function.
read_input_by_label(driver, element, label):
You can use the same logic to read information back out of forms, too.
assert expected == read_input_by_label(driver, None, "State")
Metadata
Release files for selenium-findtext 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| selenium-findtext-0.1.5.tar.gz | 4.7 kB | Without provenance | Details for selenium-findtext-0.1.5.tar.gz |
Release files / selenium-findtext-0.1.5.tar.gz
| Download URL | selenium-findtext-0.1.5.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b0fd2435eaddc4fcc80437e1baa8af9cc4a5eec40fd207df19f3ea192f786475
|
|
BLAKE2b-256 checksum How to use checksums |
81570c7da976cd230424905d04b048a935da99248fdf813d19662905fc5b7729
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.8
|
Security for selenium-findtext 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.