ClosingBrowser

Bug reports.
omayer
Posts: 458
Joined: Thu Oct 28, 2010 6:14 pm

ClosingBrowser

Post by omayer » Mon Apr 15, 2013 7:03 pm

I am trying to close all open browser or form ,but the problem it closed down the Ranorex Studio also

Code: Select all

	
public static int CloseBrowser()
	  	{    	
			
        	for (int i = 0; i < 10; i++)

        	{
  				Ranorex.Button button=null;
 				bool found = Host.Local.TryFindSingle<Ranorex.Button>("/form[@title~'.*Windows Internet Explorer']/titlebar[@accessiblerole='TitleBar']/button[@text='Close']", 2000, out button);   
 				if(found)
 				{
 					button.MoveTo();
 					button.DoubleClick();
 				}
		
			 	if (i == 2)
		 		break;

			}//for loop
        	
        	return 0;
  		}
Thank you
Tipu

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

Re: ClosingBrowser

Post by Ciege » Mon Apr 15, 2013 7:21 pm

I think button.DoubleClick(); is your issue...

The "Close" button is the X button on the top right of the browser yes?
That button only requires a single click...

My guess is since you are double clicking it, it is closing the browser and also closing the full screen Ranorex IDE which is the next window under the 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...

omayer
Posts: 458
Joined: Thu Oct 28, 2010 6:14 pm

Re: ClosingBrowser

Post by omayer » Tue Apr 16, 2013 12:43 am

Thank you Ciege to point this out, i tried w/single click but same result, using win7,IE8, Ranorex 4.02, I didn't have this issue on xp, IE7 along with older version of Ranorex
Tipu

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

Re: ClosingBrowser

Post by Support Team » Tue Apr 16, 2013 9:48 am

Hello,

There is an easier way to do what you want. Please take a look at the following code:
IList<Form> openForms = Host.Local.Find<Ranorex.Form>("/form[@title~'Windows Internet Explorer']");				
foreach(Form openForm in openForms)
{
	openForm.Close();
}
Regards,
Bernhard
.
Image

omayer
Posts: 458
Joined: Thu Oct 28, 2010 6:14 pm

Re: ClosingBrowser

Post by omayer » Wed Apr 17, 2013 2:42 pm

Thank you Bernhard, It worked
Tipu