How to handle SSL certificates in Chrome

239 views
Skip to first unread message

Radhika Joshi

unread,
Sep 22, 2020, 7:10:45 AM9/22/20
to seleniu...@googlegroups.com
Hi team,

I am trying to use DesiredCapabilities to handle SSL Certificates. However, they are deprecated:
DesiredCapabilities cap= DesiredCapabilities.chrome();
cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);


When I try using Chromeoptions, It doesn't work for me:
    ChromeOptions options= new ChromeOptions();
    options.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    driver= new ChromeDriver(options);

Is there any way I can handle these certificates in Chrome?

Thanks & Regards
Radhika Joshi

babu...@gmail.com

unread,
Sep 22, 2020, 2:36:24 PM9/22/20
to Selenium Users

Try below 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();
        }

For more details you can follow the below video.

Radhika Joshi

unread,
Sep 23, 2020, 3:34:15 AM9/23/20
to seleniu...@googlegroups.com
Works for me.. thankyou

Regards
Radhika Joshi


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/46b03ac9-a86a-400e-a264-7b0d9a45efb4n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages