Page 1 of 1

Dynamic Winform Application failed identify elements

Posted: Tue Jun 04, 2013 5:56 am
by bonniehwang
The test case is failed (timeout) due to not found the element. See attached snapshot. The app is using winform and it seems the button is dynamic.

When trying to edit xPath, a message pops up showing no element was found for button.
See xPath as follows:
/form[@controlname='frmSmartTradeMain']/container[@controlname='rrbTool']/button/button[@accessiblename='New' and @accessiblerole='PushButton' and @text='New' and @accessibledescription~'^RadButton\ ;New;255,\ 240,\ ']

Re: Dynamic Winform Application failed identify elements

Posted: Wed Jun 05, 2013 5:47 am
by bonniehwang
It seems works when modify the xpath to /form[@controlname='frmSmartTradeMain']/container[@controlname='rrbTool']/menubar/tabpage[@accessiblerole='PageTab' and @accessibledescription='Jobs']

which previously is

/form[@controlname='frmSmartTradeMain']/container[@controlname='rrbTool']/tabpage/tabpage[@accessiblename='Jobs' and @accessiblerole='PageTab' and @accessibledescription='Jobs']

recorded by recorder. This is the first action to click "Jobs" from the menu.

However, the second action "New" which is the secondary menu under "Jobs" doesn't work well, unless I move mouse down manually then it can recognize the element "New". See attached picture.

The xpath for the second action is modified as
/form[@controlname='frmSmartTradeMain']/container[@controlname='rrbTool']/menubar/button[5]
and previously is
/form[@controlname='frmSmartTradeMain']/container[@controlname='rrbTool']/button[@accessiblename='New' and @text='New']

Questions:
1. Is any method the "New" button can be recognized automatically instead of manually moving down mouse by human being?
2. It seems recording/playback doesn't work smoothly. Is any other approach to design automation test suites? Any suggestion are appreciated.

Re: Dynamic Winform Application failed identify elements

Posted: Wed Jun 05, 2013 12:48 pm
by Support Team
Hi,

It sounds like a problem with the .Net framework.
Could you please check if the full/extended version of the .Net 4.0 framework is installed on your machine?
If not, please install it.
It can be downloaded here: .NET WinForms.
After you installed the extended one you have to reinstall Ranorex and please use the Ranorex-X.exe or the setup.exe file for the reinstallation since the prerequisites will be installed too when using one of these files.

Regards,
Markus

Re: Dynamic Winform Application failed identify elements

Posted: Thu Jun 06, 2013 12:14 am
by bonniehwang
Hi Markus,

The computer already have .NET 4.0 full version installed. And I re-installed it again according to your instruction, it still doesn't work well. So it's not the issue with .NET framework. Any other suggestion please?

The system is 64-bit OS, and somehow when clicking "edit" of the xPath, Spy (32-bit) pop up automatically.
And then I changed the Target CPU to "Any Processor" under compiling tab of project option which is 32-bit by default. And the issue still exists. Thus, it is nothing to do with target CPU.

I can't find anything else I can do, but just wondering why it automatically uses Spy (32-bit) rather than 64 bit which matches my operation system.

BTW: Is any other way better than recording?

Thanks
Bonnie

Re: Dynamic Winform Application failed identify elements

Posted: Thu Jun 06, 2013 12:01 pm
by mzperix
You can manually edit the rxpath in ranorex studio or in ranorex spy. I usually use spy, because I can see immediately what Ranorex finds, and it shows the element's attributer right away.

Adding items can be done by using the spy (right click on an element and select add to repository, you can't add if the test suite is open in ranorex studio) or creating a new element in the repository and editing it's rxpath manually, or even dynamically through coding.

You can move your mouse to any position in the screen, being an absolute coordinate (not so recommended), or a relative position of a recorded item. This relative position can be even over the boundaries of the repository item. Just set the location parameter like this: 0.5;1.5 This moves the mouse pointer to 50% of it's length, and moves 150% of it's height beginning from the element's left upper corner.

By your desription, I think the problem is that before you move your mouse over the 'New' button item, it's ranorexpath is different than after the mouseover event. So you have to make a move action to the item, and after it make the click on your recorded element.

What you could do is this:
1. find the ranorexpath of the 'New' button BEFORE you move your mouse over the 'New' button
2. get this item in your repository
3. create a mousemove action in your recording file on this newly recorded repository item, so it moves on your 'New' button
4. make the click on the item whith the originally recorded ranorexpath

Hope I was clear, and it helps.

Regards,
Zoltan

Re: Dynamic Winform Application failed identify elements

Posted: Fri Jun 07, 2013 5:08 am
by bonniehwang
Added a mouse move, but error message shows "the string '.5;1.5' is not a valid location" and tried other from the drop-down box as well, nothing is correct except '0:0'.

It works anyway by adding a mouse move with location '0:0'. It moved up and somehow then move down to the button 'New'. Is there a theory to explain?

Per my understand, location can't be set for mouse over.

Re: Dynamic Winform Application failed identify elements

Posted: Mon Jun 10, 2013 1:01 pm
by mzperix
I tried in a web based application the following code and it worked well for me:

Code: Select all

repo.HRPro.Login_logout.Link_Logout.MoveTo("-5.0;.5");
As long as Ranorex finds an element you can set moveto actions to any point of the visible desktop from the relative position of the elements upper left corner.

You have to use dots in at least of the parameters so it will read the number as percent and not as a pixel. For example, if you use ("2;2"), it will move 2 pixels right and 2 pixels down from the elements left upper corner. And if you use ("2.0;2.0"), it will move 200% right of its lenght and 200% down of its height from the elements upper left corner.

The negative double parameter means, that the mouse should move to left instead of right. I got an out of boundary error if I tried to move the mouse outside of the visible desktop.