Comparing Screenshots in Python with Applitools | Applitools Documentation

Prerequisites

  1. A free Applitools account and Applitools API KEY
    Tip: Unsure how to find your API key?
    Read Retrieving your API key to find your API key.

  2. Python 3

  3. Git
    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

  1. Clone or download the repository and navigate to that folder

    git clone https://github.com/applitools/tutorial-images-python.git
    cd tutorial-images-python
    

    Note: you can alternatively download the project as a Zip file and extract it.

  2. Install the dependencies

    pip install -r requirements.txt
    
  3. Run the example test

    APPLITOOLS_API_KEY="[Your API Key]" python -m pytest tutorial.py
    

Adding Applitools Eyes to an Existing Project

Install Applitools Eyes dependencies:

pip install eyes-images

Sample test

import io
import pytest
import requests

from applitools.images import Eyes, BatchInfo, logger
from PIL import Image

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)

Having Trouble?

Don't suffer in silence!
Let us help you.
Please reach out to us to get your project working.

Taking the next steps with Applitools Eyes

Congratulations on completing this quickstart!
There's still so much to learn about visual testing with Applitools, but you're off to a great start.