Page 1 of 1

Field validation error when using program.cs

Posted: Tue Nov 10, 2009 6:58 pm
by tsyingling
Had this happen only twice now on two different fields (out of hundreds) but no idea what it means. I'm not a programmer by trade so this may be something simple? When I run the following generated code as part of the recording (play file) it works fine.

Validating AttributeEqual condition (Text='( ) - ') on item 'TextNumber (WebDocumentRhapsody)'.");
Validate.Attribute(repo.WebDocumentRhapsody.TabPageListTabControl2.TextNumber, "Text", "( ) - ");
Delay.Milliseconds(100);

However when this part of the code runs as part of the compiled exe for the project, I get the following error:

Attribute 'Text' of element '{Text:Number}' does not match the specified value (actual='( ) - ', expected='( ) - ').
2009/11/10 12:40:25.135 ERROR User Ranorex.ValidationException: Attribute 'Text' of element '{Text:Number}' does not match the specified value (actual='( ) - ', expected='( ) - '). at Ranorex.Validate.IsTrue(Boolean condition, String message, Boolean exceptionOnFail) at Ranorex.Validate.Attribute(Element element, String name, Object value, String message, Boolean exceptionOnFail) at Ranorex.Validate.Attribute(Element element, String name, Object value) at PhysicianPNTab.PPNAdd.Start() in c:\Documents and Settings\yingti00\My Documents\RanorexStudio Projects\PhysicianPNTab\PhysicianPNTab\PPNAdd.cs:line 62 at PhysicianPNTab.Program.Main(String[] args) in c:\Documents and Settings\yingti00\My Documents\RanorexStudio Projects\PhysicianPNTab\PhysicianPNTab\Program.cs:line 39

As I said, I've only had this twice on two different fields in two different projects and the other field seemed like just a simple text field. Haven't had this anywhere else yet. Can I correct for this using the app tools for Studio?

Re: Field validation error when using program.cs

Posted: Wed Nov 11, 2009 5:20 pm
by Support Team
What's the version of Ranorex you are using?
What kind of application is it you try to automate (.NET WinForms, WPF, Silverlight, Web, ...)?
Could you attach a Ranorex snapshot of the TabPageListTabControl2 element to your post (see http://www.ranorex.com/support/user-gui ... html#c2072)?

Regards,
Alex
Ranorex Support Team

Re: Field validation error when using program.cs

Posted: Thu Nov 12, 2009 6:16 pm
by tsyingling
The version of Ranorex Studio is 2.1.2.6480.
The application is a Silverlight application.
When I used Ranorex Spy to capture the screen, it captured the tab as "TabPage 'TabItem'". Captured all 5 tabs as "TabPage 'TabItem'". I tried to follow the instructions in the user guide link but I'm not even sure I have a <SCROLL> shortcut so I hope I got what you needed. I noticed in the repository that was created with the recorder that the same tab was captured as 4 different increments (TabPageListTabControl, TabPageListTabControl1, etc.) even though it was the same tab all 4 times. I've attached the repository from the recording as well. Hope this makes sense. Not sure it does to me.

Re: Field validation error when using program.cs

Posted: Wed Nov 18, 2009 6:34 pm
by Support Team
We identified this to be a bug of the code generation in Ranorex Studio. Ranorex Studio has a setting to convert tabs to spaces and vice versa. This setting caused tabs and spaces in string values to be converted, too; so the 4 spaces in your validation string are converted to a tab and consequently do not match the actual value of the element.

This bug will be fixed in the next Ranorex service release V2.2.1.
Meanwhile, as a workaround please check the "Convert Tabs to Spaces" checkbox in the Ranorex Studio "Tools -> Options -> Text Editor -> Behavior" tab page.

Regards,
Alex
Ranorex Support Team