Page 1 of 1

How to close browser without abort session

Posted: Mon Sep 10, 2018 9:33 am
by Sergii.Pankrashyn
Hi folk, I have a question.
Image
In my test the last step is closing browser, for this action I use core merthod

Code: Select all

Host.Current.CloseApplication(repo.CmdHtml.Self, 1000);
and my browser shows me alert with approving close page website, Ranorex close browser with forcing and next opening browser start with alert in restore session
Image
How in this case close browser correct?

Re: How to close browser without abort session

Posted: Tue Sep 11, 2018 9:38 pm
by Support Team
Hi Sergii,

Here are two options to handle this scenario:
  • Use KillApplication instead. The downside to this is that it will close any other tabs open and not allow the browser to shut down properly.

    Code: Select all

    Host.Current.KillApplication(repo.MyAUT.Self);
  • After using the CloseApplication action, click the button in the prompt preventing the browser from closing (just a user would need to). Note, this could be implemented as a popup watcher if you cannot predict when message box occurs.

    Code: Select all

    Host.Current.CloseApplication(repo.MyAUT.Self, new Duration(0));
    repo.ChromeForm.Leave.Click();
    
    repo.ChromeForm.Leave:

    Code: Select all

    /form[@processname='chrome']//button[@accessiblename='Leave']
I hope this helps!

Cheers,
Ned