Regex in findSomething

Ask general questions here.
Skarlso
Posts: 27
Joined: Thu Aug 07, 2008 9:11 am

Regex in findSomething

Post by Skarlso » Tue Jan 20, 2009 12:54 pm

Hi!

I'm trying to use the regular expression option when searching for something. Windows, control, etc... But it never workes.. I tried the following:

form = Application.FindFormTitle(Consts.GetString("TitleQueryNumber"), SearchMatchMode.MatchRegExp, true, 25000);

Where Consts.GetString("TitleQueryNumber") inputs : 'Query [1-9] -'

( yes i tried entering it as a string and not using variables. )

This should find this window:
Query 2 - IHS Enerdeq™ Desktop Canadian

But it does not...

Any suggestions?

Thanks,
Gergely.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Tue Jan 20, 2009 2:33 pm

You are right, this should work.

Do you use the right DLLs from the Ranorex "Net2.0-Pro" folder? Regular expressions are not supported in the Ranorex 1.X free version ("Net2.0" folder).

Regards,
Alex
Ranorex Support Team

Skarlso
Posts: 27
Joined: Thu Aug 07, 2008 9:11 am

Post by Skarlso » Tue Jan 20, 2009 2:42 pm

Yeah i'm using bought Ranorex 2.0 RC1.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Tue Jan 20, 2009 2:48 pm

I think you misunderstood me. From the code you submitted I can see that you are using Ranorex 1.X. I wanted you to check that you are using the right DLLs.

You need to use the DLLs from "Net2.0-Pro" folder in the Ranorex 1.X installation folder (usually "C:\Program Files\Ranorex 1.5.1\Bin\Net2.0-Pro"). Please make sure that the RanorexCore.dll you are using stems from this folder!

Regards,
Alex
Ranorex Support Team

Skarlso
Posts: 27
Joined: Thu Aug 07, 2008 9:11 am

Post by Skarlso » Tue Jan 20, 2009 2:53 pm

Ahhh i see.

Yes the Path to the RanorexNet.dll is : D:\Program Files\Ranorex 1.5.1\Bin\Net2.0-Pro\RanorexNet.dll.

( Btw good that you mentioned this, later on i need to rewrite this to use the 2.0 dll... Note to self. )

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Tue Jan 20, 2009 3:18 pm

And do you copy the RanorexCore.dll from the same path?

Did you try using a simpler regular expression, i.e. using the whole title of the application as displayed in RanorexSpy, e.g. "Query 2 - IHS Enerdeq™ Desktop Canadian"?

Regards,
Alex
Ranorex Support Team

Skarlso
Posts: 27
Joined: Thu Aug 07, 2008 9:11 am

Post by Skarlso » Tue Jan 20, 2009 3:27 pm

I can only guess. The RanorexCore.dll was copied into the project after the project was created, so i can only guess that it was the same... But i could try to overwrite it?

The problem is that i can't use regular expressions. If i write in the whole name without regex than it can indeed find it. But that's not what i need...

What i need would be [1-9] because there can be any number from 1-9.

Thanks,
Gergely.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Tue Jan 20, 2009 5:56 pm

If searching for the whole name with SearchMatchMode.MatchRegExp worked, then you should have the right RanorexCore.dll. Otherwise, please overwrite the RanorexCore.dll from the Ranorex installation directory.

I tried Application.FindFormTitle with a similar RegEx and everything worked just as expected. Maybe the "TM" characters in the title are the problem. What is the exact title of the application in RanorexSpy?

Regards,
Alex
Ranorex Support Team

Skarlso
Posts: 27
Joined: Thu Aug 07, 2008 9:11 am

Post by Skarlso » Wed Jan 21, 2009 8:40 am

Actually I'm omitting the TM in the title because i thought that maybe it would cause trouble. The title in the spy is that which i copied in previously.

Hmmm... I don't have any ideas left then..

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Wed Jan 21, 2009 4:21 pm

Did you try using a Regex without the "[1-9]", i.e just "Query" or "Desktop Canadian"? That should work, too.

I'm also a little out of ideas, because all regular expression searches I execute work.

Regards,
Alex
Ranorex Support Team

Skarlso
Posts: 27
Joined: Thu Aug 07, 2008 9:11 am

Post by Skarlso » Wed Jan 21, 2009 4:34 pm

Yeah, and that way they do work, but i need a number to be there :S

I'm trying to use 2.0 now, but the problem is that ...

do i really need to use the Whole Xpath??

EDIT: Disregard this.. i found that */button works fine..
Exp:

Code: Select all

/form[@controlname='CoreForm']/element[@controlname='barDockControlTop']/element[@controlname='Data Tools']/*/button[@accessiblename='Query']
but i only need /button[@accessiblename='Query'] and i'm searching in the Data Tools control. But if i don't use the full xpath it does not find it.. I could use descendant but that's not the point..

EDIT: This is however still an issue.. This is should work or not? As i remember xpath allowed the use of regex in the values too..

And also.. I'm trying Regex here too... Like:

form = "form[@title='IHS Enerdeq']";
or
form = "form[@title='IHS Enerdeq*']";

But that does not find IHS Enerdeq™ Desktop Canadian too :(

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Wed Jan 21, 2009 4:49 pm

For regular expressions in path attributes please use the "~" operator:

Code: Select all

form = "form[@title~'IHS Enerdeq']";
Regards,
Alex
Ranorex Support Team

Skarlso
Posts: 27
Joined: Thu Aug 07, 2008 9:11 am

Post by Skarlso » Wed Jan 21, 2009 4:50 pm

Yeah :D Just found it... sorry.. Really appreciate the help! Thx!