VisualTest
This Python SDK extends the functionality of Selenium WebDriver enabling the script to capture screenshots of the device under test, including fullpage, viewport, and element screenshots for regression testing or manual review of the UI.
pip install visualtest-python
Quick Setup
from selenium import webdriver
from sbvt import VisualTest
driver = webdriver.Safari()
settings = {'projectToken': "INSERT_PROJECT_TOKEN"}
visualTest = VisualTest(driver, settings)
try:
driver.get("https://www.google.com/search?q=smartbear")
visualTest.capture("Google results")
visualTest.capture("Google results viewport", {'viewport': True})
finally:
driver.quit()
Running Selenium against BitBar
Copy the file from below
Enter BitBar API_KEY and VisualTest PROJECT_TOKEN in the file
import time
from selenium import webdriver
from sbvt import VisualTest
API_KEY = 'INSERT_BITBAR_APIKEY'
PROJECT_TOKEN = 'INSERT_PROJECT_TOKEN'
def testSmartBearHomePage():
import warnings
warnings.simplefilter("ignore") # turn off tracemalloc socket warnings
caps = {
'platform': 'Linux',
'osVersion': '18.04',
'browserName': 'firefox',
'version': 'latest',
'resolution': '2560x1920',
'bitbar_apiKey': API_KEY,
}
hubUrl = 'https://us-west-desktop-hub.bitbar.com/wd/hub'
driver = webdriver.Remote(command_executor=hubUrl, desired_capabilities=caps)
print(
f'Launching webdriver for {caps["platform"]} {caps["osVersion"]} {caps["browserName"]} {caps["version"]} ')
# load the url
url = 'https://www.smartbear.com'
print(f'Opening URL: {url}')
driver.get(url)
time.sleep(5)
settings = {
'projectToken': PROJECT_TOKEN,
}
visualTest = VisualTest(driver, settings)
# full page screenshot
fullPageScreenshot = visualTest.capture('Home Page')
# viewport screenshot
viewportScreenshot = visualTest.capture('viewport', {'viewport': True})
if __name__ == '__main__':
try:
testSmartBearHomePage()
except Exception as e:
print(f'Error starting test {e}')
Running Selenium Locally
from sbvt import VisualTest
# pip install selenium==3.141
from selenium import webdriver
from selenium.webdriver.common.by import By
PROJECT_TOKEN = 'INSERT_PROJECT_TOKEN'
driver = webdriver.Chrome('./chromedriver')
driver.get("https://www.smartbear.com")
print(driver.title)
settings = {
'projectToken': PROJECT_TOKEN
}
visualTest = VisualTest(driver, settings)
# full page screenshot
fullPageScreenshot = visualTest.capture('Home Page')
# viewport screenshot
viewportScreenshot = visualTest.capture('viewport', {'viewport': True})
# element screenshot
heroEl = driver.find_element(By.CLASS_NAME, "sb-hp-hero-content")
visualTest.capture('Hero Content', {'element': heroEl})
print(driver.current_url)
driver.close()
Metadata
Release files for visualtest-python 1.9.7
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 |
|---|---|---|---|---|
| visualtest_python-1.9.7-py3-none-any.whl | Python 3 | none | any | Details for visualtest_python-1.9.7-py3-none-any.whl |
Release files / visualtest_python-1.9.7-py3-none-any.whl
| Download URL | visualtest_python-1.9.7-py3-none-any.whl |
|---|---|
| Size | 29.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4502feb29fd16675812286b260d29b6a87a217ee85fb9152d4eb31c5dc6c41e2
|
|
BLAKE2b-256 checksum How to use checksums |
35f02b7891e1741aa36811c1496319eaa1eac1db1b16b629b0a2d86c54f0439d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.9
|
Security for visualtest-python 1.9.7
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.