HOw can I find the number of links in a frame?
Newbie to Ranorex
Find number of links in a frame
Re: Find number of links in a frame
You can get an IList of all links:
Then you can get a count:
Or you can loop through the list:
Code: Select all
IList<Ranorex.ATag> AllATags = MyFrame.FindDescendants<Ranorex.ATag>();
Code: Select all
int count = AllATags.Count;
Code: Select all
foreach (Ranorex.ATag MyTag in AllATags)
{
//Do Stuff
}
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!
Ciege...
Ciege...
Re: Find number of links in a frame
Hi Ciege,
Thank you for your reply. I think I found another way to achieve my criteria. I could just find my link via findsingle and click on it. I didnt have to use this one for now.
Anu
Thank you for your reply. I think I found another way to achieve my criteria. I could just find my link via findsingle and click on it. I didnt have to use this one for now.
Anu
Re: Find number of links in a frame
Hi Ciege,
Today I have come across a scenario where your suggestion might be useful. But the webpage I am working on is a multi framed app, and if I provide a WebDocument it would give me all the links of the page which is about 327 links. I want the links from a particular frame.
For example this is what I have to get to one submenu link.
/dom[@domain='<IPADDRESS>']/frameset/frameset[@id='contentframeset']/frame[@name='snb']/body/div/table/tbody/tr/td[@id='ltd1']/a[@id='lsnb1']
Thanks for your help
Anu
Today I have come across a scenario where your suggestion might be useful. But the webpage I am working on is a multi framed app, and if I provide a WebDocument it would give me all the links of the page which is about 327 links. I want the links from a particular frame.
For example this is what I have to get to one submenu link.
/dom[@domain='<IPADDRESS>']/frameset/frameset[@id='contentframeset']/frame[@name='snb']/body/div/table/tbody/tr/td[@id='ltd1']/a[@id='lsnb1']
Thanks for your help
Anu
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Find number of links in a frame
Then use instead of the web-document your frame to search for the underlying elements. It the same code for the frame just another RxPath should be used to identify the frame.
Regards,
Peter
Ranorex Team
Regards,
Peter
Ranorex Team
Re: Find number of links in a frame
WebDocument menupath = "/dom[@domain='<IPADDRESS>']/frameset/frameset[@id='contentframeset']/frame[@name='snb']";
IList<Ranorex.ATag> AllAtags = menupath.FindDescendants<Ranorex.ATag>();
If this is what you mean, than I already tried this and I get an error that the "element does not support the required capability 'webdocument'
IList<Ranorex.ATag> AllAtags = menupath.FindDescendants<Ranorex.ATag>();
If this is what you mean, than I already tried this and I get an error that the "element does not support the required capability 'webdocument'
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Find number of links in a frame
Hi,
Please take a look to following link
http://www.ranorex.com/support/user-gui ... apter.html
This documentation is of 2.x but it is also valid for 3.x. If you read this documentation you will understand what a adapter is. Currently just replace the "WebDocument" Adapter with "FrameTag",then your code should work.
Regards,
Peter
Ranorex Team
Please take a look to following link
http://www.ranorex.com/support/user-gui ... apter.html
This documentation is of 2.x but it is also valid for 3.x. If you read this documentation you will understand what a adapter is. Currently just replace the "WebDocument" Adapter with "FrameTag",then your code should work.
Regards,
Peter
Ranorex Team
Re: Find number of links in a frame
My Code is frame inside frame , inside frame and I did this and it worked.
webDocument frameset = "/dom[@domain='mydomain']";
IList<Ranorex.FrameTag> allframes = mymainframeset.FindDescendants<FrameTag>();
foreach (FramesetTag mymainframeset in allframes
{
//look for another frameset or frame, depending on the type.
}
I have a question tho. Now at some point I am going to define an object say Alltabs which could be a DivTag, or ATag or SpanTag or any other tag. Now how do I declare this object Alltabs in the beginning of the script?
Thanks
Anu
webDocument frameset = "/dom[@domain='mydomain']";
IList<Ranorex.FrameTag> allframes = mymainframeset.FindDescendants<FrameTag>();
foreach (FramesetTag mymainframeset in allframes
{
//look for another frameset or frame, depending on the type.
}
I have a question tho. Now at some point I am going to define an object say Alltabs which could be a DivTag, or ATag or SpanTag or any other tag. Now how do I declare this object Alltabs in the beginning of the script?
Thanks
Anu
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Find number of links in a frame
Hello Anu,
ATag, DivTag, and so on are all derived from Ranorex.WebElement. You can use that.
Regards,
Roland
Ranorex Support Team
ATag, DivTag, and so on are all derived from Ranorex.WebElement. You can use that.
Regards,
Roland
Ranorex Support Team
Re: Find number of links in a frame
First, read the documents, especially the API document...
Here are some exampled for declaring variables...I have a question tho. Now at some point I am going to define an object say Alltabs which could be a DivTag, or ATag or SpanTag or any other tag. Now how do I declare this object Alltabs in the beginning of the script?
Code: Select all
Ranorex.ATag DOMlink;
Ranorex.InputTag DOMInput;
Ranorex.ImgTag DOMImage;
Ranorex.SelectTag DOMCombo;
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!
Ciege...
Ciege...
Re: Find number of links in a frame
Ciege -I have read it to an extent. But it does not answer my question.
I will try to be clearer. So the way my webapp is designed is very weirdly different. Its all frameset inside frameset inside frame and the objects in the app are not consistently defined. Some objects are recognized by Id, some with name and most of all not all my objects have InnerText. So to get a easier way what I am trying is, find all frames, and then click on the frame with this name, then find all Divs, and find all ATags inside this Div. Thats how I eventually get to my object. in some testcases, I would be grabbing values from spantags, and others i would enter some values to inputtags. I want to be able to reuse the same search function to perform all of this. I am having to repeat the whole set of code for searching different kind of objects.
I want to use the same name "AllTags" in a reusable function, and everytime I call the function I could be looking for ATags, or SpanTags or inputtags depending on what i am going to find . and hence the object definition changes. The way you have mentioned would mean declaring different objects one for each object type.
So our group is going to buy licenses and I have to make sure the tool does everything my app requires. And since the way the app is designed is very complex, I have these questions. Thanks for all your patience.
Anu
I will try to be clearer. So the way my webapp is designed is very weirdly different. Its all frameset inside frameset inside frame and the objects in the app are not consistently defined. Some objects are recognized by Id, some with name and most of all not all my objects have InnerText. So to get a easier way what I am trying is, find all frames, and then click on the frame with this name, then find all Divs, and find all ATags inside this Div. Thats how I eventually get to my object. in some testcases, I would be grabbing values from spantags, and others i would enter some values to inputtags. I want to be able to reuse the same search function to perform all of this. I am having to repeat the whole set of code for searching different kind of objects.
I want to use the same name "AllTags" in a reusable function, and everytime I call the function I could be looking for ATags, or SpanTags or inputtags depending on what i am going to find . and hence the object definition changes. The way you have mentioned would mean declaring different objects one for each object type.
So our group is going to buy licenses and I have to make sure the tool does everything my app requires. And since the way the app is designed is very complex, I have these questions. Thanks for all your patience.
Anu
Re: Find number of links in a frame
Well, first off you need to declare the different object variable types so Ranorex know what to look for and how to interact with them. For example, you would interact with an ATag differently than you would a Div.
You can write just a couple of different framework methods that take in a frame object variable then search for a particular set of objects. For example one method would be a find ATags... Have it take a Frame object as its variable and return a list of ATags. Completely re-usable. All you do is pass in a frame object and it returns the ATags in that frame. Do a similar method for each other type of object you want to find. A completely self contained block of code that is reusable throughout this and all of your other projects.
It's all very quite simple once you get your head wrapped around it. And you will eventually build up a large re-usable framework of all your shared methods that can be used again and again. Just put them into a DLL then reference that DLL from all your different test automation projects.
You can write just a couple of different framework methods that take in a frame object variable then search for a particular set of objects. For example one method would be a find ATags... Have it take a Frame object as its variable and return a list of ATags. Completely re-usable. All you do is pass in a frame object and it returns the ATags in that frame. Do a similar method for each other type of object you want to find. A completely self contained block of code that is reusable throughout this and all of your other projects.
It's all very quite simple once you get your head wrapped around it. And you will eventually build up a large re-usable framework of all your shared methods that can be used again and again. Just put them into a DLL then reference that DLL from all your different test automation projects.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!
Ciege...
Ciege...
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Find number of links in a frame
As Roland already said, all web elements (ATag, SpanTag, DivTag, ...) derive from WebElement (the API documentation for the class shows the inheritance tree at the very bottom of the page); and WebElement itself and all other adapters (like Button, Text, ComboBox) derive from Adapter. So you can use either WebElement or Adapter as your "AllTags" type.Anu wrote:I want to use the same name "AllTags" in a reusable function, and everytime I call the function I could be looking for ATags, or SpanTags or inputtags depending on what i am going to find
All adapters and types/classes in the Ranorex Framework are described in the Ranorex API documentation. The important namespace for you is the "Ranorex" namespace:
http://www.ranorex.com/Documentation/Ra ... anorex.htm
Regards,
Alex
Ranorex Team