Issue
I wanted to open a normal and incognito mode together in selenium. I could open two browsers in normal mode but I am not sure how to open the another open in incognito mode in selenium 4.
The below open the 2nd browser window in normal mode where I want this to be opened in incognito mode.
driver.switchTo().newWindow(WindowType.WINDOW).get("URI");
Expected: 1st browser window in normal mode. 2nd browser window in incognito mode.
Actual: 1 browser opened in normal mode. 2nd browser opened in normal mode.
Solution
WebDriverManager.chromedriver().setup();
ChromeOptions options = new ChromeOptions();
options.addArguments("--incognito");
WebDriver driver_1 = new ChromeDriver();
driver_1.manage().window().maximize();
driver_1.get("url");
WebDriver driver_2 = new ChromeDriver(options);
driver_2.manage().window().maximize();
driver_2.get("url");
Answered By - AbiSaran
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.