How does Selenium Webdriver handle the SSL certificate in Edge?

SeleniumAutomation TestingTesting Tools

We can handle SSL certificates in Edge browser with Selenium webdriver. This is done with the help of the EdgeOptions class. We shall create an object of this class and set the parameter setAcceptInsecureCerts to the true value.

Finally, this information has to be passed to the webdriver object to get the desired browser settings. An SSL is a protocol designed to establish a secured connection between the server and the browser.

Syntax

EdgeOptions e = new EdgeOptions();
e.setAcceptInsecureCerts(true);

Code Implementation

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.edge.EdgeOptions;
public class EdgeBrwserSSL{
   public static void main(String[] args) {
      System.setProperty("webdriver.edge.driver",
      "C:\\Users\\ghs6kor\\Desktop\\Java\\msedgedriver.exe");
      //instance of EdgeOptions
      EdgeOptions e = new EdgeOptions();
      //configure setAcceptInsecureCerts to true boolean value
      e.setAcceptInsecureCerts(true);
      //object of EdgeDriver
      WebDriver driver = new EdgeDriver(e);
      //implicit wait
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      //URL launch
      driver.get("application url");
   }
}
raja
Published on 25-Jun-2021 12:31:27
Advertisements