< All Topics

Integrating Imagium with Python and selenium for Visual Regression is a cake walk. Just like any other programing language and tool we need to to send screenshot in base64 format and that should be all. For more details on Imagium API’s check here

Please find below a sample code for python & selenium integration with Imagium

from selenium import webdriver
import requests
testNameImagium = "Python Selenium";
projectKeyImagium = '7991bf3d-060d-481d-9da4-4b885373f58b';
uidEndPointImagium = 'http://192.168.2.13:80/api/GetUID';
validateEndPointImagium = 'http://192.168.2.13:80/api/Validate';

#Generate unique test run ID
#Only one test run ID is needed for a single test case
#Test name and step name should not contain special charecters like @ # & % ^ '
uid = requests.post(uidEndPointImagium, {'TestName': testNameImagium, 'ProjectKey': projectKeyImagium })
testUID = uid.text.replace('\"','')

#Launch browser using selenium
driver = webdriver.Chrome('C:\\drivers\\chromedriver.exe')
driver.get("https://www.google.com/")

#Get screenshot as Base64 image
base64 = driver.get_screenshot_as_base64()

#Validate using Imagium
#Test name and step name should not contain special charecters like @ # & % ^ '
validate = requests.post(validateEndPointImagium, {'StepName': 'Step 1', 'TestRunID': testUID, 'ImageBase64': base64})


Previous 8. Integration with Cypress.io
Next 10. Integration with C# and Selenium
Table of Contents