硒铬驱动程序选择证书弹出确认不起作用 [英] selenium chrome driver select certificate popup confirmation not working

查看:93
本文介绍了硒铬驱动程序选择证书弹出确认不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Selenium chromewebdriver 3.7自动化测试.每当我浏览该站点时,都会出现一个如下所示的证书选择弹出窗口

I am automating tests using selenium chromewebdriver 3.7. Whenever I lauch the site, I get a certificate selection popup like the one below

但是,我无法单击确定"按钮.这些是我尝试过的选项

However I am not able to click on the OK button. These are the options I have tried

 //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();

我所有的尝试都失败了.如何在此弹出窗口上单击确定"? 这是我发现的最不可行的解决方案,在此处链接

All my trials have failed. How can I click on OK on this popup window? This is the closest solution I found which is not working Link here

推荐答案

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

I had the same problem and I was able to solve it by using the robot, creating function for the url and passing it to a different thread.

    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();
       }

这篇关于硒铬驱动程序选择证书弹出确认不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆