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

我使用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

解决方法:

我遇到了同样的问题,我可以通过使用机器人来解决它,为url创建函数并将其传递给不同的线程.

    Runnable mlauncher = () -> {
    try {

      driver.get(url);
     } catch (Exception e) {
          e.printStackTrace();
       }
    };

public void myfunction {
 try {

   Thread mthread = new Thread(mlauncher);
   mthread.start

  robot.keyPress(KeyEvent.VK_ENTER);
  robot.keyRelease(KeyEvent.VK_ENTER);

 } catch (Exception e) {
          e.printStackTrace();
       }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐