How to start Browser in Private mode using Selenium 2.x

5,701 views
Skip to first unread message

saorabh singh

unread,
Jul 13, 2012, 9:26:12 AM7/13/12
to seleniu...@googlegroups.com
Hi All,

I need to test my web pages in private mode using Selenium.
So please help me out to invoke browser in Private mode for different browsers.


Thanks & Regards,
Saorabh Singh

saorabh singh

unread,
Jul 13, 2012, 9:27:05 AM7/13/12
to seleniu...@googlegroups.com
I am using Java API's of selenium 2.21

saorabh singh

unread,
Jul 19, 2012, 8:51:14 AM7/19/12
to seleniu...@googlegroups.com
Hi guys,
Any info about my Question???
Please help me out.

Regards,
Saorabh Singh


On Friday, 13 July 2012 18:56:12 UTC+5:30, saorabh singh wrote:

Peter Gale

unread,
Jul 19, 2012, 9:00:25 AM7/19/12
to Selenium Users
Selenium tries to automate user actions in a web browser.

So the first questionis  ... how would you start your browser in private mode manually?

The answer may vary for each type of browser you want to use.


Date: Thu, 19 Jul 2012 05:51:14 -0700
From: kun...@gmail.com
To: seleniu...@googlegroups.com
Subject: [selenium-users] Re: How to start Browser in Private mode using Selenium 2.x
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/-gLsik7TLacJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Mark Collin

unread,
Jul 19, 2012, 9:34:42 AM7/19/12
to seleniu...@googlegroups.com

The other question would be what is testing in private mode going to tell you?

 

Are you trying to test that the browser history is not stored when using private mode?  If so you aren’t testing your website, you’re testing the browser (and wasting a lot of time).

saorabh singh

unread,
Jul 20, 2012, 3:25:59 AM7/20/12
to seleniu...@googlegroups.com
Hi Mark,

Testing in Private mode will allow me to test Some flow which is dependent upon mode in which browser has been opened.
Some of the issues Observed in private mode

- Issue with password permanent storage in private browsing mode, user goes to roaming every time when they select Remember computer option. They go into a roaming loop.(without closing the browser)
- IF user is enrolled in private browsing mode,password cannot be reset.

these are some functional issues which are observed in Private browsing mode.

So we want to close these gaps in our test suit.
Please help me out.

Thanks & Regards,
Saorabh Singh

Peter Gale

unread,
Jul 20, 2012, 3:53:52 AM7/20/12
to Selenium Users
Saorabh

Are these all things which you can be controlled from within the program, e.g. the Remember Computer option?

Anyway, my question remains ... tell us how you would start your browser in private mode for each of the browsers you need to use, and we can try to tell you how to automate those actions with Selenium Webdriver.

Also, I'd ask if you need to check the private mode browsing functionality in all possible browsers, or would it be sufficient to test it in one browser type only?

I'm not going to research private browsing in all browsers, but here's how you could do it in Firefox:

Under "about:config" you can see there's a "browser.private.browsing.autostart" preference.

This can be set from within your code using:

    FirefoxProfile firefoxProfile = new FirefoxProfile();   
    firefoxProfile.setPreference("browser.private.browsing.autostart", true);


Peter


Date: Fri, 20 Jul 2012 12:55:59 +0530
Subject: Re: [selenium-users] Re: How to start Browser in Private mode using Selenium 2.x
From: kun...@gmail.com
To: seleniu...@googlegroups.com

Mark Collin

unread,
Jul 20, 2012, 4:09:53 AM7/20/12
to seleniu...@googlegroups.com

So basically you are testing that private mode works.  You cannot force people to set their browser up in a certain way so you cannot be sure that they are accepting your cookies.

 

To quote Mozilla’s support page:

What does Private Browsing not save?

·         Visited pages: No pages will be added to the list of sites in the History menu, the Library window's history list, or the Awesome Bar address list.

·         Form and Search Bar entries: Nothing you enter into text boxes on web pages or the Search bar - Easily choose your favorite search engine will be saved for Control whether Firefox automatically fills in forms with your information.

·         Passwords: No new passwords will be saved.

·         Download List entries: No files you download will be listed in the Use the Downloads window to manage downloaded files after you turn off Private Browsing.

·         CookiesCookies - Information that websites store on your computer store information about websites you visit such as site preferences, login status, and data used by plugins like Adobe Flash. Cookies can also be used by third parties to track you across web sites. For more info about tracking, see How do I turn on the Do-not-track feature?

Note: To prevent Flash from storing cookies, you must be using its latest version. See Updating Flashfor instructions.

·         Cached Web Content and Offline Web Content and User Data: No temporary Internet files (cachedfiles) or files that websites save for offline use will be saved.

Note:

·         If you create new Bookmarks while using Private Browsing, they will not be removed when you stop Private Browsing.

·         If you save files to your computer while using Private Browsing, they will not be deleted when you stop Private Browsing. However, any files you open in an external application will be cleared from the system's temporary folder, and none of the files you download will appear in the Use the Downloads window to manage downloaded files list.

 

If you really want to force private mode have a look at:

 

http://support.mozilla.org/en-US/kb/private-browsing-browse-web-without-saving-info#w_how-do-i-always-start-firefox-in-private-browsing

 

I would suggest setting up a private browsing profile and a normal profile and switching between them for your testing.  There have been lots of posts about custom profiles in this list.

saorabh singh

unread,
Jul 20, 2012, 5:38:25 AM7/20/12
to seleniu...@googlegroups.com
Hi Peter,

Thanks for the help.
I will try this option in IE.

Regards,
Saorabh Singh

Peter Gale

unread,
Jul 20, 2012, 5:42:14 AM7/20/12
to Selenium Users
Saorabh

The code I gave relates to Firefox. It will not work on IE.

Peter


Date: Fri, 20 Jul 2012 15:08:25 +0530

saorabh singh

unread,
Jul 20, 2012, 8:33:21 AM7/20/12
to seleniu...@googlegroups.com
Okey So what Should be done For IE,
I guess For IE also we can set profile.

Peter Gale

unread,
Jul 20, 2012, 9:18:49 AM7/20/12
to Selenium Users
I don't know what you'd have to do for IE off the top of my head.

But if you can find out how to turn private browsing on for IE manually, then someone here might be able to tell you how to configure that from Selenium.

Though for IE you might just find that if you turn private browsing on manually first, then your tests may run in private browsing mode until you turn it off again.


Date: Fri, 20 Jul 2012 18:03:21 +0530

Peter Gale

unread,
Nov 6, 2012, 3:39:30 AM11/6/12
to Selenium Users
The tools menu isn't a part of the web page itself so cannot be controlled by Selenium.

You should be able to use the Java robot class to navigate the menu from code.

Or setting IE to the private browsing mode manually should mean that any subsequent Selenium based IE sessions are private.


Date: Mon, 5 Nov 2012 13:07:38 -0800
From: prathyus...@gmail.com
To: seleniu...@googlegroups.com

Subject: Re: [selenium-users] Re: How to start Browser in Private mode using Selenium 2.x

Peter,

For IE 8 to turn on in private browsing manually navigate to Tools and click on InPrivate Browsing. Can you please tell me how to configure that from Selenium(java)?

Prathyusha.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/F1vI9bSrF0AJ.

tushar....@magicsw.com

unread,
May 10, 2016, 6:45:08 AM5/10/16
to Selenium Users
Hi All,

It seems a pretty old chain. But I'm facing the same issue, the code you provided:
FirefoxProfile firefoxProfile = new FirefoxProfile();    
firefoxProfile.setPreference("browser.private.browsing.autostart", true);
is not working. I am using the below code:
FirefoxProfile fp = new FirefoxProfile();
fp.setPreference("browser.privatebrowsing.autostart", true); //I have checked in about:config and there is no period between private and browsing
dv = new FirefoxDriver(); 
It opens firefox but I don't think it is private window as it does not shown any purple Private window icon on the top(which appears for New Private Windows).

Can anyone help?

Regards,
Tushar

⇜Krishnan Mahadevan⇝

unread,
May 10, 2016, 11:12:04 PM5/10/16
to Selenium Users
Tushar,

Some of the things that Private Mode [ Incognito mode] gives you are :
1. Doesn't remember history.
2. Clear cache and cookies clean up.

I believe by default Selenium is already doing this by spinning off a new Firefox browser which is clean. So what is your use case to try and spawn Firefox in an Incognito mode ? What are you trying to solve ?



Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages