Applitools Eyes Core SDK Server (Python Client)

4.16.5 · active · verified Mon Apr 13

The `core-universal` package is part of the Applitools Eyes SDK ecosystem, serving as the Python client for the Eyes Core SDK Server. It provides the underlying communication protocol (using WebSockets) for Python SDKs (like `eyes-selenium`, `eyes-playwright`, `eyes-appium`) to interact with the Applitools Eyes service, where core functionality is implemented in JavaScript. End-users typically interact with higher-level Applitools SDKs rather than directly with `core-universal`. The current version is 4.16.5. Applitools SDKs are actively maintained with frequent releases.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates a basic visual test using `applitools.selenium`, which is a common way to interact with Applitools Eyes functionality. It initializes a Selenium WebDriver, opens an Applitools Eyes test, performs visual checkpoints on different pages, and then closes the test. Remember to set the `APPLITOOLS_API_KEY` environment variable.

import os
from selenium import webdriver
from applitools.selenium import Eyes, ClassicRunner, Target

def run_applitools_test():
    # Set your Applitools API key from environment variable
    # For a quickstart, ensure APPLITOOLS_API_KEY is set in your environment
    api_key = os.environ.get('APPLITOOLS_API_KEY', 'YOUR_APPLITOOLS_API_KEY_HERE')
    if not api_key or api_key == 'YOUR_APPLITOOLS_API_KEY_HERE':
        print("Warning: APPLITOOLS_API_KEY environment variable not set. Test might fail.")
        # In a real scenario, you'd raise an error or handle this more robustly

    runner = ClassicRunner()
    eyes = Eyes(runner)
    eyes.api_key = api_key

    # Configure Eyes to log to console for debugging
    eyes.log_handler = None # Set to StreamMessageLogger() for console output

    driver = None
    try:
        # Initialize a headless Chrome browser (ensure chromedriver is in PATH)
        options = webdriver.ChromeOptions()
        options.add_argument('--headless')
        driver = webdriver.Chrome(options=options)

        # Start the Applitools Eyes test
        driver = eyes.open(driver=driver, app_name='My Python App', test_name='Simple Login Test', viewport_size={'width': 800, 'height': 600})

        # Navigate to a URL and perform visual checkpoints
        driver.get('https://demo.applitools.com')
        eyes.check('Login Page', Target.window().fully())

        # Perform some actions (e.g., filling a form, clicking buttons)
        # For this example, just navigate to another page
        driver.find_element_by_id('log-in').click()
        eyes.check('App Page', Target.window().fully())

        # Close the Eyes test and get results
        results = eyes.close(raise_exception=True)
        print(f"Applitools Test Results: {results}")

    except Exception as e:
        print(f"Applitools test failed: {e}")
    finally:
        if driver:
            driver.quit()
        # Always abort the test if it's open, even if an exception occurred
        eyes.abort_if_not_closed()

if __name__ == '__main__':
    run_applitools_test()

view raw JSON →