Selenium with C# 61 - How to handle invalid SSL certificate error in Chrome & Firefox in selenium C#

Опубликовано: 24 Март 2026
на канале: Ankpro Training
4,309
47

In this video we will see
What is an SSL certificate
When SSL certificate becomes invalid
Code demo on how to handle invalid SSL certificate error in Chrome & Firefox using selenium C#

#selenium #seleniumcsharp #seleniumsslerror

**When SSL certificate becomes invalid? **
Site is using an expired certificate
Certificate doesn’t include the website’s hostname
Certificate is using the outdated algorithm and no longer trusted

Possible Interview Questions on ssl certificate error in selenium
What is an ssl certificate?
How websites provide security to sensitive data?
When ssl certificates becomes invalid?
How to handle websites with invalid ssl certificates in selenium?

**Code: **
[TestMethod]
public void HandleInvalidSSLCertificateError()
{
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AcceptInsecureCertificates = true;

FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.AcceptInsecureCertificates = true;

IWebDriver driver = new FirefoxDriver(firefoxOptions);
driver.Manage().Window.Maximize();
driver.Url = "https://expired.badssl.com/";

Console.WriteLine(driver.FindElement(By.Id("content")).Text);
Thread.Sleep(2000);
driver.Quit();
}