When I run the below code first time, the website opens with extensions but the website would not load. Click on Terminate and when I run it second time, it is successful. How to run the code successfully first time?

System.setProperty("webdriver.chrome.driver","C:\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=C:/Users/user_name/AppData/Local/Google/ Chrome/User Data");
options.addArguments("--start-maximized");
driver = new ChromeDriver(options);
driver.get("name of the website")
1

There are 1 best solutions below

0
On

Can you try the below code -

options.addExtensions(new File("/path/to/extension.crx"));
options.addArguments("start-maximized");