【发布时间】:2015-06-16 13:17:17
【问题描述】:
我在 Windows 7 上使用 Selenium Web 驱动程序。
我正在尝试测试一个使用身份验证的网站,我需要使用 SSL 证书。
当我使用 Selenium 之外的 Firefox 时一切正常,但我注意到 Selenium 打开的 Firefox 浏览器会话没有注册任何证书,因此很明显它不起作用。
当我使用 Firefox “out” Selenium 时,这里是高级首选项
在这里你和我使用 Selenium 打开的 Firefox 会话时是一样的
我已尝试保持会话打开并手动注册证书,但浏览器会话未注册证书。
这是我的代码,如果有用的话
package myTestProjects;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class GAMOPERA_Test_01 {
private static WebDriver driver = null;
public static void main(String[] args) throws InterruptedException {
// Create a new instance of the Firefox driver
System.out.println("Creo una nuova sessione del browser Firefox ...");
driver = new FirefoxDriver();
//Put a Implicit wait, this means that any search for elements on the page could take the time the implicit wait is set for before throwing exception
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
// It is always advisable to Maximize the window before performing DragNDrop action
System.out.println("Massimizzo la finestra del browser ...");
driver.manage().window().maximize();
Thread.sleep(3000L);
//Launch the Sistema Piemonte Home Page
System.out.println("Mi collego a Sistema Piemonte ...");
driver.get("http://<my_site_url>");
Thread.sleep(3000L);
// Find the element Accedi o
System.out.println("Accesso tramite certificato digitale ...");
driver.findElement(By.xpath("/html/body/div[6]/div/div/div[2]/form/table/tbody/tr[3]/td/input")).click();
//driver.findElement(By.className("loginbutton")).click();
Thread.sleep(3000L);
// Print TEST = OK!!
System.out.println("TEST = OK !!");
//driver.quit();
}
}
有什么建议吗?
【问题讨论】:
标签: java selenium ssl selenium-webdriver