ขนาดวิดีโอ: 1280 X 720853 X 480640 X 360
แสดงแผงควบคุมโปรแกรมเล่น
เล่นอัตโนมัติ
เล่นใหม่
Dear Sir, can you please share the Python code for this series of Selenium class ? Thank you !
Did not check in GitHub.import timeimport pytestfrom selenium import webdriverfrom 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 Truedef 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
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 !
Dear Sir, can you please share the Python code for this series of Selenium class ? Thank you !
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
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 !