나는 simillar 작업을했습니다. 웹 페이지에서 3000 개 이상의 이미지를 비교해야했습니다. 내가 처음 이미지와 모든 이미지의 크기를 비교 한 후
public void compareImage() throws InterruptedException {
driver.get(baseUrl);
driver.manage().window().maximize();
JavascriptExecutor executor = (JavascriptExecutor) driver;
Long previousHeight;
Long currentHeight;
do {
previousHeight = (Long) executor.executeScript("return document.documentElement.scrollHeight");
executor.executeScript("window.scrollBy(0, document.documentElement.scrollHeight)");
Thread.sleep(500);
currentHeight = (Long) executor.executeScript("return document.documentElement.scrollHeight");
} while (Long.compare(previousHeight, currentHeight) != 0);
(또는 당신은 단지 크기를 쓸 수 있습니다) : 내가 페이지를 스크롤 모든 먼저 모든 이미지를로드 C에 #
List<WebElement> images = driver.findElements(By.cssSelector("img[class='playable']"));
List<String> errors = new LinkedList<>();
int imgWidth, imgHeight, elWidth, elHeight;
int imgNum = 0;
imgWidth = images.get(0).getSize().getWidth();
imgHeight = images.get(0).getSize().getHeight();
for (WebElement el : images) {
imgNum++;
elWidth = el.getSize().getWidth();
elHeight = el.getSize().getHeight();
if (imgWidth != elWidth || imgHeight != elHeight) {
errors.add(String.format("Picture # %d has incorrect size (%d : %d) px"
, imgNum, elWidth, elHeight));
}
}
for (String str : errors)
System.out.println(str);
if (errors.size() == 0)
System.out.println("All images have the same size");
}
계산합니다. 원본 이미지와 출력 이미지를 비교할 때 어려움을 느낍니다. ImageMagick 또는 ImageDiff와 같은 도구를 사용하여 이미지 비교를 수행하지만 한 번에 하나의 이미지 세트에 대해서만 작업을 수행합니다. 이미지 세트가 500 개 이상이므로 이미지 비교를 수행하는 것은 상당히 어려운 작업입니다. 여러 가지 이미지를 한 번에 비교하는 대신 시간이 많이 걸리는 이미지를 비교하는 등 다른 방법으로이를 해결할 수 있습니다. 웹 드라이버>를 사용하여 완료 할 수 있습니까? 사전 감사 ... Sanjay .. – user1068759