Invalid Browser Count
-
- Posts: 27
- Joined: Sat Aug 27, 2011 9:41 am
Invalid Browser Count
Hi All,
Here is my code to get the number of currently running browsers on the screen,
IList<Ranorex.WebDocument> AllBrowsers = Host.Local.FindChildren<Ranorex.WebDocument>();
int BrowCount = AllBrowsers.Count;
Console.WriteLine(BrowCount);
I am getting answer as 1, even if no browsers are currently under running state.
And getting answer as 2, if there exists one browser on the screen.
What I mean to say is, every time I am getting answers as (Number of currently running browsers + 1).
Is there any solution for this ...?
Here is my code to get the number of currently running browsers on the screen,
IList<Ranorex.WebDocument> AllBrowsers = Host.Local.FindChildren<Ranorex.WebDocument>();
int BrowCount = AllBrowsers.Count;
Console.WriteLine(BrowCount);
I am getting answer as 1, even if no browsers are currently under running state.
And getting answer as 2, if there exists one browser on the screen.
What I mean to say is, every time I am getting answers as (Number of currently running browsers + 1).
Is there any solution for this ...?
Re: Invalid Browser Count
What version of windows?
Do you have any minimized or hidden browsers open?
Do you have any file explorers open?
Do you have any widgets open?
Many things in Windows are run within a "browser" context so if they are open even if they are not visible they can be counted as a browser object.
With the 1 browser that the piece of code is finding, can you return the properties of the browser and see what it actually is (like get the url, etc...)
Also, use RanorexSpy to browse your machine and look to see what is getting reported as a browser.
Do you have any minimized or hidden browsers open?
Do you have any file explorers open?
Do you have any widgets open?
Many things in Windows are run within a "browser" context so if they are open even if they are not visible they can be counted as a browser object.
With the 1 browser that the piece of code is finding, can you return the properties of the browser and see what it actually is (like get the url, etc...)
Also, use RanorexSpy to browse your machine and look to see what is getting reported as a browser.
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: Invalid Browser Count
I am running the script in both Windows 7 as well as Windows XP 2
Do you have any minimized or hidden browsers open?
No, I don't think so
Do you have any file explorers open? No
Do you have any widgets open? No
I am trying all possibilities but filed to reach the target...!
Do you have any minimized or hidden browsers open?
No, I don't think so
Do you have any file explorers open? No
Do you have any widgets open? No
I am trying all possibilities but filed to reach the target...!
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Invalid Browser Count
Hi,
You are searching for all Ranorex.WebDocument and these adapter represents DOM Object and not browser instances. If you open Ranorex Spy and check how many DOM Objects inside this tree you will notice that the count fits into your count.
Regards,
Peter
Ranorex Team
You are searching for all Ranorex.WebDocument and these adapter represents DOM Object and not browser instances. If you open Ranorex Spy and check how many DOM Objects inside this tree you will notice that the count fits into your count.
Regards,
Peter
Ranorex Team
-
- Posts: 27
- Joined: Sat Aug 27, 2011 9:41 am
Re: Invalid Browser Count
Thank you Peter,
Then what to do to get all the currently available browser count...?:?:
Regards,
Praveen
Then what to do to get all the currently available browser count...?:?:
Regards,
Praveen
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Invalid Browser Count
Hi
You could use following code
Regards,
Peter
Ranorex Team
You could use following code
var iexplore = System.Diagnostics.Process.GetProcessesByName("iexplore"); var firefox = System.Diagnostics.Process.GetProcessesByName("firefox"); Console.WriteLine("IE: " + (iexplore.Length)); Console.WriteLine("Firefox: " + (firefox.Length));to check how many browsers are currently running.
Regards,
Peter
Ranorex Team
-
- Posts: 27
- Joined: Sat Aug 27, 2011 9:41 am
Re: Invalid Browser Count
Hey Peter,
This code is absolutely fine since I am using the same code I know it very well.
But my aim is to get all the browser's count regardless of browser type.
The drawback of the present code is, we have to write a separate code for each and every browser.
I feel this is not that much generic........
We need to handle all type of browsers (or atleast for some max extent of browsers) in a single function.
I think now you got my intentions
This code is absolutely fine since I am using the same code I know it very well.
But my aim is to get all the browser's count regardless of browser type.

The drawback of the present code is, we have to write a separate code for each and every browser.
I feel this is not that much generic........

We need to handle all type of browsers (or atleast for some max extent of browsers) in a single function.
I think now you got my intentions

- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Invalid Browser Count
Hi,
Would it be possible to post or send me a full snapshot of you host, when you try to receive the DOM Objects. I think there are one or two embedded in an application and maybe we find an RxPath to filter them out.
Thanks in advance.
Regards,
Peter
Ranorex Team
Would it be possible to post or send me a full snapshot of you host, when you try to receive the DOM Objects. I think there are one or two embedded in an application and maybe we find an RxPath to filter them out.
Thanks in advance.
Regards,
Peter
Ranorex Team
-
- Posts: 27
- Joined: Sat Aug 27, 2011 9:41 am
Re: Invalid Browser Count
Hi Peter,
Let me describe my TestCase Scenario:
For Eg,
We have a facebook login option in our application. Once we click on that button, a new window will open for facebook login, upon giving the valid credentials it'll allow us to access facebok albums .
Now, for any reason , if it fails to access the albums or if we enter a invalid credentials then we need to capture both the browser images . In reality we failed to capture both the browser images.
Help me out dude....!!
Let me describe my TestCase Scenario:
For Eg,
We have a facebook login option in our application. Once we click on that button, a new window will open for facebook login, upon giving the valid credentials it'll allow us to access facebok albums .
Now, for any reason , if it fails to access the albums or if we enter a invalid credentials then we need to capture both the browser images . In reality we failed to capture both the browser images.
Help me out dude....!!
Re: Invalid Browser Count
Well, you can write one method that incorporates the count for all browser types then. Have that method return a result to you of a list of browsers or a count or whatever you want. If you write the method once you can reuse that method wherever you want in you testing...Praveen597 wrote:Hey Peter,
This code is absolutely fine since I am using the same code I know it very well.
But my aim is to get all the browser's count regardless of browser type.![]()
The drawback of the present code is, we have to write a separate code for each and every browser.
I feel this is not that much generic........![]()
We need to handle all type of browsers (or atleast for some max extent of browsers) in a single function.
I think now you got my intentions
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: Invalid Browser Count
Oh Ciege,
So you want me to write a piece of code for IE, FF, Chrome, Safari, etc....
Am I right....??
So you want me to write a piece of code for IE, FF, Chrome, Safari, etc....
Am I right....??
Re: Invalid Browser Count
Sure, why not... One method that does it all and returns exactly the information you want... It's not difficult. You get to make it do exactly what you want. You write it once and reuse it however many times you want. Any modifications, fixes, changes, etc... are all done in only one place.
It is clearly, in my mind, the best path to take...
Pseudo Code:
It is clearly, in my mind, the best path to take...
Pseudo Code:
Code: Select all
public static list[] GetListOfOpenBrowsers()
try
{
//Get list of IE browsers then add to the list
for each IE browser
{ mylist.add IE Browser}
//Get list of FF browsers then add to the list
for each FF browser
{ mylist.add FF Browser}
etc...
return mylist
}
catch exception
{return null}
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: Invalid Browser Count
Hi Ciege,
Is there any predefined method/function to count the number of browsers currently running irrespective of browser type..?
Is there any predefined method/function to count the number of browsers currently running irrespective of browser type..?
Re: Invalid Browser Count
Not that I am aware of... You need to write the code yourself.
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...