lev4
lev4

Reputation: 133

How to ignore ssl certificate in codeception chrome headless browser?

I added in acceptance.suite.yml

chromeOptions:
    args: ["--headless", "--disable-gpu","--test-type","--ignore-certificate-errors"],

but no luck? what can i do now

description edit:

When i start tests in headless mode they get stuck, in the _output file (fail.png) i get blank page. So i think that they get to "Insecure Connection" page and can't get through it, and my question is how to avoid that page

Upvotes: 3

Views: 5088

Answers (4)

user332951
user332951

Reputation: 409

Not sure if this already answered but according to codeception documentation https://codeception.com/docs/modules/WebDriver

modules:
   enabled:
      - WebDriver:
   config:
     url: 'http://localhost/'
     browser: chrome
     capabilities:
         acceptInsecureCerts: true

Upvotes: 5

charlesdeb
charlesdeb

Reputation: 601

I suspect the argument you want is allow-insecure-localhost. This line worked for me to configure my acceptance.suite.yml file in CodeCeption.

- WebDriver:
    url: xxx.com
    window_size: false # disabled in ChromeDriver
    port: 9515
    browser: chrome
    capabilities:
        goog:chromeOptions: 
            args: ["allow-insecure-localhost","headless","start-maximized"]

This page lists all the options that chrome supports https://peter.sh/experiments/chromium-command-line-switches/#allow-insecure-localhost. Google themselves link to that (3rd party) page from their own page describing ChromeDriver config https://sites.google.com/a/chromium.org/chromedriver/capabilities.

Upvotes: 1

Faiz Muhammad
Faiz Muhammad

Reputation: 1

Please try following code .

        ChromeOptions options = new ChromeOptions();
        options.addArguments("--disable-dev-shm-usage");
        options.addArguments("--no-sandbox");
        options.addArguments("--headless", "--window-size=1920,1200", "--ignore-certificate-errors");
        options.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        options.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
        driver = new ChromeDriver(options);

Upvotes: 0

whydoieven
whydoieven

Reputation: 599

This works for me,

ChromeOptions options = (ChromeOptions) caps.getCapability(ChromeOptions.CAPABILITY);
options.addArguments("--headless", "--disable-gpu", "--window-size=1366,768", "--no-sandbox");  
caps.setAcceptInsecureCerts(true);

Upvotes: 0

Related Questions