Page 1 of 2

Another "odd" 3.0 issue

Posted: Thu Mar 03, 2011 12:34 am
by Ciege
Here is an odd one, searching for a simple button is failing in 3.0 (again, this worked just fine in 2.3).

Exception:

Code: Select all

Ranorex.ElementNotFoundException: No element found for path './/button[@controlname='btnCancel' or @text='btnCancel']' within 1m.
at Ranorex.Core.Element.FindSingle(RxPath path, Duration timeout)
at Ranorex.Adapter.FindSingle(RxPath path, Duration timeout)
at RanorexFramework.RFW.PushButtonClick(Form RanorexFormName, String PushButtonName, Boolean boolHideNotFoundError) in C:\Documents and Settings\Admin\My Documents\Visual Studio 2008\Projects\RanorexFramework\RanorexFramework\Class1.cs:line 5452

Here is my code:
1st, I find the form I want to deal with (this works)

Code: Select all

Ranorex.Form HDStartupForm = RFW.WaitForWindow("HD Startup", 10);
if (HDStartupForm == null)
{
    Report.Debug("Did not find the Hard Dollar Startup dialog");
}
else
{
    Report.Debug("Found Hard Dollar Startup dialog");
    Report.Debug("Closing the dialog.");
    intResult = RFW.PushButtonClick(HDStartupForm, "btnCancel");
    if (intResult == -1)
    {
        return null;
    }
    RFW.WaitForWindowCloseByForm(HDStartupForm, 60);
}
Then I find the button (in this case "btnCancel"). This is the importand code ripped from the PushButtonClick method:

Code: Select all

RanorexFormName.EnsureVisible();
RanorexFormName.Activate();
Thread.Sleep(500);
HDbutton = RanorexFormName.FindSingle(".//button[@controlname='" + PushButtonName + "' or @text='" + PushButtonName + "']", 60000);
RanorexSpy seems to find it ok with this xPath:

Code: Select all

/form[@controlname='OpeningForm']/button[@controlname='btnCancel']

Re: Another "odd" 3.0 issue

Posted: Thu Mar 03, 2011 2:50 pm
by Support Team
Ciege wrote:Here is an odd one, searching for a simple button is failing in 3.0 (again, this worked just fine in 2.3).
I just tried that code with Ranorex 3.0 on the Hard Dollar 10 client and it worked out of the box...

Do you get any warnings in the log files?
Do you have .NET 4.0 installed?
Do you start the automating process from a network drive?

Regards,
Alex
Ranorex Team

Re: Another "odd" 3.0 issue

Posted: Thu Mar 03, 2011 3:58 pm
by Ciege
Do you get any warnings in the log files?
Are you referring to my log file that is generated during runtime? IF so, then no, other than the ElementNotFound exception I receive no other warnings or issues.
Do you have .NET 4.0 installed?
Nope.
Do you start the automating process from a network drive?
Nope.


I had run ALL of my scripts through my working 2.3 version of Ranorex. Then I reset my VMImage to base (Ranorex 2.3 installed but AUT not installed). Uninstalled 2.3, Installed 3, licensed 3 (since we needed a new license) then recompiled (through VS) and ran the scripts.
So this failure is occuring on known good Ranorex code and a known good version of the AUT. The only difference is the v3 of Ranorex DLLs.

Re: Another "odd" 3.0 issue

Posted: Thu Mar 03, 2011 4:59 pm
by Ciege
Hmmm, I've reset my image and re-installed Ranorex v3 again... Seems to be working again now... I'll need to keep an eye on this one for a bit.

Re: Another "odd" 3.0 issue

Posted: Thu Mar 03, 2011 5:04 pm
by Support Team
Ciege wrote:So this failure is occuring on known good Ranorex code and a known good version of the AUT. The only difference is the v3 of Ranorex DLLs.
This is really weird, because as a test case for 3.X backwards compatibility we ran the project you sent us regarding the following forum post:
http://www.ranorex.com/forum/treeview-n ... t1968.html
Ciege wrote:Hmmm, I've reset my image and re-installed Ranorex v3 again
Could it be that you still had the Ranorex 2.X assemblies and references to them around?

Regards,
Alex
Ranorex Team

Re: Another "odd" 3.0 issue

Posted: Thu Mar 03, 2011 5:13 pm
by Ciege
Could it be that you still had the Ranorex 2.X assemblies and references to them around?
Shouldn't be the case, I uninstalled 2.x before installing 3 and verified that the VS references we pointed to "C:\Program Files\Ranorex 3.0\Bin".
Also verified that the "C:\Program Files\Ranorex 2.x" path no longer exists.

Re: Another "odd" 3.0 issue

Posted: Thu Mar 03, 2011 5:26 pm
by Ciege
OK, it's happening again...
Here are my steps with some new information...

Back to a clean install.
Ran an existing script from the command line (I have a utility that I wrote that shows all my scripts, I select one, the utility compiles it using DevEnv.exe from VS2008).
This gets passed the login screen issue fine.
The script then fails at a place where I am trying to click a table cell (is this because of the new breaking issue that needs the flag to be set? Not sure, need to investigate this).
So I open the code in Visual Studio, set a breakpoint on the line that calls my tablecellclick method from my framework and run the script in debug mode from Visual Studio.
Now, the script cannot get passed the login screen, I get the exception that the Cancel button cannot be found.


So, if I run the script from the .exe that I compiled it works (until I hit the next error) but if I run the same script from VS then it fails on the login page.

This is repeatable, running from the .exe works (in regards to the login screen / cancel button issue) but running from Visual Studio fails.

Re: Another "odd" 3.0 issue

Posted: Thu Mar 03, 2011 9:33 pm
by Support Team
Ciege wrote:but if I run the same script from VS then it fails on the login page.
So it fails right at the start of the script. And this works with 2.X?

The only thing that makes sense is a security problem, where VS does not let Ranorex inject into the automated application. Finding the form works, because it's identified by its title, and getting the title does not need any special security rights. However, this also applies to 2.X, I really don't know what should be different there.

Have you tried compiling and debugging with Ranorex Studio instead of Visual Studio?
Do you use VS 2008 RTM or SP1? Do you start it with admin rights?
What OS do you use on that system? If it's Windows 7, is UAC enabled?
And there is no anti-virus tool or whatsoever running on that system that could interfere with automation, right? :wink:

Regards,
Alex
Ranorex Team

Re: Another "odd" 3.0 issue

Posted: Thu Mar 03, 2011 9:44 pm
by Ciege
This is on a Windows XP Pro machine (so no UAC issue).
VS 2008 RTM.
My user account is the Admin of the machine.
No AV installed.
It did all run just fine in 2.x.
This is the exact same test code I have made no edits to the test scripts between upgrading from 2.x to 3.x.

Everything is the same on this machine as it was from the 2.x installation except:
1) 2.x is removed
2) 3.x is installed
3) All important Windows patches for XP Pro that were current as of 3/2/11 we installed (this *may* have something to do with it)

I have not tried from Ranorex Studio. Do I need to do anything special with my VS project to get it to run in Ranorex Studio?
So it fails right at the start of the script. And this works with 2.X?
It's not exactly the beginning of the script but pretty close. It goes through starting the AUT, searching for a couple of windows, finds the startup window (successfully) then tries to close the window via the cancel button.


I'm also going to try, on this setup, removing 3.x and installing 2.3 back and see what it does.

Re: Another "odd" 3.0 issue

Posted: Thu Mar 03, 2011 9:58 pm
by Ciege
OK, same machine. I uninstalled nothing (still have 3.x installed). I installed 2.3.0 (yes I know... 2.3.9 is the latest but 2.3.0 is *my* last know good configuration), set all the Ranorex references to the 2.3 DLLs. Ran my test through VS, and it worked fine.

Then, without changing anything (nothing installed/uninstalled/no reboot/etc...) changed all the Ranorex references to the 3.x DLLs, and it failed finding the Cancel button as before.

So I would say that's quite conclusive that the 2.3.0 DLLs work as expected in VS with my AUT and the 3.x version of the DLLs do not work as expected in the exact same environment.

Re: Another "odd" 3.0 issue

Posted: Fri Mar 04, 2011 4:03 pm
by Support Team
I could reproduce that problem now on a Windows XP VM (without updates) and with Visual Studio RTM installed. If you use Visual Studio 2008 to debug the Ranorex automating process and have the "Visual Studio hosting process" enabled, Ranorex cannot inject into the target process and recognition of WinForms controls inside your application fails.
This does not happen when you debug with Ranorex Studio or disable the "Enable the Visual Studio hosting process" setting in the Visual Studio project "Debug" properties.

I'm not sure why this happens, because we do exactly the same every day when we develop Ranorex (using VS to debug our own Ranorex code) and don't have any problems at all. The only difference is that we use Visual Studio 2008 SP1 and have all security patches installed. I will dig a little deeper next week, did not have time today, sorry! :?

Regards,
Alex
Ranorex Team

Re: Another "odd" 3.0 issue

Posted: Fri Mar 04, 2011 4:11 pm
by Ciege
Well, the good news is that you did reproduce the issue... Are you guys tired of me finding these off the wall strange issues yet? :lol:

I'll look into updating VS to SP1. Need to first verify that SP1 will not break anything else for the other development I do here, but it shouldn't be the problem. If that solves the issue I will be happy with that and would consider the "fix" for this issue to be the SP1 patch. Strange that the v3 DLLs would cause this issue while the 2.x DLLs do not, but we are all in software here and I've seen my fair share of "that shouldn't happen" issues!

Thanks for looking into it, I'll let you know what I find...

Re: Another "odd" 3.0 issue

Posted: Fri Mar 04, 2011 5:20 pm
by Ciege
Well that is a negative ghostrider... The SP1 update to my installed VS 2008 did not make a difference. Still same issue with unable to find and click a button when running from within VS. Disappointing...

Re: Another "odd" 3.0 issue

Posted: Mon Mar 07, 2011 6:15 pm
by Ciege
This does not happen when you debug with Ranorex Studio or disable the "Enable the Visual Studio hosting process" setting in the Visual Studio project "Debug" properties.
Where do I find this setting? I can't seem to find it under Tools -> Options -> Debugging.

Re: Another "odd" 3.0 issue

Posted: Mon Mar 07, 2011 7:53 pm
by Support Team
Ciege wrote:Where do I find this setting? I can't seem to find it under Tools -> Options -> Debugging.
Project Settings -> Debug -> Enable Debuggers -> Enable the Visual Studio hosting process

I have an update on this issue, too. The problem is specific to Windows 2000 and Windows XP. Only on those operating systems if you debug with Visual Studio and have the "Enable the Visual Studio hosting process" enabled, Ranorex cannot recognize Windows Forms controls any more.
I pinned this problem down to a security rights problem, where an access rights flag was used in Ranorex code that behaves differently in Windows XP and Vista. So if you don't have full access rights in the automating process - as this is the case when you use the VS hosting process to debug -, Ranorex could not open the automated process any more, which is required to correctly identify Windows Forms controls.

To cut a long story short: This should be fixed with the upcoming version 3.0.1.

Regards,
Alex
Ranorex Team