0

ChromeOptions在Java中遇到了这个问题。在我的代码中实现它时,它不包含我需要在 Chrome 浏览器中接受/忽略 SSL 证书的一些方法。这样的方法.setCapability我可以传入它CapabilityType.ACCEPT_SSL_CERTS, true);

例子:

ChromeOptions options = new ChromeOptions();
options.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
options.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);    

... setCapabilityEclipse 在哪里被标记为错误,它说

The method setCapability(String, boolean) is undefined for the type ChromeOptions
4

2 回答 2

1

我无法在他的帖子中回答,但我认为 Nikolai 的建议是:

  • 你能检查你在这个类中有正确的导入吗?import org.openqa.selenium.remote.CapabilityType;
  • 您在 pom.xml 文件中使用的 Selenium 版本是什么?前任:
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.141.59</version>
        </dependency>
于 2020-07-31T16:25:49.130 回答
0

使用 Robot 类来接受它。对我来说,每次我必须处理这种弹出窗口时它都会起作用。

    Robot r = new Robot();
    // use tab to move to desired button
    r.keyPress(KeyEvent.VK_TAB);
    r.keyRelease(KeyEvent.VK_TAB);

    //than use enter to click it
    r.keyPress(KeyEvent.VK_ENTER);
    r.keyRelease(KeyEvent.VK_ENTER);
于 2020-07-28T13:48:11.863 回答