Is there a way in Selenium web driver (python, Firefox) to check that the current window is in private mode(private window so the cookies won't be cached) or it is just a normal window?
Asked
Active
Viewed 493 times
1
-
I certainly hope not! – Pointy Jul 23 '15 at 00:41
-
Have a look at [incognito](http://stackoverflow.com/questions/27630190/python-selenium-incognito-private-mode). looks like you are starting with a new profile each time. – lloyd Jul 23 '15 at 00:51
-
I'm sad to say that [this](https://gist.github.com/cou929/7973956) works for me – lbeziaud Jul 23 '15 at 00:56
-
Actually I have open a mixed of private and normal windows in Selenium, and I need to check at some point which one is which. So I'm looking for some selenium command or firefox flag to check that. – Alex Jul 23 '15 at 01:02
2 Answers
4
Selenium actually already runs private mode by default. Every time you start any driver via Selenium it creates a brand new anonymous profile. This of course if you haven't specified an already created profile.

DJanssens
- 17,849
- 7
- 27
- 42
-
1
-
@sircapsalot thank you for contributing to such an awesome piece of software! ;) – DJanssens Jul 23 '15 at 01:01
-
-
Yes, it is a fresh profile but then cookies would be stored there while you are visiting domains. I need to open private windows and then close them to delete cookies.So I need a way to detect if the widow that I'm closing is a private window or not. – Alex Jul 23 '15 at 02:02
0
I think you can check the path of the browser's profile, like:
# start a Firefox named `ff`
> ff.firefox_profile.path
'/var/folders/v3/vnzplyt50796n0tvgb2rvwm00000gn/T/tmppe0Pwx'
If you've pointed a existing profile, it would be named as webdriver-py-profile-namecopy
: source code

LittleQ
- 1,860
- 1
- 12
- 14
-
But if I open a normal page and then open a private window, it still uses the same profile, so It can not help. – Alex Jul 23 '15 at 01:59