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.
URL name dynamically
Re: URL name dynamically
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
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...
Ciege...
-
- Posts: 27
- Joined: Sat Aug 27, 2011 9:41 am
Re: URL name dynamically
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....
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....
Re: URL name dynamically
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...?Which one is better...?
Using the second method, instead of doing a myDom.Close(); you can get the PageUrl property from each myDom.And one more thing , hoe to get the URL of the browser dynamically....
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: URL name dynamically
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.
Roland
Ranorex Support Team
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