"Karmanyevadhikaraste ma phaleshu kadachana, Ma karma phala hetur bhurmatey sangostva akarmani."

Handling Certificate errors

import java.util.Iterator;
import java.util.Set;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;

// to handle untrusted fire fox certificate errors
//create a firefox profile and accept the error in that profile manualy..
//if not manually, create firefox profile FirefoxProfile fp=new FirefoxProfile(); and fp.setAcceptuntrustedCertificates(true);
// or use the line fp.setAssumetrustedCertificateIssuer(false);
//chrome driver will take care of this certificate errors- when system proprty file executed
//for IE, u have to write line- driver.navigate().to("javascript:document.getElementById('overridelink').click()");

  1. driver.navigate().to("javascript:document.getElementById('overridelink').click()");  
//http://www.mythoughts.co.in/2012/05/handling-security-cerificatesuntrusteds.html#.U3E4ufldVmM

public class Certificate_Error {



public static void main(String[] args) {
FirefoxProfile fp= new FirefoxProfile();
fp.setAcceptUntrustedCertificates(true);
//or use below line
fp.setAssumeUntrustedCertificateIssuer(false);
WebDriver driver = new FirefoxDriver(fp);
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.get("http://soapui-tutorial.com/login/soapui-memberlogin.php");
driver.findElement(By.xpath("xxxx")).sendKeys("aaa");
driver.findElement(By.xpath("xddd")).sendKeys("ccc");
driver.findElement(By.xpath("xxxx")).click();

Set<String> ids= driver.getWindowHandles();
Iterator <String> iter= ids.iterator();
String main=iter.next();
String tab= iter.next();
driver.switchTo().window(tab);
driver.findElement(By.xpath("xcdd")).click();

//Here comes the certificate error