相关疑难解决方法(0)

在Webdriver中使用个人SSL证书(Selenium 2.0)

我正在测试一个需要个人SSL证书的网站才能做某些事情,比如登录.

我有一个使用代理设置的Webdriver(Selenium 2.0)测试:

    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);
Run Code Online (Sandbox Code Playgroud)

这将很好地访问主页.然后,测试点击登录按钮,输入正确的凭据并单击提交.此时浏览器进入加载状态,我假设是因为我的身边缺少SSL证书,因此无法连接到登录服务.

我搜索了不同的代理解决方案,发现了这个:

    profile.setAcceptUntrustedCertificates(true);
    profile.setAssumeUntrustedCertificateIssuer(true);
Run Code Online (Sandbox Code Playgroud)

所以我把它添加到我的代码中,但它似乎没有做我想要的.我想我正在寻找一种方法告诉WebDriver我的ssl证书在x目录中,请在访问此站点时使用它.有谁知道如何做到这一点?

我的测试代码是:

@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);
}
Run Code Online (Sandbox Code Playgroud)

谢谢,贝西

java selenium webdriver

7
推荐指数
1
解决办法
1万
查看次数

Python Selenium - 如何指定在客户端SSL身份验证中使用的客户端证书

我根据Python Selenium中的答案查看了所有json文件中的所有可能键- FireFox webdriver配置文件首选项中有哪些可能的键,但是我找不到用于指定要在我的SSL连接中使用的客户端证书的密钥.

我已经对此进行了研究,但我找不到确切的答案.我发现我们需要根据如何使用Selenium [在Python中]为Firefox导入SSL证书中的答案将证书添加到FireFox配置文件中?,但我有点困在这里,我无法弄清楚这个证书究竟是如何添加的.

请注意,我不是在谈论信任服务器的证书.默认情况下,启动SSL连接时,将分配给工作站的本地证书用作客户端证书.在这里,我需要为我的SSL连接使用新的证书/私钥对.我需要这样做来测试SSL中的客户端身份验证.

所以,总之,我正在寻找一些看起来像这样的配置:

profile.add_client_cert(path_to_cert)
profile.add_private_key(path_to_private_key)
Run Code Online (Sandbox Code Playgroud)

我发现了一些可能是我需要调整的文件,但不知道如何将证书和密钥添加到这些文件中,cert8.db以及key3.db.我在FireFox配置文件目录中找到了这些文件.

我搜索了selenium的源代码但找不到答案:https: //github.com/SeleniumHQ/selenium/search?utf8 =%E2%9C%93&q =cert

python authentication ssl selenium

6
推荐指数
1
解决办法
1576
查看次数

标签 统计

selenium ×2

authentication ×1

java ×1

python ×1

ssl ×1

webdriver ×1