Image Valiation with Code Module.
Posted: Wed Mar 27, 2019 12:07 pm
Hello Team,
I am currently using trial version Ranorex 8. I struck with below issue while writing a test case. I tried online help but everything deals with Recording and not with code module.
I have created a test case with Code Module and not through Recordings. I have a below piece of code to validate image. I could successfully compare the image and I could see the difference in the Report. But even if the Image is not matching the report shows successful with Green pie diagram and not Red. I added validation screen shot in .rxrep file with file name : Screenshot1. I would like to know how to record the failure when the images are not matching with code module.
Attached a Report which shows successfull with an value 140 but actual value is 280. I wish to see Report failed. Is there a setting to be made or extend this code ?
If you need further information please let me know. Thank you.
What I found: I could find a solution in https://www.ranorex.com/blog/enhanced-f ... alidation/. The output is what I expect. But, the description for above is for Recording and not for code module. I could not see the ‘Report difference Image’ inside properties as described in above link. For which I need a support.
I am currently using trial version Ranorex 8. I struck with below issue while writing a test case. I tried online help but everything deals with Recording and not with code module.
I have created a test case with Code Module and not through Recordings. I have a below piece of code to validate image. I could successfully compare the image and I could see the difference in the Report. But even if the Image is not matching the report shows successful with Green pie diagram and not Red. I added validation screen shot in .rxrep file with file name : Screenshot1. I would like to know how to record the failure when the images are not matching with code module.
Attached a Report which shows successfull with an value 140 but actual value is 280. I wish to see Report failed. Is there a setting to be made or extend this code ?
If you need further information please let me know. Thank you.
What I found: I could find a solution in https://www.ranorex.com/blog/enhanced-f ... alidation/. The output is what I expect. But, the description for above is for Recording and not for code module. I could not see the ‘Report difference Image’ inside properties as described in above link. For which I need a support.
Code: Select all
namespace SussGUITestAutomation.TestCases.CircularGauge
{
[TestModule("31001416-BDDB-4879-9ACC-22EEBA993057", ModuleType.UserCode, 1)]
public class TC_CircularGaugeRangeCheck : TestCase, ITestModule
{
private readonly SussGUITestAutomationRepositoryFolders.TabPageCircularGaugeFolder _repoCircularGauge =
Repos.Gallery.TabPageList.TabPageCircularGauge;
public override void Execute()
{
DoStep(
1,
"compare image and validate the slider.",
$"Upper Value is defined.",
() =>
{
SetValueAndValidate(140, _repoCircularGauge.Ranges.Upper_Container.Upper_EditInfo , _repoCircularGauge.Ranges.Upper_Container.UpperSliderInfo);
Ranorex.Validate.CompareImage(_repoCircularGauge.RangeIndicatorPanelInfo,
_repoCircularGauge.RangeIndicatorPanelInfo.GetScreenshot1(), new Imaging.FindOptions(0.85),
"Show Difference", new Validate.Options() {ReportDifferenceImages = Ranorex.Validate.ResultOption.Always,
ReportSimilarity = Ranorex.Validate.ResultOption.Always} );
});
}
private void SetValueAndValidate(int _value,RepoItemInfo _edit, RepoItemInfo _slider)
{
Report(Do.Text.SetText(_edit,_value));
Report(Do.Keyboard.Press(Keys.Tab));
Report(Validate.Slider.HasExpectedValue(_slider, _value));
}
}