spydr
Selenium Python WebDriver Wrapper - Commonly used WebDriver functionality in a package.
spydr WebDriver - Spydr documentation
spydr WebElement - SpydrElement documentation
Install
pip install spydr
Supported locator
Spydr WebDriver supports locator using the following how=what strategies to locate elements:
css=.btnclass=btn-primaryid=frame1link_text=Click herename=j_usernamepartial_link_text=Go totag_name=spantext=Save As Draftxpath=//span/ayml=today_page.dashboard.search_field
If how is not specified, locator starting with / or ( will be parsed as xpath, while ., [ and # are treated as css.
locator also supports css pseudo selector :eq(), like using .tab:eq(2) to locate 3rd element of .tab.
Using Sypdr WebDriver
# Basic Example 1:
# - Google search 'webdriver'
from spydr.webdriver import Spydr
s = Spydr()
s.maximize_window()
s.open('https://www.google.com/')
s.send_keys('name=q', 'webdriver', s.keys.ENTER)
s.save_screenshot('sample-1')
s.quit()
# Basic Example 2:
# - Firefox driver, in headless mode, with 1920x1080 resolution
# - Switch frame and window
from spydr.webdriver import Spydr
s = Spydr(browser='firefox', headless=True, log_level='INFO', window_size='1920,1080')
s.info('JSFiddle: Test "Open New Tab/Window"')
s.maximize_window()
s.open('https://jsfiddle.net/s7gcx1du/')
s.switch_to_frame('name=result')
s.click('link_text=New Window', switch_to_new_target=True)
s.save_screenshot(s.timestamp(prefix='sample-'))
s.quit()
# Handle Basic/Digest HTTP AUTH using Chrome
from spydr.webdriver import Spydr
s = Spydr(auth_username='guest', auth_password='guest')
s.open('https://jigsaw.w3.org/HTTP/Basic/')
s.save_screenshot('basic')
s.open('https://jigsaw.w3.org/HTTP/Digest/')
s.save_screenshot('digest')
s.quit()
# Handle Basic/Digest HTTP AUTH using non-Chrome
from spydr.webdriver import Spydr
s = Spydr(browser='firefox', auth_username='guest', auth_password='guest')
s.open_with_auth('https://jigsaw.w3.org/HTTP/Basic/')
s.save_screenshot('basic')
s.open_with_auth('https://jigsaw.w3.org/HTTP/Digest/')
s.save_screenshot('digest')
s.quit()
Using YML: Dot Notation
# conf.yml
env:
url: 'https://dev.company.com/today'
today_page:
dashboard:
search_field: '#dashboard-search'
search_string: 'name is {name}'
from spydr.webdriver import Spydr
s = Spydr(yml='conf.yml')
url = s.t('env.url')
search_string = s.t('today_page.dashboard.search_string', name='spydr')
s.open(url)
s.send_keys('yml=today_page.dashboard.search_field', search_string) # using yml as locator
Using INI: JSON serialization
; conf.ini
[Spydr]
url = "https://www.google.com"
query = "webdriver"
from spydr.webdriver import Spydr
s = Spydr(ini='conf.ini')
url = s.get_ini_key('url')
query = s.get_ini_key('query')
s.open(url)
s.send_keys('name=q', query, s.keys.ENTER)
first_result = s.text('.r > a h3:eq(0)') # Get first search result
s.set_ini_key('first_result', first_result) # add first_result to the INI file
all_results = s.texts('.r > a h3') # Get all results
s.set_ini_key('all_results', all_results) # add all results to the INI file
s.save_ini() # Save the INI file
s.quit()
SpydrElement (WebElement with Spydr functionality)
from spydr.webdriver import Spydr
s = Spydr()
# ...
table = s.find_element('#table')
td = table.find_element('css=td[data-id="12345"]')
if td.parent_element.last_child.text == 'complete':
td.next_element.find_element('.comment').send_keys('Comment here', blur=True)
else:
td.parent_element.first_child.find_element('css=a.update').click()
Development Environment
cd spydr
pip install -e .
pip install autopep8
pip install pylint
pip install twine
pip install wheel
pip install sphinx
pip install sphinxcontrib-napoleon
Build Docs
cd spydr
sphinx/make html
Upload Package
cd spydr
python -B setup.py bdist_wheel
twine upload dist/*
Project Home
Metadata
Release files for spydr 0.6.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spydr-0.6.1-py3-none-any.whl | Python 3 | none | any | Details for spydr-0.6.1-py3-none-any.whl |
Release files / spydr-0.6.1-py3-none-any.whl
| Download URL | spydr-0.6.1-py3-none-any.whl |
|---|---|
| Size | 33.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e734637f97595ee635ef602f558b01c9c03449e5c01b0705440720d3eb77dbea
|
|
BLAKE2b-256 checksum How to use checksums |
a423e40e385f558e999801ba73ecb6b6fb44bc19c059b7e19e7c3a4eed91fc08
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1
|
Security for spydr 0.6.1
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.