问题
I am attempting to migrate the regression tests for my company's website from Selenium 2.31 and Chrome 25 to Selenium 3.14 and Chrome 75. The tests use a screenshot system where screenshots are taken in the process of the tests and compared with a baseline. In the process, I've encountered an issue where with the same tests, just across different runs, there are small differences in the rendering of small sections of the page that cause the tests to fail.
The tests are run on AWS medium3 machines with Xeon E5-2670's each time. Usually for a particular test, the differences are in the same place - sometimes showing up and sometimes not. I've created a small experiment doing this with google's home page and also found the same thing happening.
{
webDriver = CreateDriver(chromeOptions);
Helper.ResizeBrowserWindows(webDriver);
for(int i = 1; i < 200; i++) {
webDriver.Navigate().GoToUrl("http://www.google.ca");
new OpenQA.Selenium.Support.UI.WebDriverWait(webDriver, new System.TimeSpan(0, 0, 10)).Until(
d => ((IJavaScriptExecutor)d).ExecuteScript("return document.readyState").Equals("complete"));
screenshot.tryMatch("google" + i + ".png");
}
return true;
}
The differences do not show every time. For example, google198.png is different than google199.png and the difference can be seen with an image diff tool like https://online-image-comparison.com/ (with Fuzz set at 0 since we use image-to-byte array conversion and byte array comparison) the difference
Has anyone seen this happen or knows what it could be about? I am aiming to find the cause and address that somehow rather than just finding a work-around (like raising tolerance).
回答1:
So i found a solution for my case. Using the --disable-partial-raster flag fixed this inconsistency on Chrome 75. Not exactly sure why (i've contacted the google people for this) but it works.
来源:https://stackoverflow.com/questions/57096549/inconsistent-results-with-small-pixel-rendering-differences-for-the-same-seleniu