Visual Regression Test in Selenium Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ม.ค. 2025

ความคิดเห็น • 3

  • @mariaremedios-w2y
    @mariaremedios-w2y หลายเดือนก่อน

    Dear Sir, can you please share the Python code for this series of Selenium class ? Thank you !

    • @testautomation999
      @testautomation999  หลายเดือนก่อน

      Did not check in GitHub.
      import time
      import pytest
      from selenium import webdriver
      from PIL import Image, ImageChops
      @pytest.fixture(scope="function")
      def setup():
      options = webdriver.ChromeOptions()
      driver = webdriver.Chrome(options)
      driver.implicitly_wait(10)
      driver.maximize_window()
      yield driver
      driver.quit()
      def capture_screenshot(driver, file_path):
      driver.save_screenshot(file_path)
      def images_compare(baselineImage, NewImage, diff_image):
      image1 = Image.open(baselineImage)
      image2 = Image.open(NewImage)
      # Compare images
      diff = ImageChops.difference(image1, image2)
      if diff.getbbox():
      diff.save(diff_image)
      return False
      return True
      def test_Home_Screenshot_comparison(setup):
      driver = setup
      driver.get("admlucid.com/")
      time.sleep(5)
      # Capture new screenshot
      new_screenshot_path = "C:/Users/luluk/PycharmProjects/pythonSeleniumProject/screenshots/home_screenshot.png"
      capture_screenshot(driver, new_screenshot_path)
      # Compare new screenshot with baseline
      baseline_screenshot_path = "C:/Users/luluk/PycharmProjects/pythonSeleniumProject/screenshots/baseline/home_screenshot.png"
      diff_screenshot_path = "C:/Users/luluk/PycharmProjects/pythonSeleniumProject/screenshots/diff_home_screenshot.png"
      Thanks

    • @mariaremedios-w2y
      @mariaremedios-w2y หลายเดือนก่อน

      Thank you for the response. I would like to request ALL the Python code ( not only this lecture ) for the "Automation Test 101 for Python Selenium class". Please share. Thank you !