Quality Testing

Quality is delighting customers

How to handle Security Certificate in Google Chrome Browser?

Please share the code.

Thanks,

Mahi

Views: 235

Reply to This

Replies to This Discussion

Hi Mahi,

You haven't mentioned the platform/language you are using. I assume you are working with selenium which is being widely used by many software testing companies and here is the code of the same:

package com.example;
import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class SSLExample_Chrome {

private WebDriver driver;

@BeforeClass
public void setUp() {
DesiredCapabilities capability = DesiredCapabilities.chrome();
// To Accept SSL certificate
capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
// setting system property for Chrome browser
System.setProperty("webdriver.chrome.driver", "E:/chromedriver.exe");
// create Google Chrome instance and maximize it
driver = new ChromeDriver(capability);
driver.manage().window().maximize();
}

@Test
public void openApplication() {
System.out.println("Navigating application");
driver.get("https://cacert.org/");
WebElement headingEle = driver.findElement(By.cssSelector(".story h3"));
// Validate heading after accepting untrusted connection
String expectedHeading = "Are you new to CAcert?";
Assert.assertEquals(headingEle.getText(), expectedHeading);
}

@AfterClass
public void tearDown() {
if (driver != null)
driver.quit();
}
}

Hope this helps.

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2017   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service