java - selenium chrome 驱动程序选择证书弹出确认不起作用

标签 java selenium testing selenium-webdriver automated-tests

我正在使用 selenium chromewebdriver 3.7 进行自动化测试。每当我启动该站点时,我都会看到一个证书选择弹出窗口,如下所示 enter image description here

但是我无法单击“确定”按钮。这些是我尝试过的选项

 //I have tried getWindowHandle like this  
 String  handle= driver.getWindowHandle();
        this.driver.switchTo().window(handle);

//I have alos tried switching and accept
 driver.switchTo().alert().accept();

//I have also tried to force the enter key like this
 robot.keyPress(KeyEvent.VK_ENTER);
 robot.keyRelease(KeyEvent.VK_ENTER);

 // I also tried this way
 Scanner keyboard = new Scanner(System.in);
 keyboard.nextLine();

我所有的试验都失败了。如何在此弹出窗口中单击“确定”? 这是我找到的最接近但不起作用的解决方案 Link here

最佳答案

我在接受使用签名证书的警告时也遇到了问题。 @eskoba 的解决方案非常有效。这些功能不是最终的,因为我让 enter 按钮按下 10 次。我做了这个,因为 webdriver 需要很长时间才能真正调用 url。与此同时,他已经开始施压了。

在 Python 中:

def threaded_function():
    #Calls the website
    browser.get(url)

def threaded_function2():
    #Presses 10 times
    for i in range(0,10):
        pyautogui.press('enter')

#Calling the website and pressing 10 times in the same time
thread2 = Thread(target = threaded_function2)
thread2.start()

thread = Thread(target = threaded_function)
thread.start()

关于java - selenium chrome 驱动程序选择证书弹出确认不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49512058/

相关文章:

java - 需要逻辑解释java反向字符串

java - 通过 Selenium 启动浏览器时出现异常 java.lang.ClassNotFoundException : org. openqa.selenium.MutableCapability

python - 对初始化期间调用的方法进行单元测试?

java - 如何使用java计算Vector中的不同元素?

Java - 搜索数组中等于给定数字的所有元素索引

java - intellij 未识别 catalina.home

javascript - Selenium WebDriver 隐式等待

python - Scrapy xpath 在 python 中返回空列表

testing - JMeter 将 JSON 响应值传递给下一个请求

testing - grabAttributeFrom() 方法不返回属性值