Page 1 of 1
Can I check for pixel's color in some area for validation
Posted: Tue Mar 29, 2016 4:56 pm
by MGeorgiev
I'm trying to do validation and check for some color ( red). If there is red pixel into that screenshot to fail the validation. Is there any chance to do that in Ranorex ?
Re: Can I check for pixel's color in some area for validation
Posted: Wed Mar 30, 2016 12:12 pm
by asdf
Hi MGeorgiev,
Ranorex is based on the .Net framework, that means you can simply use C# methods in UserCodeModules.
Here is a little sample how this could work.
Bitmap img = new Bitmap("YourScreenshot.bmp");
for(int j = 0; j < img.Height; j++)
{
for(int i = 0; i < img.Width; i++)
{
var color = img.GetPixel(i,j).Name;
if(color == "ffff0000")
Report.Failure("Fail");
else
Report.Success("Success");
}
}
Regards,
asdf
Re: Can I check for pixel's color in some area for validation
Posted: Wed Mar 30, 2016 12:55 pm
by MGeorgiev
Thank you asdf