C # - chromedriver - ignore-certificate-errors

I am trying to use ChromeDriver 2.4.226107 with Selenium 2.45, Google Chrome 42.0.2311.135, Visual Studio 2012 and .NET 4.5. My little test application compiles and runs, but when it launches a new Chrome window, I get this error:

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

I carefully read this post and tried many of the proposed fixes, but nothing worked. The proposed solution / solution, which I saw again and again, was to do this:

 options.AddArgument("test-type"); 

It just does nothing with Chrome 42.0. Here is my C # code (console application):

 using(var driver = new ChromeDriver()) { driver.Navigate().GoToUrl("http://localhost/test.aspx"); } 

The Chrome window with an error inside the yellow bar looks like this:

enter image description here

  • Is there a solution?
  • Is there a better / easier way to run automated tests in a Chrome web browser than Selenium?
+7
c # selenium selenium-webdriver selenium-chromedriver
source share
1 answer

I don’t know what WTH happened, but this morning it works fine. Last night, the same code did not work. In any case, in case this helps someone, here is the COMPLETE working C # code for chromedriver 2.5, .NET 4.5 and Selenium 2.45 binary files for .NET:

 static void Main(string[] args) { ChromeOptions options = new ChromeOptions(); options.AddArgument("test-type"); // Initialize the Chrome Driver using(var driver = new ChromeDriver(options)) { driver.Navigate().GoToUrl("http://localhost/test.aspx"); // Get User Name field, Password field and Login Button var userNameField = driver.FindElementById("txtUsername"); var userPasswordField = driver.FindElementById("txtPassword"); var loginButton = driver.FindElementById("btnLogin"); // Type user name and password userNameField.SendKeys("MyUSN"); userPasswordField.SendKeys("MyPWD"); // and click the login button loginButton.Click(); // Take a screenshot and save it into screen.png driver.GetScreenshot().SaveAsFile(@"F:\temp\screen.png", ImageFormat.Png); Console.ReadLine(); } } 

Note. To reuse the same Chrome browser window for all of your tests, enter a static class variable:

 private static ChromeDriver driver; 

(In fact, you may need to make all your class level variables static.)

And then do something like the following so that your ChromeDriver can be reused in all of your tests:

 [ClassInitialize] // this only executes ONCE per test-run (not once per test!) public static void OneTimeSetup(TestContext ctxt) { ChromeOptions options = new ChromeOptions(); options.AddArgument("test-type"); options.AddArgument("start-maximized"); options.LeaveBrowserRunning = true; driver = new ChromeDriver(@"C:\MyStuff", options); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(4)); } 
+5
source share

All Articles