Getting the div index

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
gerrip
Posts: 9
Joined: Thu Sep 27, 2012 2:13 pm

Getting the div index

Post by gerrip » Tue Oct 02, 2012 9:05 am

Hello,
I am testing now the Ranorex for our company needs. We can decide to use Ranorex, but only if it can serve us well. We using ExtJs and I have some troubles with element identification. Now my main question is about a table:
is there a way of getting the div index of one element? I have the innertext, and need the div index....
I am using VB.net..

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

Re: Getting the div index

Post by Support Team » Tue Oct 02, 2012 3:10 pm

Hello,

This should be possible, but in order to analyze the issue in detail we would need a Ranorex Snapshot file of your table, would this be possible?
You can post it here or you can also send it to our support mail address: [email protected].
Following link will show you how to generate a snapshot file:
Creating Ranorex Snapshot Files.

Thanks,
Markus
Ranorex Support Team

gerrip
Posts: 9
Joined: Thu Sep 27, 2012 2:13 pm

Re: Getting the div index

Post by gerrip » Thu Oct 04, 2012 8:06 am

Hello,
I sent the snapshot per Email.
Looking forward to hearing from you soon!

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

Re: Getting the div index

Post by Support Team » Thu Oct 04, 2012 3:05 pm

Hi,

Thanks for the snapshot!
Please take a look at the two attributes of the specific TR tag "viewIndex" or "viewRecordId", these attributes should include the information you wanted to get.
If these values of the attributes are the wrong values we would need a Ranorex snapshot of the entire table in order to analyze the issue in detail.
You can get these attributes with the Get Value action as shown in the attached recording file.

Regards,
Markus
Ranorex Support Team
You do not have the required permissions to view the files attached to this post.

gerrip
Posts: 9
Joined: Thu Sep 27, 2012 2:13 pm

Re: Getting the div index

Post by gerrip » Thu Oct 04, 2012 3:23 pm

Hello,

This does not help me....the point is, that I need to find the tr/td index of the current cell (Name). Because I want to use that in general, where I dont have any value in a cell. The other point is, that the cell I may need is not every time in the same row. That's why I just thought that I can use vb.net to make a manual function and use it, when I want to find any cell place
For example, if I can find the row index of the 'Name' cell, then I can also find the column index(td) of another cell, for which I also have a value, and then I can alone prepare this regexp, according to tr/td indexes for the cell I need....
Is it possible to find this index, using an user code? Or maybe my question is in the wrong place?

Thank you and best of regards!

regex
Posts: 48
Joined: Tue Aug 14, 2012 5:47 pm

Re: Getting the div index

Post by regex » Thu Oct 04, 2012 8:30 pm

Make a list out of it.
IList<Ranorex.DivTag> myList = tag.findDescendents<Ranorex.DivTag>();

Call the index of the list:

myList[0]

Perform operations
myList[0].InnerText

gerrip
Posts: 9
Joined: Thu Sep 27, 2012 2:13 pm

Re: Getting the div index

Post by gerrip » Fri Oct 05, 2012 8:02 am

Thank you!
Can you also tell me, if one div is in a table, and I know the div, how can I find the correspondent tr and td index ? I will very appreciate!
Example code (I have the div with id=description, i want to find the tr index and td index. Here is for example tr[2]td[1])
<tr>
</tr>
<tr>
<td id="ext-gen1053" class="lty_iboxDscr ">
<div id="description" class="lty_iboxDscr Nov ">Name:<span class="requiredfield lty_requiredStar"></div>
</td>
<td id="ext-gen1066" class="lty_iboxCntin">
<input id="uq917" name="p_sName" maxlength="300" vtype="required;" onkeyup="javascript:try{iboxValidate(this)}catch(ex){};;" onchange="javascript:changeForm();" class="lty_inputText w264 " value="Hello" autocomplete="on" type="text"></td>
<td>
<a boxid="metaBox" class="lty_iboxHdLnk" onclick="javascript:openPage(1,'-1','-1','NAME','73822','-1','-1','testing');;"></a>
</td>
</tr>

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

Re: Getting the div index

Post by Support Team » Fri Oct 05, 2012 12:13 pm

Hi,

You can get an attribute of a parent element as I showed it in my uploaded sample recording.
Use the RxPath of the div tag and add the following expression in order to identify the parent element: <RxPath of DivTag>/../, this would identify the td tag.
You can get the value of a specific attribute of a specific repo item with the "Get Value" action as shown in my sample.

Regards,
Markus
Ranorex Support Team

gerrip
Posts: 9
Joined: Thu Sep 27, 2012 2:13 pm

Re: Getting the div index

Post by gerrip » Tue Oct 09, 2012 10:19 am

Hello,

thank you for the answer. I managed to cope with that, but I have another problem. I have one functionality, which I cannot test, if I dont find a way to locate a cell..
For that I need to find the row, where this cell is, according to another cell
(because this cell will not be at the same place each time)
I have:
/html/body/div[5]/div[2]/div/div/div[4]/div/div/div[2]/div/table/tbody/tr[13]/td id="ext-gen1576" class=" xty_flxgridBorderTRL x-grid-cell" style="; text-align: center;" unselectable="on">myCell</div></td>


So, I need to find the number in bracket in tr[13], according to the place of //div[@inertext='myCell'].

I have 5 more days to finid a way to test this, in order to decide if I will do with ranorex or not......so will be grateful if anyone can help me!

regex
Posts: 48
Joined: Tue Aug 14, 2012 5:47 pm

Re: Getting the div index

Post by regex » Tue Oct 09, 2012 4:45 pm

Put it in a loop and maybe do:

tr[13].moveto();

Find descendents, look in the local variables of the list, and locate the index of the required cell. Move to that index.

I'd need to understand the problem more.

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

Re: Getting the div index

Post by Support Team » Tue Oct 09, 2012 5:00 pm

Hello,

If I got the question correctly you have to make the following:
In order to get the index of the tr tag you can use the childindex(attribute) +1, because it starts with 0 and the index starts with 1.
Just make the same as shown in my sample and add a GetValue action with "childindex" as attribute/name.
You can also make this in UserCode:
YourVariable = YourRepoElement.Element.GetAttributeValue("childindex").ToString();
Regards,
Markus
Ranorex Support Team

gerrip
Posts: 9
Joined: Thu Sep 27, 2012 2:13 pm

Re: Getting the div index

Post by gerrip » Thu Oct 11, 2012 11:57 am

Thank you to all of you!

I found the cell, but stil have problems with finding elements
With highlight element I can always find them, but during the run process, sometimes are found, sometimes not, althought they are there!

Dont know what to do, normally this happens in a separate (popup) window....

Any idea, what could be different?

Can the problem be in @class attribute that I am using to catch element?

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

Re: Getting the div index

Post by Support Team » Fri Oct 12, 2012 9:41 am

Hi,

It could be that you are using an attribute in your RxPath which will change after a restart of your AUT.
Could you please send us a Ranorex Snapshot file of that pop up window, including the specific not found element and the RxPath you are using in order to find the element?
Do you have installed the full version of the .Net 4.0 framework?

Thanks,
Markus
Ranorex Support Team

gerrip
Posts: 9
Joined: Thu Sep 27, 2012 2:13 pm

Re: Getting the div index

Post by gerrip » Fri Oct 12, 2012 1:19 pm

No, I have 3.5 Framework...I will install the 4.0 then.

Otherwise, no, the element is not changed, because if I use highlight element option from the repository (clicking over the element), it finds it, but during the playback, it does not find it...it is always the first searched element /the first action/ in the new window . I wil investigate more.

The problem is more reproducable in IE, instead of FF..

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

Re: Getting the div index

Post by Support Team » Fri Oct 12, 2012 1:22 pm

Hi,

Could it be that you are using rooted folders? If so, please check if the "Use Cache" property is set to false.
It should also run with 3.5, there is no need to update, I just asked because there are some issue if you just installed the client version of the .Net 4.0 framework.

Regards,
Markus
Ranorex Support Team