I am testing a website which requires personal SSL certificates in order to do certain things, such as sign-in.
I have a Webdriver (Selenium 2.0) test that I have set up with a proxy:
Proxy localhostProxy = new Proxy();
localhostProxy.setProxyType(Proxy.ProxyType.MANUAL);
localhostProxy.setHttpProxy("www-proxyname:port");
FirefoxProfile profile = new FirefoxProfile();
profile.setProxyPreferences(localhostProxy);
driver = new FirefoxDriver(profile);
And this will access the homepage fine. The test then clicks the sign in button, enters in the correct credentials and clicks on submit. At this point the browser then goes into a loading state, and I'm assuming it's because the SSL certificate is missing from my side and therefore cannot connect to the sign in service.
I searched for different proxy solutions, and found this:
profile.setAcceptUntrustedCertificates(true);
profile.setAssumeUntrustedCertificateIssuer(true);
So I added it into my code, but it doesn't seem to do what I want. I think I'm looking for a way to tell WebDriver that my ssl certificate is in x directory, please use it when accessing this site. Does anyone know how to do this?
My Test code is:
@Test
public void userSignsInAndVerifiesDrawerViews(){
driver.get("www.url.com");
waitFor(5000);
driver.findElement(By.xpath("//a[contains(text(), 'Sign in')]")).click();
waitFor(3000);
String username = "seleniumtest";
String password = "seleniumtest1";
driver.findElement(By.id("username")).sendKeys(username);
driver.findElement(By.id("password")).sendKeys(password);
driver.findElement(By.xpath("//signin")).click();
waitFor(30000);
String signInLinkText = driver.findElement(By.xpath("//xpath")).getText();
assertEquals(signInLinkText, username);
}
Thanks,
Beccy
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…