Private browsing

Ask general questions here.
CG08
Posts: 3
Joined: Mon Mar 17, 2014 12:28 pm

Private browsing

Post by CG08 » Mon Mar 17, 2014 12:34 pm

Hi

We are noobs yet, we are running a cross browser test and need to start every browser in private mode. How could we pass this params to ranorex?

Thank you

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Private browsing

Post by Support Team » Tue Mar 18, 2014 4:47 pm

Hello CG08,

Unfortunately it is not possible to add arguments to the "Open Browser" action in a recording module.
A possibility is to use "UserCode"-Actions to start your browsers in private mode.
Please have a look at our User Guide to learn how to create "UserCode-Actions" under this link http://www.ranorex.com/support/user-gui ... tions.html

Unfortunately Safari has no command-line-arguments to start in private-mode.

Here is an example for the "User-Code" action

Code: Select all

public void OpenBrowserPrivate(string URL, string Browser)
{
string FFFlag="-private-window";
string IEFlag="-private";
string CHFlag="-incognito";
string flag="";
        	
if(Browser=="Firefox")
       	flag=FFFlag;
else if(Browser=="Chrome")
       	flag=CHFlag;
else if(Browser=="IE")
       	flag=IEFlag;
else
       	flag="";
   
Host.Local.OpenBrowser(URL,Browser,flag,false,false);
}
Kind regards,

Markus (S)

CG08
Posts: 3
Joined: Mon Mar 17, 2014 12:28 pm

Re: Private browsing

Post by CG08 » Tue Mar 18, 2014 6:09 pm

Thank you Markus

I am testing your code, seems ok but I getting two instances of Firefox, one private and one regular, in this last one Ranorex is continuing with the following recorded modules. Chrome and IE seems working ok.

Could you help me with this?

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Private browsing

Post by krstcs » Tue Mar 18, 2014 7:05 pm

Mozilla changed the way Firefox does private browsing several releases ago. If you pass a URL to the command line in addition to the "-private" flag, Firefox will open the URL in a standard (non-private) window and will open a blank page in the private window. This is how it works and there is nothing Ranorex can do about it, unfortunately.

You might be able to open the private window without passing the URL and then navigate the browser to the URL after it is open.
Shortcuts usually aren't...

Florian
Posts: 75
Joined: Fri Jul 27, 2012 12:57 pm
Location: France (Lyon)
Contact:

Re: Private browsing

Post by Florian » Thu Aug 07, 2014 8:45 am

Sorry to answer only right now, but there is a workaround for Firefox:
- open your browser
- type about:config in the url bar
- search for "private"
- look for "browser.privatebrowsing.autostart"
- double-click on the line to put "true" for the value

You can now close your browser.
Every time you will pen the browser with the normal shortcut, the browser will open in private mode.

As I use Ranorex on a Virtual Machine to keep working even during the test session, it doesn't matter if my browser keeps in private mode.

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Private browsing

Post by krstcs » Thu Aug 07, 2014 1:26 pm

Unfortunately that doesn't solve the whole problem. They didn't want Firefox to start in private mode every time. They only wanted it to start in private mode when they told it to, and they wanted it to open the URL they typed in the command-line, in the private window.


Mozilla decided that security was more important than user convenience in this instance (rightly, I think) and stopped allowing a URL to be opened in private mode from the command line. This "feature" of other browsers could be used by malware to open hidden, malicious web pages in a private session that would then never be recorded in the history. Personally, I think all browsers should do it this way as it forces the user to know what is going on with their system. It is inconvenient for automation, but better for security.
Shortcuts usually aren't...