0

ビジュアル テストに aShot を使用しています。 https://github.com/pazone/ashot ページの現在表示されている部分のみのスクリーンショットを撮りたいページがいくつかあります (ページ全体のスクリーンショットはありません)。問題は、ページから除外する要素を追加すると、ページ全体の上部までスクロールしたスクリーンショットからのみ要素が除外されることです。

これは、要素がビューポートに表示されているスクリーンショットから同じ要素を除外したいが、すでにいくつかのピクセルを下にスクロールしている場合、現在配置されている領域は比較から除外されないことを意味します。

無視された領域 (座標) は、ページの上部からの距離を取得する aShot メソッドから内部的に計算され、これはページ全体のスクリーンショットで正常に機能すると想定しています。しかし、現在のビューポートのスクリーンショットになると、計算された面積は同じ座標を参照するため、要素は無視されません。

私が見逃している組み込みメカニズムがあるかどうか、またはロジックを実装する必要があるかどうかを教えてください。

以下のID私のコード

/** Set ignored areas **/
            
Set<By> allIgnoredElements = IgnoredElements.getAllIgnoredElements( getFlowType() , mapElementKey );
    
AShot aShot = new AShot();
    
for (By element : allIgnoredElements)
   aShot.addIgnoredElement(element);
    
/** Take Screenshot **/

Screenshot actualScreenshot;
if (stickyElementsCase) {

  /** Sticky elements case : loop for visible part screenshots **/
    
} else {
    
  /** NO Sticky elements case : full page screenshot**/
  aShot = aShot.shootingStrategy(ShootingStrategies.viewportPasting(1000));
    
}
    
actualScreenshot = aShot
                    .coordsProvider(new WebDriverCoordsProvider())
                    .takeScreenshot(getDriver());
    

/** Actual image **/

File actualFile = new File(
                    path + actualFileName
            );
ImageIO.write(actualScreenshot.getImage(), "png", actualFile);
    
/** Expected image **/

System.out.println("expectedDir + expectedFileName = " + path + expectedFileName);
Screenshot expectedScreenshot = new Screenshot(
                                  ImageIO.read(
                                    new File(
                                       path + expectedFileName
                                    )
                                  )
                                );
    
expectedScreenshot.setIgnoredAreas(actualScreenshot.getIgnoredAreas()); // set ignored coordinates before comparing for the master screen

expectedScreenshot.setCoordsToCompare(actualScreenshot.getCoordsToCompare()); // set coordinates which are going to be compared for the master screen
    
/** Final comparison **/

compareScreenshotsSoftAssert(path, mapElementKey, actualScreenshot, expectedScreenshot, screenShotIndex);
4

0 に答える 0