The Method Attribute(RepoItemInfo, String, Regex, String) can send a Message to the Log:
Validate.Attribute(RepoItemInfo, AttributeName, Regex, String2Log)
"{0}" is replaced by the name of the itemInfo object, "{1}" by the attribute name.
But what if the real attribute value should be logged?
How can I write the real attribute value (not the Regex) into the Log?
-> Feature request: "{2}" is replaced by the attribute value.
Write attribute value to Log with Attribute(RepoItemInfo)?
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Write attribute value to Log with Attribute(RepoItemInfo)?
This feature is currently not available, mainly because not in all cases it is possible to get the actual value of the attribute, e.g. if the element corresponding to the repository item cannot be found. Anyway, I added a feature request for that placeholder; I guess in the case that the actual value cannot be obtained, we will then just use the empty string to replace the placeholder.mats wrote:How can I write the real attribute value (not the Regex) into the Log?
-> Feature request: "{2}" is replaced by the attribute value.
For now, there is another (internally used, non-documented) placeholder string ("@Validate.AttributeREASON@") that is replaced by the reason why a validation failed (or the empty string if the validation succeeds). I don't know if that is good enough for you at the moment
Regards,
Alex
Ranorex Team
Re: Write attribute value to Log with Attribute(RepoItemInfo)?
Thank you for this internal function.
But it is not exactly what I need.
For example I want to write the value of my titlebar into the Report, because therein is the Product Release String.
The placeholder string ("@Validate.AttributeREASON@") is replaced by the reason only if a validation failed. Is it possible to write this reason into an other string, or to start a validation without exception and without 'validation failure' in the Report?
This Example writes the whole exception string into the Report, but I need only the actual value:
But it is not exactly what I need.
For example I want to write the value of my titlebar into the Report, because therein is the Product Release String.
The placeholder string ("@Validate.AttributeREASON@") is replaced by the reason only if a validation failed. Is it possible to write this reason into an other string, or to start a validation without exception and without 'validation failure' in the Report?
This Example writes the whole exception string into the Report, but I need only the actual value:
Code: Select all
try
{
Validate.EnableReport = false;
Validate.Attribute(repo.Login_ARTS_Explorer.TitleLogin_ARTS_Explorer_3_x, "Text", new Regex("Value"), "Test2: " + "@Validate.AttributeREASON@");
Validate.EnableReport = true;
}
catch (RanorexException e)
{
Report.Info("Expected RanorexException occured: " + e.ToString());
}
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Write attribute value to Log with Attribute(RepoItemInfo)?
I think the easiest way to achieve that functionality right now is to write your own method performing the validation. The code for that method could look like the following:
Alex
Ranorex Team
object value = repo.MyText.Text; // get value by adapter property value = repo.MyText.Element.GetAttributeValue("Text"); // value get by attribute name string stringValue = Ranorex.Core.ValueConverter.ToString(value); Validate.AreEqual(stringValue, regex, "Your message containing the attribute value '" + stringValue + "'.");Regards,
Alex
Ranorex Team
Re: Write attribute value to Log with Attribute(RepoItemInfo)?
This code is working.
My problem was the fact that the Itemname in the Repository 'repo.MyText' was, but in the *.cs and *.UserCode.cs 'repo.MyTextInfo'. So I had to delete the suffix 'Info'!
My problem was the fact that the Itemname in the Repository 'repo.MyText' was, but in the *.cs and *.UserCode.cs 'repo.MyTextInfo'. So I had to delete the suffix 'Info'!
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Write attribute value to Log with Attribute(RepoItemInfo)?
This feature will be available with Ranorex 3.0.1 (projected release date is end of March 2011).mats wrote:-> Feature request: "{2}" is replaced by the attribute value.
Regards,
Alex
Ranorex Team