Issue with validating text

Ask general questions here.
Andrew
Posts: 4
Joined: Mon Jun 06, 2011 1:55 pm

Issue with validating text

Post by Andrew » Mon Jun 06, 2011 1:58 pm

Hi there. I'm currently evaluating a number of test automation tools. For initial comparison demonstrations I'm recording scripts against calc.exe. I can create the test case recording (10,+,10,=,validate '20') but whenever I click the display to validate 20 it reads the Text property as an empty string - even though the screenshot it takes displays '20' - and seems to then blank the display.

Any information is appreciated, thanks.


OS: Windows 7
Ranorex: 3.0.2.12718
.Net: 4.0.30319.225

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Issue with validating text

Post by Support Team » Mon Jun 06, 2011 6:01 pm

Hello Andrew,

the display of the Windows 7 calculator is a little complicated, because it also can contain some extra information like "M". Enter a number in the calculator for recognition in the Spy and analyze the display with the Spy. I get this RanoreXPath:

Code: Select all

/form[@title='Calculator']/element/container/text[@ControlId='150']
The RanoreXPath identifies an element and sometimes you need to adapt it a little, although mostly its only because you want to make it more general such that it works for all situations where you want to use it.

Regards,
Roland
Ranorex Support Team
.
Image

Andrew
Posts: 4
Joined: Mon Jun 06, 2011 1:55 pm

Re: Issue with validating text

Post by Andrew » Mon Jun 06, 2011 8:18 pm

Thanks very much for the response.

I'll test out the Spy further tomorrow.

Andrew
Posts: 4
Joined: Mon Jun 06, 2011 1:55 pm

Re: Issue with validating text

Post by Andrew » Tue Jun 07, 2011 11:33 am

Spy seems to give me

Code: Select all

/form[@title='Calculator']/element/container[@caption='' and @class='#32770' and @instance='0']/text[@windowtext='20']
and the related generated .cs is

Code: Select all

Validate.Attribute(repo.FormCalculator.TextN160Info, "Text", "20");
I suppose I should be able to use that xpath with validate attribute as you would with selenium, however to test that I changed the '20' references to '99' in the .cs file, ran the exe yet it still validated for '20'.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Issue with validating text

Post by Support Team » Tue Jun 07, 2011 12:37 pm

As you said yourself, the *.cs code file for a recording is automatically generated. Consequently, your changes will be overwritten every time the code for the recording is generated and that is whenever you press compile or run. That's why the first line in the recording code file says "Do not edit" :)

Please, edit the recording only within the Recorder UI or in the UserCode file. See the corresponding section in the Ranorex User Guide:
http://www.ranorex.com/support/user-gui ... rding.html

Regards,
Alex
Ranorex Team
.
Image

Andrew
Posts: 4
Joined: Mon Jun 06, 2011 1:55 pm

Re: Issue with validating text

Post by Andrew » Tue Jun 07, 2011 12:43 pm

Thanks again for your help and apologies for the silly questions. I'm evaluating a dozen different automation tools at the moment and really don't have time to go through all of the help documentation for all of them, so it's catch as catch can at the moment. I will try and have a good look through the Ranorex docs before bothering you again.