0

I am having this problem with ChromeOptions class in Java. When implementing it in my code it doesn't contain some of the methods that I need to Accept/Ignore SSL certificate in Chrome browser. Methods like .setCapability so I can pass in it CapabilityType.ACCEPT_SSL_CERTS, true);.

Example:

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

... where setCapability is being marked as a mistake by Eclipse, and it says

The method setCapability(String, boolean) is undefined for the type ChromeOptions
Nikolai Shevchenko
  • 7,083
  • 8
  • 33
  • 42
  • Make sure that you have proper dependencies on [Selenium](https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/MutableCapabilities.html#setCapability-java.lang.String-boolean-) framework – Nikolai Shevchenko Jul 28 '20 at 13:25
  • How to make sure that I am using the right one? Could you please explain to me? – kilo_bravo_delta Jul 29 '20 at 18:25

2 Answers2

1

I can't answer in his thread, but I think Nikolai's suggestion is:

  • can you check you have the correct import in this class? import org.openqa.selenium.remote.CapabilityType;
  • what is the Selenium version you are using in your pom.xml file? Ex:
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.141.59</version>
        </dependency>
Batou
  • 98
  • 1
  • 8
  • the Selenium version is the same> 3.141.59. – kilo_bravo_delta Aug 10 '20 at 10:15
  • OK, and the import at the beginning of the class is `import org.openqa.selenium.remote.CapabilityType;` or maybe `import org.openqa.selenium.remote.*;`? – Batou Aug 10 '20 at 15:33
  • Yes, totally the same-> import org.openqa.selenium.remote.CapabilityType; I kind of find out what's the problem. It looks like Chrome version above 80 can not accept or ignore the SSL certificate- I still don't know the reason, but I'll downgrade Chrome and try again to accept it. – kilo_bravo_delta Aug 11 '20 at 06:52
0

Use the Robot class to accept it. For me it works every time I have to deal with this kind of pop-ups.

    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);
Ledjon
  • 105
  • 8