Screenshots Python Tutorial
Getting Started with Applitools
Want to learn more about the Applitools platform and how it works? First get started with one of the following:
Running Tests with Applitools
Prerequisites
- A free Applitools account and Applitools API KEY
Tip: Unsure how to set up your API key?
Learn how to get started at Setting Up
Note: Installing `git` is optional
Installing git is used to clone the demo project from the Github repository. Instead of installing git
, you can simply download the Zip file from the repository. Further, if you are Mac, you already have git
.
Running the Example Project
- Clone or download the repository and navigate to that folder
git clone https://github.com/applitools/tutorial-images-python.git
cd tutorial-images-python
2
Note: you can alternatively download the project as a Zip file and extract it
- Install the dependencies
pip3 install -r requirements.txt
- Run the example test
APPLITOOLS_API_KEY="[Your API Key]" pytest tutorial.py
Adding Applitools Eyes to an Existing Project
Install Applitools Eyes dependencies:
pip install eyes-images
Sample test
import os
import io
import pytest
import requests
from PIL import Image
from applitools.images import Eyes, BatchInfo, logger
logger.set_logger(logger.StdoutLogger())
@pytest.fixture(name="eyes", scope="function")
def eyes_setup():
"""
Basic Eyes setup. It'll abort test if wasn't closed properly.
"""
eyes = Eyes()
eyes.configure.batch = BatchInfo("Demo Batch - Images - Python")
yield eyes
# If the test was aborted before eyes.close was called, ends the test as aborted.
eyes.abort()
def test_tutorial(eyes):
# Start the session and set app name and test name.
eyes.open("Demo App - Images Python", "Smoke Test - Images Python")
image = Image.open(io.BytesIO(requests.get("https://i.ibb.co/bJgzfb3/applitools.png").content))
# Visual checkpoint #1.
eyes.check_image(image)
# End the test.
eyes.close(False)
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Resources
Terms & Conditions Privacy Policy GDPR© 2021 Applitools. All rights reserved.