1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.remote.DesiredCapabilities; public class HandleCertificate { public static void main(String[] args) { // DesiredCapabilities Predefined class inside Selenium DesiredCapabilities cap = new DesiredCapabilities(); // Creating its object Reference // Delibrately throwing SSL certificate as true to selenium // As selenium don't allow to open Website without valid(Unexpired) SSL Certificate cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); // Setting Up ChromeDriver System.setProperty("webdriver.chrome.driver", "..//chromedriver.exe"); // Creating a Object Reference for ChromeDriver // And Passing object reference of DesiredCapabilities to Accept SSL Certicate as True WebDriver driver = new ChromeDriver(cap); // Launching the URL without SSL Certificate driver.get("https://www.cacert.org/"); } } |