Can not find element on form : Automation API

Can not find element on form

Class library usage, coding and language questions.

Can not find element on form

Postby brca » Fri Jan 30, 2009 3:24 pm

Hi.

I am evaluating Ranorex 2.0 RC1 for my company.

I have problem with getting text field element. Application is written in Delphi
I always get ElementNotFoundException.

Code: Select all
try:
    path = "/form[@title='Log On'and@processname='Builder'and@class='TLogInForm']"
    loginForm = Ranorex.Host.Local.FindSingle[Ranorex.Form](path, self._timeout)           
    if not loginForm.Active:
        try:
            loginForm.Activate()
        except Ranorex.ActionFailedException:
            return False
except Ranorex.ElementNotFoundException:           
    return False

try:       
    path = "/element[@processname='Builder'and@class='TPanel'and@instance='0']
      /element[@processname='Builder'and@class='TEdit'and@instance='0']
     /text[@accessiblerole='Text']"
    txtUsername = loginForm.FindSingle[Ranorex.Text](path, self._timeout)
except Ranorex.ElementNotFoundException:
    return False


loginForm is found. I tried to close form, and it works too.

If I try this:

Code: Select all
    path = Ranorex.Core.RxPath.Concat(loginForm.GetPath(), Ranorex.Core.RxPath("/element[@processname='Builder'and@class='TPanel'and@instance='0']
      /element[@processname='Builder'and@class='TEdit'and@instance='0']
      /text[@accessiblerole='Text']"))
    txtUsername = Ranorex.Host.Local.FindSingle[Ranorex.Text](path, self._timeout)


I get the reference to the text field element.

Path is the same as the path in the Ranorex Spy.

Getting just /element[@processname='Builder'and@class='TPanel'and@instance='0'] doesn't work too, but with Ranorex.Host.Local it works.

Am I doing something wrong?
brca
 
Posts: 2
Joined: Fri Jan 30, 2009 3:06 pm

Postby Support Team » Fri Jan 30, 2009 5:32 pm

If you use relative RanoreXPaths, you must omit the starting '/' character. '/' at the front of an RxPath means "search from root", i.e. from Host.Local (absolute RanorXPath). So, if you remove that starting '/' when you search for the text inside your form, your code should work.

You can find the documentation for RanoreXPath in the Ranorex User Guide.

Regards,
Alex
Ranorex Support Team
User avatar
Support Team
Site Admin
 
Posts: 4837
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Postby brca » Mon Feb 02, 2009 10:07 am

It's working now.

Thanks a lot.
brca
 
Posts: 2
Joined: Fri Jan 30, 2009 3:06 pm


Return to Automation API

Who is online

Users browsing this forum: No registered users and 0 guests