Page 1 of 1

How to make Validate.Attribute more generic w DataSource

Posted: Tue Nov 21, 2017 1:31 pm
by _KK_
Environment: A WPF-GUI is coupled at least to a PLC.
The goal for automation of testing is to write into the PLC, read the value of the PLC and compare it with the current content (value) of the GUI.
This should be made as generic as possible, so that the important values are driven from a DataSource.
Attributes are IoPath for identification of the control, value, c#DataType, TwinCatDataType and more.

The ugly thing is, that there is a lot of needed convertion because the DataType of the application and the PLC differ.
E.g.: DWORD in application is UInt32 in PLC.
The other thing is, that the GUI shows at numbers a decimal point, e.g. 12.007, 4.294.967.295

The writing and reading will be done in a "code module" and works so far.
I was not able to make the check with Validate.Attribute generic, so that every value can be checked.

My approach with items in the RxRepo:

Code: Select all

container[1]/container[3]//container[@controlname='ReportContainer']/form[@automationid='report']/container[2]/list[1]/text[@caption='5.555']

container[1]/container[3]//container[@controlname='ReportContainer']/form[@automationid='report']/container[2]/list[1]/text[@caption~'.*']

container[1]/container[3]//container[@controlname='ReportContainer']/form[@automationid='report']/container[2]/list[1]/text[@caption=$DSC_Caption_Int16]
The "Variable" DSC_Caption_Int16 has a default value, e.g.5555

code in module

Code: Select all

string _DSC_Caption_Int16 = "5.555";
        [TestVariable("588d5118-76f8-4ef9-9ec2-223bb8c34dd4")]
        public string DSC_Caption_Int16
        {
        	get { return _DSC_Caption_Int16; }
        	set { _DSC_Caption_Int16 = value; }
        }
Validate.Attribute(repo.Window.Text9999_Caption_any, "Caption", _DSC_Caption_Int16);

Is it a good idea to bind the module-variable with the "Variable" in the repo?
And how to do that?

Thanks in advance for an answer.


BR

Klaus

Re: How to make Validate.Attribute more generic w DataSource

Posted: Thu Nov 23, 2017 3:28 pm
by RobinHood42
Did you know that you can use a regex as parameter in the Validate.Attribute() method? You might not have to do a conversion at all.
e.g.
Attribute(RepoItemInfo, String, Regex)
Cheers,
Robin

Re: How to make Validate.Attribute more generic w DataSource

Posted: Mon Nov 27, 2017 2:19 pm
by _KK_
Thanks Robin,

when I use in the Validation a RegEx so I can validate only e.g. if there numbers or letters are "in".

To make my Approach more generic I use in the repo-variable a "regex" like

Code: Select all

repoVariable   PaperRun_QualityDataMeanValueFeedAirSpeed_caption_RegEx 
with Path
...........form[@automationid='report']/?/?/container[@automationid='DCA2']/*[@caption~'[0-9]']
So this is as desired generic for numbers.

In the Validate.Attribute I will use the repo-variable and validate against a DataDriven variable with actual value "in" _DSC_Caption_UInt32.
Maybe you remember that I wrote that the UI Shows the value with 1000er Separators.
To avoid reading/converting/Stripping I use maybe not the best way with my approach, but it works.

Code: Select all

Validate.Attribute(repo.Window.PaperRun_QualityDataMeanValueFeedAirSpeed_caption_RegEx, "Caption", _DSC_Caption_UInt32);
I know that I have to read more of documentation to find the "best practise".

Regards

Klaus