Page 1 of 1

Issue with the Validate method, integer and string

Posted: Fri Aug 03, 2012 9:20 am
by Florian
To be quick, here is the message I got:

Code: Select all

Attribute 'Value' of element for item 'ldlcV3Repository.LDLC.Panier.txt_QuantiteFirstProduit' does not match the specified value (actual='5', expected='5').
It's quite weird when you read that, isn't it? :)

Actually, I think the problem is the type of the variable. One is an Integer, the other one may be a String.
Here is the userCode:

Code: Select all

Dim iQuantite as Integer
iQuantite = repo.LDLC.Panier.txt_QuantiteFirstProduit.Value
repo.LDLC.Panier.btn_QuantitePlus.Click() //a web button which increase the quantity of a product
Validate.Attribute(repo.LDLC.Panier.txt_QuantiteFirstProduitInfo, "Value", iQuantite + 1
If I run this code, I get the error above.

I find a solution with this following code:

Code: Select all

Dim iQuantite as Integer
iQuantite = repo.LDLC.Panier.txt_QuantiteFirstProduit.Value
repo.LDLC.Panier.btn_QuantitePlus.Click()
dim iNewQuantite as Integer = repo.LDLC.Panier.txt_QuantiteFirstProduit.Value
validate.AreEqual(iQuantite+1,iNewQuantite)
Now it works
Do you think it is due to the String/Integer variables?

Re: Issue with the Validate method, integer and string

Posted: Fri Aug 03, 2012 2:55 pm
by Support Team
Hi,

You are right the problem is the conversion between an integer and a string. The method Validate.Attribut() tries to convert the value into the right type in case that the value is a string. Ranorex doesn't convert it into a string when the type is an, e.g. integer.

I treat it as a feature request and add it into our bug tracking system.

Thank you!

Regards,
Bernhard
Ranorex Support Team

Re: Issue with the Validate method, integer and string

Posted: Thu Feb 12, 2015 3:08 pm
by iuliaborza
Hello,

we have an old version of Ranorex and I need to know if this issues was solved or not? And if yes, could you please let me know in what version.

Thank you,
Iulia

Re: Issue with the Validate method, integer and string

Posted: Fri Feb 13, 2015 4:41 pm
by Support Team
Hello Iulia,

Unfortunately, there is no feature in order to convert an integer into a string and vice versa automatically, but you can do the conversion before the validation step as described by Florian.
I hope this workaround also works for you.

Regards,
Bernhard

Re: Issue with the Validate method, integer and string

Posted: Thu Aug 06, 2015 1:08 pm
by iuliaborza
Hello,

Thank you for the answer.

We have manage to do this but we have using user custom code in order to be able to do the conversion.
There is another way to solve this or not?
Can you give me an example, please?

Thank you,
Iulia

Re: Issue with the Validate method, integer and string

Posted: Thu Aug 06, 2015 1:29 pm
by iuliaborza
HI,

This Is my problem, more exactly,

00:00.842 Failure Validation Jump to itemOpen in SpyAttribute 'Text' of element for item 'Control7ScenariosRepository.FormVisma_Control_7__VSWS_WS1.CashFlowItemsRegister.BasicInfo.Amount' does not match the specified RegEx (actual='3 000,00', regex='3 000,00').
00:01.013 Error Module Jump to itemOpen in SpyView HelpModule execution was aborted because a validation step has failed. Attribute 'Text' of element for item 'Control7ScenariosRepository.FormVisma_Control_7__VSWS_WS1.CashFlowItemsRegister.BasicInfo.Amount' does not match the specified RegEx (actual='3 000,00', regex='3 000,00').
Show/Hide Stacktrace

If I use 300 instead of 3 000 is working this type of validation.
If you have any other suggestion/solution please let me know.

Thank you,
Iulia

Re: Issue with the Validate method, integer and string

Posted: Thu Aug 06, 2015 1:42 pm
by Florian
Maybe 300 is implicitly converted in string/intger, whereas "3 000,00" is different between string and integer ?

Re: Issue with the Validate method, integer and string

Posted: Thu Aug 06, 2015 2:56 pm
by iuliaborza
Yes, I think so.
So only user custom code is the solution where we can force conversion to integer?

Re: Issue with the Validate method, integer and string

Posted: Mon Aug 10, 2015 2:32 pm
by Support Team
Hi lulia,

Sometimes controls have an invisible control character in their attributes. Therefore, I may ask you to try the following approach.
  • Open Ranorex Spy Tool and track the element in question.
  • Switch to the 'overview tab' on the right side
  • Right click on the desired attribute
  • Select 'Copy Value'
  • Insert this value in your validation action
Spy_Copy_Value.png
Please let me know if this solves your problem.

Regards,
Markus (S)