URL name dynamically

Ask general questions here.
Praveen597
Posts: 27
Joined: Sat Aug 27, 2011 9:41 am

URL name dynamically

Post by Praveen597 » Mon Aug 29, 2011 3:20 pm

Hi All,

I'm new to Ranorex. But I found something interesting with it so I decided to explore the tool.

Can any one explain how to get the URL name dynamically of all currently running browsers using C# code in Ranorex.

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

Re: URL name dynamically

Post by Ciege » Mon Aug 29, 2011 4:24 pm

Take a look at this post... With just a small bit of tweaking you can modify the code to return all the URLs of any open browser.

http://www.ranorex.com/forum/how-to-fin ... t1032.html
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...

Praveen597
Posts: 27
Joined: Sat Aug 27, 2011 9:41 am

Re: URL name dynamically

Post by Praveen597 » Tue Aug 30, 2011 10:46 am

Thank you Ceige,

After many attempts I got the trick. As I am a begineer, I am getting lots of doubts so kindly please bare with me.

I used:

System.Diagnostics.Process[] p = System.Diagnostics.Process.GetProcessesByName("iexplore");
foreach(System.Diagnostics.Process Ps in p)
{
Ps.Kill();
}

and also the below code doing the same thing:
List<Ranorex.WebDocument> AllDoms = Host.Local.FindChildren<Ranorex.WebDocument>();
if (AllDoms.Count >=1
{
foreach (WebDocument myDom in AllDoms)
{
myDom.Close();
}
}

Which one is better...? Is there any other method to do the same...?

And one more thing , hoe to get the URL of the browser dynamically....

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

Re: URL name dynamically

Post by Ciege » Tue Aug 30, 2011 3:38 pm

Which one is better...?
Not sure which is better, I use the .Close method instead of the .Kill method. I'm not sure what .Kill does under the covers and my just force kill the process found rather than cleanly close...?
And one more thing , hoe to get the URL of the browser dynamically....
Using the second method, instead of doing a myDom.Close(); you can get the PageUrl property from each myDom.
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...

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: URL name dynamically

Post by Support Team » Tue Aug 30, 2011 7:51 pm

The template parameter (<Ranorex.WebDocument>) does only do a type casting over all children.
The actual element you best find with either <adapter>.Find() or <adapter>.FindSingle() and a RanorexPath.
The first gives you all the element that fit to the provided path, the second gives you the first one.
You would use a path that is relative to the adapter class you use.
In your case you start with the adapter that represents your desktop (Host.Local).
Then you can use an absolute path.
IList<Ranorex.WebDocument> AllDoms = Host.Local.Find<Ranorex.WebDocument>("/dom");
foreach (WebDocument myDom in AllDoms)
{
	myDom.Close();
}
Regards,
Roland
Ranorex Support Team
.
Image