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 的解决方案非常有效。这些功能不是最终的,因为我按了 10 次 Enter 按钮。我这样做是因为网络驱动程序需要很长时间才能真正调用该网址。与此同时,他已经开始施压了。

在 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/59787837/

相关文章:

JavaFX Scene Builder 2.0 动态 css 菜单按钮

python - Selenium:打开新链接并切换选项卡以获取内容

windows - 有没有开源浏览器 GUI 自动化工具支持单击页面上任意位置的特定图标?

java - 具有通用服务的 Spring Boot 映射器

java - listview.setadapter(adapter) 生成的主要空异常

java - 使用 Java Graphics 在白色上绘制黄色

java - Selenium Webdriver startWith() 方法在 Java 中不起作用

android - 带有 eq ("string"的白盒 invokeMethod )

android uiautomator : UIObject. 带有日文字符的 setText 失败

ruby - 如何测试网络抓取应用程序?