I'm 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 app 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 suggested fixes, but nothing worked. A proposed workaround/solution I saw again and again was to do this:
options.AddArgument("test-type");
This just doesn't do anything with Chrome 42.0. Here is my C# code (console app):
using(var driver = new ChromeDriver()) {
driver.Navigate().GoToUrl("http://localhost/test.aspx");
}
The Chrome window with error inside yellow bar looks like this:
I don't know WTH happened, but suddenly this morning this is working perfectly. Last night this same code didn't work. Anyway, in case it helps anyone, here is the FULLY working C# code for chromedriver 2.5, .NET 4.5, and Selenium 2.45 binaries 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 your tests, make a static class variable thusly:
private static ChromeDriver driver;
(In fact you may want to make all your class-level variables static.)
And then do something like the following so that your handle to ChromeDriver can be reused across all 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));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With