specbug
specbug

Reputation: 562

Selenium Chrome Error: You are using an unsupported command-line flag: --ignore-certifcate-errors

Okay so I am learning Web Scraping and am comfortable with Java hence I choose Jsoup, which is a web scraping library. I planned on scraping A CodeChef contest problem (which is just a coding problem), but I found difficulty scraping all the displayed content, which is not possible as most of it is dynamic source. So I used selenium to render the JavaScript and obtain simple HTML page and then feed it to JSOUP.

So I tried printing the rendered HTML page just to verify, but I get the following error when I run the code:

My Code:

    File f = new File("<Path to chromedriver.exe>");
    System.setProperty("webdriver.chrome.driver", f.getAbsolutePath());
    WebDriver driver = new ChromeDriver();
    driver.get("https://www.codechef.com/problems/FRGTNLNG");
    System.out.println(driver.getPageSource());

Error (in chrome):

You are using an unsupported command-line flag: --ignore-certifcate-errors. Stability and security will suffer

I tried the following solution from Chrome Error: You are using an unsupported command-line flag: --ignore-certifcate-errors. Stability and security will suffer, I installed the latest chromedriver but it didn't resolve my error.

I also tried adding Desired Capabilities (now deprecated) and ChromeOptions as per Pass driver ChromeOptions and DesiredCapabilities?, but the same error persists.

Thanks in advance!

Upvotes: 4

Views: 3389

Answers (1)

undetected Selenium
undetected Selenium

Reputation: 193058

The error says it all :

You are using an unsupported command-line flag: --ignore-certifcate-errors. Stability and security will suffer

As per best programming practices, use the ChromeOptions Class to open Chrome Browser being maximized, disabling the infobars and disabling the extensions as follows :

System.setProperty("webdriver.chrome.driver", "C:\\path\\to\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
options.addArguments("disable-infobars");
options.addArguments("--disable-extensions");
options.addArguments("--test-type");
options.addArguments("--ignore-certificate-errors");
WebDriver driver =  new ChromeDriver(options);
driver.get("https://www.google.co.in");

Additionally, perform the following steps :

  • Update your JDK to the most recent versions JDK 8u162
  • Upgrade Selenium-Java Clients to v3.10.0.
  • Upgrade ChromeDriver to the latest release ChromeDriver v2.35
  • Clean up the Project Space from your IDE.
  • Run CCleaner tool to wipe off all the OS system chores.
  • If your base Web Browser version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of the Web Browser.
  • Take a System Reboot.
  • Execute your @Test

Upvotes: 4

Related Questions