selenium webdriver – Chrome browser is not getting launched using automated suite

Until now I have tried below things.

  1. Upgraded selenium version to 4.11.0
  2. Removed WebDriver Manager from pom.xml as selenium 4.11.0 onwards will take care of WebDriver.
  3. Deleted previous versions of Chrome driver from path .cache/selelium/chromedriver/linux64/ . so, that latest chrome driver gets downloaded.
  4. Tried Chrome For Test to launch the browser.

Below is the code snippet.

case "CHROME":
            //System.setProperty ("webdriver.http.factory","jdk-http-client");
            ChromeOptions chromeOptions = new ChromeOptions();
            HashMap<String, Object> chromePrefs = new HashMap<String, Object>();
            chromePrefs.put("profile.default_content_settings.popups", 0);
            chromeOptions.setExperimentalOption("prefs", chromePrefs);
            chromeOptions.addArguments("disable-infobars");
            chromeOptions.addArguments("--no-sandbox");
            chromeOptions.addArguments("--disable-dev-shm-usage");
            chromeOptions.addArguments("--remote-allow-origins=*");
            
            if (acr.getIncognitoModeOption().equalsIgnoreCase("Yes")) {
                chromeOptions.addArguments("--incognito");
            }
            //WebDriverManager.chromedriver().driverVersion(acr.getChromeVersion()).setup();
            //WebDriverManager.chromedriver().setup();
            String filePath = (System.getProperty("user.dir")
            + "/src/main/resources/ChromeForTest/chrome-linux64/chrome").replaceAll("\\\\|/",
                    "\\" + System.getProperty("file.separator"));
            chromeOptions.setBinary(filePath);
            DesiredCapabilities cap = new DesiredCapabilities();
            cap.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
            cap.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
            driver = new ChromeDriver(chromeOptions);
            ca = new CommonActions();
            ca.writeLog("CHROME browser has launched succesfully!!");

Read more here: Source link