Page 1 of 1
How to automate browsing in link areas?
Posted: Mon Feb 17, 2014 8:42 am
by lunarro
Hello all.
I'm totally new to Ranorex - and i'm working with studio v.3.2.
Currently i'm trying to figure out, how to automate browsing all links within the one specific element, like for example:
<div id=""something">
<ul>
<li><a>some link</a></li>
<li><a>some other link</a></li>
<li>...
...</ul>
</div>
Pages with such "link areas" called in my example "something" have random number of links in my case - so how could i make it flexible - automatically, and force Ranorex to test all of them ?
I would be thankful for any suggestions.
Re: How to automate browsing in link areas?
Posted: Mon Feb 17, 2014 3:50 pm
by Swisside
Hello !
I'm not used to testing HTML but I found a way to do it :
You will find a working example attached to this post
Here are the steps:
1) In this case I added the DIVTag to a repository. (You could easily adapt this)
2) We find the ul descendant
3) We find all the li descendants
4) foreach li descendant we get the ATag and MAJ+Click the link(to open in a new window) then we close the window (ALT+F4)
Hope it will help you !
Swiss'
Here is the method I used :
public void MyMethod()
{
//Div tag which is in the body tag (you need to have browseliHtml.SomeDivTag in your repo)
DivTag someDivTag = new DivTag(repo.BrowseliHtml.SomeDivTag);
//Create the ultag adapter
UlTag ultag = someDivTag.FindDescendant<UlTag>();
//Create the list of all litag
IList<LiTag> LiList= ultag.FindDescendants<LiTag>();
//Loop through all LiTag
foreach(LiTag li in LiList){
//Create the ATag adapter
ATag at = li.FindDescendant<ATag>();
//Press Down the MAJ Key
Keyboard.Down(System.Windows.Forms.Keys.LShiftKey | System.Windows.Forms.Keys.Shift, Keyboard.DefaultScanCode, true);
//Click on the ATag
at.Click();
//Release the MAJ Key
Keyboard.Up(System.Windows.Forms.Keys.LShiftKey | System.Windows.Forms.Keys.Shift, Keyboard.DefaultScanCode, true);
//WAIT 1 sec
Delay.Duration(1000);
//Close the window we just opened
Keyboard.Press(System.Windows.Forms.Keys.F4 | System.Windows.Forms.Keys.Alt, Keyboard.DefaultScanCode, Keyboard.DefaultKeyPressTime, 1, true);
}
}
Re: How to automate browsing in link areas?
Posted: Wed Feb 19, 2014 12:37 pm
by lunarro
Hey Swisside!
Thanks a lot for your response. I like this approach and seems to work for me - however building sophisticated browsing schemas will be hard in this case.
But as i understand - it will be natural limitation of Ranorex.
Earlier i did it with Visual WebScrapper tool - but it is a kind of customized, programmable browser, where http communication is monitored and all javascript/browser specific acions can be captured.
Anyway - your idea helps me partially, so thanks!