简体   繁体   English

如何使用 selenium C# 按像素比较两个图像

[英]How to compare two images by pixel using selenium C#

I have two screenshots.我有两张截图。 One is expected , another one is actual .一个是预期的,另一个是实际的。 I was looking for a good way to compare those screenshots using C# for my automated selenium tests.我正在寻找一种好方法来比较使用 C# 进行自动 selenium 测试的这些屏幕截图。 I found a few decisions to do that in java but C# doesn't provide a lot.我在 java 中发现了一些这样做的决定,但 C# 并没有提供很多。 I'd appreciate any help我会很感激任何帮助

You can use ImageMagick a 3rd party application.您可以使用 ImageMagick 第三方应用程序。 It supports command line calls to do image comparison.它支持命令行调用来进行图像比较。 The following link discusses how to use the command line call: http://techblog.hotwire.com/2016/05/19/image-comparison-in-automated-testing/以下链接讨论如何使用命令行调用: http://techblog.hotwire.com/2016/05/19/image-comparison-in-automated-testing/

You can also use the nuget package for ImageMagick.您还可以将 nuget package 用于 ImageMagick。 This would allow you to embed C# calls to the nuget library in your .NET application.这将允许您在 .NET 应用程序中嵌入对 nuget 库的 C# 调用。 The following stack overflow answer discusses it: https://stackoverflow.com/a/14235661/2683997以下堆栈溢出答案对其进行了讨论: https://stackoverflow.com/a/14235661/2683997

Both of these links assumes that you have been able to do the image capture part already.这两个链接都假定您已经能够完成图像捕获部分。

You can do this by sikuli with selenium web driver您可以通过 sikuli 使用 selenium web 驱动程序执行此操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM