Reputation: 871
I'm trying to run chrome headless using selenium in C# but I keep getting this error:
You are using an unsupported command-line flag: --ignore-certificate-errors, Stability and security will suffer.
I'm using
My code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
namespace MyApp {
public partial class Form1: Form {
public Form1() {
InitializeComponent();
}
private void StartBtn_Click(object sender, EventArgs e) {
string appPath = AppDomain.CurrentDomain.BaseDirectory;
IWebDriver driver;
ChromeOptions options = new ChromeOptions();
options.AddArguments("--headless", "--disable-gpu", "--remote-debugging-port=9222", "--window-size=1440,900");
driver = new ChromeDriver(options);
}
}
}
My WinForm application just has one button with name "StartBtn".
Upvotes: 3
Views: 9963
Reputation: 966
Following was what i did to resolve similar issue
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--test-type");
The following is the whole code just to open url that worked , hope its helpful
System.setProperty("webdriver.chrome.driver", "C:\\Program Files\\Java\\chromedriver.exe");
System.out.println(System.getProperty("webdriver.chrome.driver"));
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("no-sandbox");
chromeOptions.addArguments("--test-type");// this is the one that helped
chromeOptions.addArguments("disable-extensions");
chromeOptions.addArguments("--start-maximized");
WebDriver driver = new ChromeDriver(chromeOptions);
driver.get("https://www.google.com");
System.out.println("Google is selected");
Upvotes: 0
Reputation: 193058
To get rid of the following error :
You are using an unsupported command-line flag: --ignore-certificate-errors, Stability and security will suffer
As you are using Selenium: 3.6
along with Chrome: 61
, instead of using chromedriver v2.3
consider using the latest version of the chromedriver.exe
i.e. v2.33
Additionally, along with your existing arguments add the following arguments as well: disable-infobars
, --disable-extensions
So, the line of code will be as follows:
options.AddArguments("headless", "disable-gpu", "remote-debugging-port=9222", "window-size=1440,900", "disable-infobars", "--disable-extensions")
Upvotes: 2