Unable to detect the text box in java application

Ask general questions here.
ejji09
Posts: 54
Joined: Thu Sep 10, 2015 2:48 pm

Unable to detect the text box in java application

Post by ejji09 » Tue Sep 29, 2015 3:16 pm

Hi,

Am trying to test a java application and in that application i have several text fileds, but when i track the "postcode" text filed and run the test application it going to the text field "Age". I dont know why its happening like that. Please suggest me any ideas to solve the issue.

Thank you.

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

Re: Unable to detect the text box in java application

Post by odklizec » Tue Sep 29, 2015 4:22 pm

Hi,

I can only guess that the tracked "postcode" xpath is not unique and that the "Age" field is the first one which does match the xpath. Could you please post the xpath and Ranorex snapshot of your application, where both fields are visible? Without snapshot is pretty hard to suggest something reliable.
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

ejji09
Posts: 54
Joined: Thu Sep 10, 2015 2:48 pm

Re: Unable to detect the text box in java application

Post by ejji09 » Wed Sep 30, 2015 10:53 am

The Ranorex snapshot is too large to upload in this forum, So i sent you the normal snapshot where you can see the all the fields of my application.

and this is the xpath of my application:

Code: Select all

/form[@title='Centricity RIS-i 5.0 - ']
xpath of the postcode textfield:

Code: Select all

/form[@title='Centricity RIS-i 5.0 - ']/container[@type='MdiDesktopPane']/?/?/container[@name='rootPanel']/container[@name='MainPanel']/?/?/container[@name='patientPanel']/container[@name='verticalSouthSplit']/?/?/container[@name='treatedPersonPanel']//container[@name='horizontalWestSplit']/?/?/container[@name='horizontalEastSplit']//container[@type='BasicScrollPane$BasicViewport']/?/?/container[@type='SingleRecordEditPanel$1']/container[4]/text[@name='field']
You do not have the required permissions to view the files attached to this post.

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

Re: Unable to detect the text box in java application

Post by odklizec » Wed Sep 30, 2015 11:27 am

Hi,

Unfortunately, the posted screenshot is not helpful here. Could you please upload the snapshot to Google drive, MS One drive or similar cloud service and share the link?

The xpath you posted is the actually used xpath in repository?
Could you please post also the xpath of "Age" field?
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

ejji09
Posts: 54
Joined: Thu Sep 10, 2015 2:48 pm

Re: Unable to detect the text box in java application

Post by ejji09 » Wed Sep 30, 2015 12:25 pm

xpath of postcode in repository:

Code: Select all

/?/?/container[@type='SingleRecordEditPanel$1']/container[4]/text[@name='field']

and when i track the Age it showing Date of birth text field in the repository where the date of bith text field is already tracked for testing

xpath of Age in repository:

Code: Select all

?/?/container[@type='SingleRecordEditPanel$1']/container[9]/text[@name='field']
and even for the Date of birth also its showing the same path.

P.S: Age is not a text field it just automatically display the exact age after selecting the Date of birth


Please find the link of the download the ranorex snapshot of my application.
https://app.box.com/s/2p2afqto2x7jj9bddh0gdr9jdp21jacu
Last edited by ejji09 on Wed Sep 30, 2015 12:38 pm, edited 1 time in total.

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

Re: Unable to detect the text box in java application

Post by odklizec » Wed Sep 30, 2015 12:37 pm

Hi,

Exactly what I've suspected. The path is not unique and if applied in snapshot, it actually returns 13 elements, where the "Age" field is the first one in the list. This is why your script always goes to "Age" field.
ListOfItems.png
What you need to do is to add another attribute to the path, to make the postcode xpath unique. Like this...
/?/?/container[@type='SingleRecordEditPanel$1']/container[4]/text[@accessiblename~'Postcode' and @name='field']
eventually, like this:
/?/?/container[@type='SingleRecordEditPanel$1']/container[4]/text[@accessiblename~'Postcode' and @type='LovField']
You do not have the required permissions to view the files attached to this post.
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

ejji09
Posts: 54
Joined: Thu Sep 10, 2015 2:48 pm

Re: Unable to detect the text box in java application

Post by ejji09 » Wed Sep 30, 2015 12:59 pm

Thanks it worked fine,

But How Can we know before executing the test case that the xpath is unique or not?

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

Re: Unable to detect the text box in java application

Post by odklizec » Wed Sep 30, 2015 1:18 pm

You are welcome.

As of how to know is the path is unique or not, this is something you should verify during the design phase of your test. I guess you are using Recording? After recording some steps, you should always do some cleanup (renaming and reorganizing added repo items), including verification of repo item xpaths uniqueness. This is why you should not record too many steps at once. Recording is a great time saver, but it's not a magic wand ;) Some user interaction is always required and highly recommended. At least if you want to build robust repository, which requires minimum maintenance in future.
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

ejji09
Posts: 54
Joined: Thu Sep 10, 2015 2:48 pm

Re: Unable to detect the text box in java application

Post by ejji09 » Wed Sep 30, 2015 2:10 pm

Actually am using recoring method and using code module and they way do testing is:
i will track the object from repository and then i will just drag it into the code module and then i will execute it. So while tracking the oject is there a way to find whether is tracking object is unique or not ?

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

Re: Unable to detect the text box in java application

Post by odklizec » Wed Sep 30, 2015 2:19 pm

Yes. Once the element is added to repository, select it (in repository) and click its "Edit" button. Now in the appeared Ranorex Spy switch to Browser & Results tab. If the path is unique, there should be found just one element.
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

ejji09
Posts: 54
Joined: Thu Sep 10, 2015 2:48 pm

Re: Unable to detect the text box in java application

Post by ejji09 » Wed Sep 30, 2015 3:39 pm

But how to make unique to these kind of xpaths

Code: Select all

?/?/menuitem[@text='Selection']
because when i try to track the postcode selection tab(which pop ups after clicking on the textfield of postcode to select the postcode) its again going back to the dateofbirth section tab which is already tracked in the repository and to solve the issue i tried something like this but it dint worked out.

Code: Select all

?/?/menuitem[@accessiblename~'Dateofbirth' and @text='Selection']

Please check the attchment of the Date of birth selection popup
date of birth selection.JPG
Please check the attchment of the postcode selection popup
postcode selection.JPG
You do not have the required permissions to view the files attached to this post.

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

Re: Unable to detect the text box in java application

Post by odklizec » Thu Oct 01, 2015 8:05 am

Hi,

For context/popup menus, you need to use Instant Tracking feature (as described >here<). This should help you out with finding unique attributes for given menu item.
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

ejji09
Posts: 54
Joined: Thu Sep 10, 2015 2:48 pm

Re: Unable to detect the text box in java application

Post by ejji09 » Thu Oct 01, 2015 8:52 am

Yeah i tried the instant tracking feature but even though it takes the same path which is already taken by Date of birth :| and the test case is not working

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

Re: Unable to detect the text box in java application

Post by odklizec » Thu Oct 01, 2015 9:01 am

I think you just need to create a new repository item manually (via Add New Item button in repo editor) and add it xpath with attributes, which are unique for the popup menu.

Just open standalone Spy, use instant tracking to track the problematic popup and then in spy examine its attributes and add them to the xpath displayed in Spy. Then copy that xpath and paste in newly (manually) created repo item. Hope this helps?
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

ejji09
Posts: 54
Joined: Thu Sep 10, 2015 2:48 pm

Re: Unable to detect the text box in java application

Post by ejji09 » Wed Oct 07, 2015 11:05 am

The Xpath for the Selection pop up is not unique, it is same for every Selection popup when ever i try to track the Selection popup it always shows me the previous Selection popup. How to overcome this :(