liumiaomiao 1 vuosi sitten
vanhempi
commit
c3a51d91a9
1 muutettua tiedostoa jossa 6 lisäystä ja 3 poistoa
  1. 6 3
      lib/linkapi.py

+ 6 - 3
lib/linkapi.py

@@ -14,8 +14,8 @@ class APILink():
         self.browser.close()
         self.playwright.stop()
 
-
-    def save_screenshot(self,url, output_path, elements, clip=None):
+    #网页截图模糊遮罩方法,适用于网页有动态元素,进行遮罩比较
+    def save_screenshot_mask(self,url, output_path, elements, clip=None):
         locs = []
         self.page.goto(url)
         for element in elements:
@@ -23,7 +23,10 @@ class APILink():
             locs.append(loc)
         self.page.screenshot(path=output_path,mask=locs, clip=clip)
 
-
+    #网页直接截图方法,适用于网页元素不变,可直接截图比较
+    def save_screenshot(self,url, output_path, clip=None):
+        self.page.goto(url)
+        self.page.screenshot(path=output_path, clip=clip)
 
     def compare_images(self, image1_path, image2_path):
         image1 = Image.open(image1_path)