URL name dynamically : General Questions

URL name dynamically

Ask general questions here.

URL name dynamically

Postby Praveen597 » Mon Aug 29, 2011 4: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.
Praveen597
 
Posts: 24
Joined: Sat Aug 27, 2011 10:41 am

Re: URL name dynamically

Postby Ciege » Mon Aug 29, 2011 5: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-find-and-close-web-browser-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...
User avatar
Ciege
 
Posts: 965
Joined: Thu Oct 16, 2008 7:46 pm
Location: Arizona, USA

Re: URL name dynamically

Postby Praveen597 » Tue Aug 30, 2011 11: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....
Praveen597
 
Posts: 24
Joined: Sat Aug 27, 2011 10:41 am

Re: URL name dynamically

Postby Ciege » Tue Aug 30, 2011 4: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
Ciege
 
Posts: 965
Joined: Thu Oct 16, 2008 7:46 pm
Location: Arizona, USA

Re: URL name dynamically

Postby Support Team » Tue Aug 30, 2011 8: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
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria


Return to General Questions

Who is online

Users browsing this forum: No registered users and 0 guests

cron