Unable to recognize the working form

Ask general questions here.
amith.saddi
Posts: 3
Joined: Fri Oct 16, 2015 4:41 pm

Unable to recognize the working form

Post by amith.saddi » Fri Oct 16, 2015 4:47 pm

I'm using visual studios 2012 with ranorex evaluation version.
It gets stuck at 2nd line and waits for ages but doesn't carry on with any exception, Unable to associate the process to Ranorex form.

System.Diagnostics.Process pr = System.Diagnostics.Process.Start("calc.exe");
Form form = Host.Local.FindSingle<Ranorex.Form>("form[@processname='" + pr.ProcessName + "']");
form.Activate();

From output window :
'QTAgent32.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Ranorex.Libs.Licensing\5.4.2.25689__b798506b574ebc9a\Ranorex.Libs.Licensing.dll'
'QTAgent32.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Ranorex.Libs\5.4.2.25689__b798506b574ebc9a\Ranorex.Libs.dll'
'QTAgent32.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\Ranorex.Core.WinApi\v4.0_5.4.2.25689__b798506b574ebc9a\Ranorex.Core.WinApi.dll'
A first chance exception of type 'System.Security.SecurityException' occurred in mscorlib.dll
A first chance exception of type 'System.Security.SecurityException' occurred in mscorlib.dll
'QTAgent32.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Management\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Management.dll'
The thread '<No Name>' (0x8244) has exited with code 0 (0x0).
The thread '<No Name>' (0x3f04) has exited with code 0 (0x0).
The thread '<No Name>' (0x8f74) has exited with code 0 (0x0).
The thread '<No Name>' (0x7344) has exited with code 0 (0x0).
The thread '<No Name>' (0x1b18) has exited with code 0 (0x0).
The thread '<No Name>' (0x526c) has exited with code 0 (0x0).
The thread '<No Name>' (0x2fd4) has exited with code 0 (0x0).
The thread '<No Name>' (0x3554) has exited with code 0 (0x0).

amith.saddi
Posts: 3
Joined: Fri Oct 16, 2015 4:41 pm

Unable to find form from application

Post by amith.saddi » Mon Oct 19, 2015 11:12 am

Windows 8.1
Visual Studio : Premium 2012 with Update 4
Ranorex : 5.4.2.25689

Language C#:
[TestMethod]
public void TestMethod1()
{
try
{
System.Diagnostics.Process pr = System.Diagnostics.Process.Start("calc.exe");
Form form = Host.Local.FindSingle("form[@processname='" + pr.ProcessName + "']");
form.Activate();
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
}


Problem Description :
Unable to find form from application, hangs on below line for ages but doesnt exception
Host.Local.FindSingle("form[@processname='" + pr.ProcessName + "']");
Process starts up correctly by launching the calc.exe application, but Ranorex is unable to find the form by process name.

Runs fine if recorded and played back using Ranorex studio.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Unable to find form from application

Post by odklizec » Mon Oct 19, 2015 3:39 pm

Hi,

I believe you need to add dot and slash before the "form" element...
Form form = Host.Local.FindSingle("./form[@processname='" + pr.ProcessName + "']");
I've stuck on this too when I started using Find methods ;) Hope this helps?

PS: I need to correct myself. The "dot" in front of the slash is required only if there is not used full xpath. I just tried your sample without ./ and it worked for me OK. So I'm not quite sure what could be the reason of your problem?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

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

Re: Unable to recognize the working form

Post by Support Team » Tue Oct 20, 2015 12:56 pm

Hi amith.saddi,

Unfortunately, I am not aware of such an issue. May I ask you if you could attach your solution to this topic? Alternatively, you could also send it to [email protected]
This would allow me to try reproducing the mentioned behavior on my machine.
Thank you in advance.

Regards,
Markus (S)
.
Image