{"id":5214,"library":"eyes-selenium","title":"Applitools Eyes SDK for Selenium Python","description":"Applitools Eyes SDK for Selenium Python is a proxy package that facilitates automated visual testing for web applications by integrating with Selenium WebDriver. It allows developers and QA engineers to automatically validate the correctness of an application's UI layout, content, and appearance using AI-driven image comparisons. The current version is 6.4.32, and the library is actively maintained with frequent patch releases.","status":"active","version":"6.4.32","language":"en","source_language":"en","source_url":"https://github.com/applitools/eyes.sdk.python","tags":["applitools","selenium","visual-testing","e2e-testing","qa","automation"],"install":[{"cmd":"pip install eyes-selenium","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Primary WebDriver integration for web automation.","package":"selenium","optional":false},{"reason":"Included for potential Appium WebDriver integration, though selenium is primary for this package.","package":"Appium-Python-Client","optional":true}],"imports":[{"note":"Main class for Applitools Eyes functionality.","symbol":"Eyes","correct":"from applitools.selenium import Eyes"},{"note":"Used to define what to check in a visual test (e.g., `Target.window()`).","symbol":"Target","correct":"from applitools.selenium import Target"},{"note":"Manages multiple Eyes test sessions, especially with the Ultrafast Grid. Recommended for parallel execution.","symbol":"VisualGridRunner","correct":"from applitools.selenium import VisualGridRunner"},{"note":"Manages multiple Eyes test sessions without the Ultrafast Grid.","symbol":"ClassicRunner","correct":"from applitools.selenium import ClassicRunner"},{"note":"Groups related test runs together in the Applitools Test Manager.","symbol":"BatchInfo","correct":"from applitools.common import BatchInfo"}],"quickstart":{"code":"import os\nimport pytest\nfrom selenium import webdriver\nfrom applitools.selenium import Eyes, Target, VisualGridRunner, BatchInfo\n\n# Set your Applitools API key as an environment variable APPLITOOLS_API_KEY\n# For example: export APPLITOOLS_API_KEY='YOUR_API_KEY'\nAPPLITOOLS_API_KEY = os.environ.get('APPLITOOLS_API_KEY', '')\nif not APPLITOOLS_API_KEY:\n    raise ValueError(\"APPLITOOLS_API_KEY environment variable not set.\")\n\n@pytest.fixture(scope='session')\ndef applitools_runner():\n    runner = VisualGridRunner()\n    yield runner\n    # Wait for all visual tests to complete and get results\n    print(\"\\nVisual test results:\\n\", runner.get_all_test_results(raise_exception=True))\n\n@pytest.fixture(scope='function')\ndef driver():\n    # Ensure your ChromeDriver version matches your Chrome browser version\n    options = webdriver.ChromeOptions()\n    # options.add_argument('--headless') # Uncomment for headless execution\n    driver = webdriver.Chrome(options=options)\n    driver.implicitly_wait(10)\n    yield driver\n    driver.quit()\n\ndef test_applitools_example(driver, applitools_runner):\n    eyes = Eyes(runner=applitools_runner)\n    eyes.api_key = APPLITOOLS_API_KEY\n    eyes.batch = BatchInfo('My Python App') # Group tests in Test Manager\n    \n    try:\n        # Open Eyes with the WebDriver, application name, test name, and viewport size\n        eyes.open(driver=driver, app_name='My App', test_name='Login Page Test', viewport_size={'width': 800, 'height': 600})\n        \n        driver.get('https://demo.applitools.com/')\n        eyes.check('Login Window', Target.window().fully())\n        \n        driver.find_element('id', 'username').send_keys('user')\n        driver.find_element('id', 'password').send_keys('password')\n        driver.find_element('id', 'log-in').click()\n        \n        eyes.check('App Dashboard', Target.window().fully())\n        \n    finally:\n        # Close Eyes to finish the test session\n        eyes.close()\n","lang":"python","description":"This quickstart demonstrates a basic visual test using `eyes-selenium` with `pytest` and Selenium WebDriver. It initializes a `VisualGridRunner` for efficient test management, sets the Applitools API key, and performs visual checkpoints on a web page. The `APPLITOOLS_API_KEY` must be set as an environment variable. The example includes navigating to a demo site, logging in, and performing visual checks on both the login and dashboard pages."},"warnings":[{"fix":"Ensure you are using the `eyes-selenium` PyPI package for installation and consult the Applitools documentation (applitools.com/docs) for the latest usage patterns.","message":"The GitHub repository `applitools/eyes.selenium.python` has been deprecated. While the `eyes-selenium` PyPI package remains the correct installation, users should refer to `applitools/eyes.sdk.python` for the latest source and potentially more up-to-date examples if direct repository interaction is needed.","severity":"breaking","affected_versions":"All versions"},{"fix":"Regularly update `ChromeDriver` to match your Chrome browser version. Consider using `webdriver-manager` for automated driver management if not already in use.","message":"The version of `ChromeDriver` (or any other browser driver) used with Selenium WebDriver must precisely match the installed version of the Chrome browser to avoid `WebDriverException` errors during initialization.","severity":"gotcha","affected_versions":"All versions using local browser drivers"},{"fix":"Set `APPLITOOLS_API_KEY` in your environment (e.g., `export APPLITOOLS_API_KEY='YOUR_API_KEY'`). Optionally, `eyes.api_key` can be set programmatically, but environment variables are recommended.","message":"Applitools tests require the `APPLITOOLS_API_KEY` environment variable to be set for authentication with the Applitools Eyes server.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always wrap your visual test logic within a `try...finally` block to ensure `eyes.close()` is called, even if exceptions occur. For runners, ensure `runner.get_all_test_results()` is called at the end of all tests.","message":"Every Applitools Eyes test session must begin with `eyes.open()` and conclude with `eyes.close()` to ensure proper test execution and result reporting. Failing to call `close()` can lead to abandoned tests.","severity":"gotcha","affected_versions":"All versions"},{"fix":"When using `VisualGridRunner` or `ClassicRunner`, call `eyes.close()` for each test instance (this will internally handle async if needed), and then `runner.get_all_test_results()` once after all tests have completed.","message":"The synchronous `eyes.close()` method returns a single test result. For parallel execution or when using runners (like `VisualGridRunner`), it's recommended to use asynchronous closing mechanisms (`eyes.close_async()`) followed by `runner.get_all_test_results()` to retrieve all results efficiently.","severity":"deprecated","affected_versions":"Versions prior to `6.x` and early `6.x` when not using runners; usage with runners where single `close()` is called."}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}