Reputation: 173
I want to run some automated browser tests on my ASP.NET Core 2.1 web application. For this application, I have HttpsRedirection enabled, and I ran the command dotnet dev-certs https --trust
to trust the ssl certificates used by ASP.NET Core.
I have downloaded the firefox selenium driver and added the executable to my PATH. This works as a firefox window is opened when I run the code.
Accepting the risk and continuing does nothing as the code has already disconnected from the browser.
var firefoxOptions = new FirefoxOptions();
var profile = new FirefoxProfile();
profile.AcceptUntrustedCertificates = true;
// Tried the following, got this: Invalid moz:firefoxOptions field acceptInsecureCerts
// firefoxOptions.AddAdditionalCapability(CapabilityType.AcceptInsecureCertificates, true);
firefoxOptions.Profile = profile;
var driver = new FirefoxDriver(firefoxOptions);
driver.Url = "http://localhost:5002/";
I expect to be taken to my web app, as happens when I browse to http://localhost:5002
in firefox myself. Instead, I get the following:
Upvotes: 4
Views: 1788
Reputation: 2198
Set the parameter directly on FireFoxOptions instead of the profile...
var firefoxOptions = new FirefoxOptions();
firefoxOptions.AcceptInsecureCertificates = true;
I also noticed your URL is non https, if you want to be accepting an insecure certificate, you should probably browse to https instead, i.e
driver.Url = "https://localhost:5002/";
Upvotes: 2