1
$\begingroup$

With session=StartWebSession["Firefox"] it seems I don't have any options to add, or do I? I would like to operate in private browsing mode. If after starting the session I manually open in the resulting browser window a private browsing tab and close the initial one, then after that, say, WebExecute[session, "OpenPage" -> "https://www.wolframalpha.com"] does not work anymore, I get

enter image description here

Is it possible to start a web session in private browsing mode?

$\endgroup$

1 Answer 1

1
$\begingroup$

No, you don't really have any options to fiddle with in StartWebSession (except Visible). If you've worked with Selenium/geckodriver before, you can see how Mathematica communicates with it if you look into WebUnit`Private`setsession. I've tried to add the -private argument, but I haven't managed to make it open a private browsing window. You may try with setting a custom profile ...

However, if you manually open the private browsing window, then you have to first switch the active window, and then you will be able to interact with it:

session = StartWebSession["Firefox"];

(* ... Manually open new private window ... *)

windows = WebExecute[session, "BrowserWindows"];
WebExecute[session, "SetBrowserWindow" -> Last[windows]];

WebExecute[session, "OpenPage" -> "https://google.com"]
$\endgroup$
1
  • $\begingroup$ Aha! That's all I need in fact $\endgroup$ Commented Aug 24, 2024 at 22:46

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.