Interact with an app using visual definitions of elements
Project description
velenium
Interact with an app using visual definitions of elements
sample usage
import unittest
from appium import webdriver
from velenium import VisualElement, VERTICAL_ORDER, HORIZONTAL_ORDER, CV_SQDIFF
class VisualTestCase(unittest.TestCase):
def test_visual(self):
desired_caps = dict(
...
)
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
# create a visual definition
element = VisualElement(driver, 'path/to/pattern.png')
# create a visual definition using multiple images using glob path
element = VisualElement(driver, 'path/to/patterns/**/pattern_*.png')
# assert element is visible
self.assertTrue(element.is_visible())
# wait until visual element is visible, raises TimeoutException from selenium if timeout
element.wait_until_visible()
# wait until visual element is not visible, raises TimeoutException from selenium if timeout
element.wait_until_not_visible()
# click on element
element.click()
# refresh position of element and click
element.reset_object().click()
# click and wait no visibility of the element
element.click().wait_until_not_visible()
# find with different similarity threshold, by default is 70%
VisualElement(driver, 'path/to/pattern.png', similarity=0.8).click()
# click the 2nd best match of element
VisualElement(driver, 'path/to/pattern.png', order=1).click()
# click element at 2nd position in vertical order
VisualElement(driver, 'path/to/pattern.png', order=1, disposal=VERTICAL_ORDER).click()
# or
item = VisualElement(driver, 'path/to/pattern.png', disposal=VERTICAL_ORDER)
item[1].click()
# click element at 3er position in horizontal order
VisualElement(driver, 'path/to/pattern.png', order=2, disposal=HORIZONTAL_ORDER).click()
# or
item = VisualElement(driver, 'path/to/pattern.png', disposal=HORIZONTAL_ORDER)
item[2].click()
# use another cv2 method to get the match, by default uses CV_CCOEFF
VisualElement(driver, 'path/to/pattern.png', method=CV_SQDIFF).wait_until_visible()
# count matches
print(len(element))
# iterate over matches
for e in element:
e.click()
# enable debug images in "temp/" folder
element.debug()
# disable debug images
element.debug(False)
if __name__ == '__main__':
unittest.main()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
velenium-0.3.1.tar.gz
(5.0 kB
view details)
File details
Details for the file velenium-0.3.1.tar.gz
.
File metadata
- Download URL: velenium-0.3.1.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b48417b765788bffb3f57718afa7dd473161e1536ff00253fe888d374ba858d5 |
|
MD5 | dd4773aa92938bc77b206a8ca9d921db |
|
BLAKE2b-256 | 32e59dc265df73cf2df12a13299e836a68e6236f13656ee46bf3b983c99fafb1 |