Issue with the Validate method, integer and string

Ask general questions here.
Florian
Posts: 75
Joined: Fri Jul 27, 2012 12:57 pm
Location: France (Lyon)
Contact:

Issue with the Validate method, integer and string

Post by Florian » Fri Aug 03, 2012 9:20 am

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?

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Issue with the Validate method, integer and string

Post by Support Team » Fri Aug 03, 2012 2:55 pm

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

iuliaborza
Posts: 4
Joined: Thu Feb 12, 2015 3:03 pm

Re: Issue with the Validate method, integer and string

Post by iuliaborza » Thu Feb 12, 2015 3:08 pm

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Issue with the Validate method, integer and string

Post by Support Team » Fri Feb 13, 2015 4:41 pm

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

iuliaborza
Posts: 4
Joined: Thu Feb 12, 2015 3:03 pm

Re: Issue with the Validate method, integer and string

Post by iuliaborza » Thu Aug 06, 2015 1:08 pm

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

iuliaborza
Posts: 4
Joined: Thu Feb 12, 2015 3:03 pm

Re: Issue with the Validate method, integer and string

Post by iuliaborza » Thu Aug 06, 2015 1:29 pm

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

Florian
Posts: 75
Joined: Fri Jul 27, 2012 12:57 pm
Location: France (Lyon)
Contact:

Re: Issue with the Validate method, integer and string

Post by Florian » Thu Aug 06, 2015 1:42 pm

Maybe 300 is implicitly converted in string/intger, whereas "3 000,00" is different between string and integer ?

iuliaborza
Posts: 4
Joined: Thu Feb 12, 2015 3:03 pm

Re: Issue with the Validate method, integer and string

Post by iuliaborza » Thu Aug 06, 2015 2:56 pm

Yes, I think so.
So only user custom code is the solution where we can force conversion to integer?

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Issue with the Validate method, integer and string

Post by Support Team » Mon Aug 10, 2015 2:32 pm

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)
You do not have the required permissions to view the files attached to this post.