How to recognize the links in the text box

Ask general questions here.
kiran
Posts: 5
Joined: Tue Jun 23, 2009 6:53 am

How to recognize the links in the text box

Post by kiran » Tue Jun 23, 2009 9:30 am

I have an application with a table of rows and columns. Each row has 4 columns and first row consist of a link which redirects to another page.

Have a look at this link in which i uploaded the application gui. How to click on the last link of the text box. All the controls are in the web document form.

I have written my code as :
SampleRepository repo=SampleReposiroty.Instance;

repo.WebDocumentWeb_Browse.LinkTrTag.Focus();
Delay.Seconds(3);
repo.WebDocumentWeb_Browse.LinkTrTag.Children[0].Click();

With the above code the cursor clicks on the first row first column link. :)

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

Re: How to recognize the links in the text box

Post by Support Team » Tue Jun 23, 2009 12:25 pm

kiran,

Please describe what you mean by "textbox" and "last link in the textbox" and what you are exactly trying to accomplish.

It would certainly be helpful if you could post a snapshot of the web document (or send it to [email protected]) you are automating.

Michael
Ranorex Team

kiran
Posts: 5
Joined: Tue Jun 23, 2009 6:53 am

Re: How to recognize the links in the text box

Post by kiran » Tue Jun 23, 2009 12:58 pm

Please look at the link in which i uploaded the screen shot. I need to click on the 6.0.0. link in the text box of 1st row and 3rd column.

I have written the below code to do that :

repo.WebDocumentWeb_Browse.LinkTrTag.Focus();
Delay.Seconds(3);
repo.WebDocumentWeb_Browse.LinkTrTag.Children[0].Click();

With my code it is clicking on the link 4.0.0.
Can you let me know how to click on the 6.0.0 link.

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

Re: How to recognize the links in the text box

Post by Support Team » Tue Jun 23, 2009 1:15 pm

kiran wrote:Can you let me know how to click on the 6.0.0 link.
There is no direct answer to that without knowing the structure of your application, e.g. by spying your application or having a Ranorex snapshot (not screenshot) of the application. If the "4.0.0" link is the first and the "6.0.0" element the third child of the LinkTrTag element, than Children[2] might work, but that is only a guess!

Why don't you just use Ranorex Spy to spy the "6.0.0" link and get the corresponding RxPath or repository item, respectively?

Regards,
Alex
Ranorex Support Team

kiran
Posts: 5
Joined: Tue Jun 23, 2009 6:53 am

Re: How to recognize the links in the text box

Post by kiran » Tue Jun 23, 2009 2:21 pm

Alex,

I got the id from Ranorex spy itself. I can get id and go further.
But the thing is daily those versions get appended like 6.0.0 today 7.0.0 tomorrow..like that
I can't hard code directly or change the link daily in my code. I want the code to be generic and dynamic. So that's the reason i took the Trtag as the id for 6.0.0 which is common and to which these links get added.

That's the reson written the above code. I even tried with Children[2], but was clicking on the second row(labeled as "Last Write") and first column .

Hope i'm clear with my content.
:)

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

Re: How to recognize the links in the text box

Post by Support Team » Tue Jun 23, 2009 2:44 pm

Without a Snapshot of your application we don`t know anything about your Elements and the associated RXPaths, however.
By the way, do you have read the Rx-Path userguide:
http://www.ranorex.com/support/user-gui ... xpath.html

Regards,
Christian
Ranorex Support Team

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

Re: How to recognize the links in the text box

Post by Support Team » Tue Jun 23, 2009 3:56 pm

Do you know that you can use relative paths to search for elements? I.e. you can search for all links inside the LinkTrTag element and then click on the last one:
List<ATag> links = repo.WebDocumentWeb_Browse.LinkTrTag.FindDescendants<ATag>();
// or the equivalent to the above line using RxPath
links = repo.WebDocumentWeb_Browse.LinkTrTag.Find<ATag>(".//a");
links[links.Count - 1].Click();
Regards,
Alex
Ranorex Support Team

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: How to recognize the links in the text box

Post by Ciege » Tue Jun 23, 2009 4:01 pm

That (according to the picture) looks like just a basic HTML table. Can you not just get the table object then iterate, using the DOM, through each cell and get the aTag links?

If it is just an HTML document try (along with using Spy) using the IE Developer Toolbar for IE7 or the built in Developer Tools in IE8. Each has a DOM Inspector that you can traverse your web docs through the DOM and determine access to each item.