Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can someone provide an example for the ImageCompare methods?

I'm attempting to compare two images using Visual Studio 2013 Pro. The MSDN provides information (http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.uitesting.imagecomparer.compare.aspx) on ImageComparer.Compare, alas I'm failing to get it implemented in my code. On the last line of my code I'm told that "The name 'Compare' does not exist in the current context". Can someone please help? Thanks!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using Microsoft.VisualStudio.TestTools.UITesting;


namespace Intranet.SmokeTests
{
public class Intranet_Login : Intranet_Setup
{
    public List<string> IntranetLoginTest(string BrowserURL, string Host, int Port)
    {
            Image expected = Image.FromFile(@"\\webdriver\ImageVerification\Expected\IntranetHome.png");
            Image actual = Image.FromFile(@"\\webdriver\ImageVerification\Actual\IntranetHome.png");

            bool equal = Compare(actual, expected);
    }
}
}
like image 458
Wario X Avatar asked Nov 21 '25 12:11

Wario X


1 Answers

You must do it like this:

bool equal = ImageComparer.Compare(actual, expected);

When you want to use a class's static member in c# you must always qualify it with the class first. Otherwise the compiler will try to locate the member on the current class.

Another problem you might be having with your IntranetLoginTest is that it's supposed to return an instance of List<string>, but it doesn't. I must also say I find it strange that you are making an image comparison test in a method that would suggest it performs authentication mechanisms testing.

like image 173
Crono Avatar answered Nov 24 '25 01:11

Crono



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!