Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to run chrome in incongito mode through selenium. I googled enough for it and found how to run chrome directly in incongito mode with the help of this link:

  1. Right click on the shortcut of Google Chrome and select "Properties".
  2. On "Shortcut" tab on the "Target" field add an –incognito to the end of program path. So in the "Target" field you should have "C:Program Files (x86)GoogleChromeApplicationchrome.exe" –incognito

but I didn't get how to run this in selenium.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
348 views
Welcome To Ask or Share your Answers For Others

1 Answer

One other way to launch chrome in incognito mode is to add argument "-incognito" like following:

ChromeOptions options = new ChromeOptions();
options.addArguments("--incognito");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);

This solution works for me.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...