New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 97 users

Issue metadata

Status: Fixed
Owner:
Closed: Dec 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Feature

Blocked on:
issue 792468


Show other hotlists

Hotlists containing this issue:
Hotlist-1
Hotlist-1


Sign in to add a comment

Provide ability to handle certificate errors in Chromedriver/Selenium for headless

Reported by tasos.la...@gmail.com, May 12 2017

Issue description

UserAgent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0

Steps to reproduce the problem:
Use Chromedriver as a Selenium back-end.

What is the expected behavior?

What went wrong?
Currently there's no way to configure headless Chromium options that are exposed via the devtools API[1] from Selenium/Chromedriver -- or there are docs missing.

Certain security related options that used to be controlled via CLI switches in the UI version of Chromium (like --ignore-certificate-errors) are silently ignored and can only be set via devtools, although this is either currently impossible or not documented.

[1] https://chromedevtools.github.io/devtools-protocol/tot/Security/

Did this work before? N/A 

Chrome version: <Copy from: 'about:version'>  Channel: dev
OS Version: 
Flash Version:
 
Showing comments 23 - 122 of 122 Older
We will add support for "acceptInsecureCerts" in the near future.

Comment 24 by mikl...@gmail.com, Aug 4 2017

watching for update to chrome driver
Summary: Provide ability to handle certificate errors in Chromedriver/Selenium for headless (was: Expose devtools API via Chromedriver/Selenium for headless)
Retitling as this issue seems to be specific to certificate issues.
For localhost use cases,  bug 714287  is fixed in the latest Dev channel release 62.0.3178.0. One can now use the --allow-insecure-localhost flag with Chrome headless.

Comment 27 by m...@iddqd.su, Aug 15 2017

Tested Chrome 62 with chromedriver and it does not work. Waiting for next release.

Comment 28 by zi...@zixia.net, Aug 17 2017

The latest google-chrome-unstable v62 with `--allow-insecure-localhost` under Ubuntu 17.04 works for me.

I'm using nodejs with selenium:

```ts
const options = {
  args: [
    '--allow-insecure-localhost', //  https://bugs.chromium.org/p/chromium/issues/detail?id=721739#c26
    '--disable-gpu',
    '--headless', // https://developers.google.com/web/updates/2017/04/headless-chrome
    '--homepage=about:blank',
    '--no-sandbox',
    // '--remote-debugging-port=9222',  // will conflict with webdriver
  ],  //  issue #26  for run inside docker
  binary: '/opt/google/chrome-unstable/chrome',
}
const customChrome = Capabilities
                     .chrome()
                     .set('chromeOptions', options)
```
For #23, any news for supporting "acceptInsecureCerts"?  Thanks!
+1 on "acceptInsecureCerts", that would be perfect. Thanks!

Comment 31 by mikl...@gmail.com, Sep 1 2017

another +1 on "acceptInsecureCerts"
any news regarding "acceptInsecureCerts" ? 
It will likely be a few more weeks before I can work on this. In the meantime, if anyone else have time available please feel free to grab this.
Hi Team,

When can we expect new version which will cover this issue?
+1 on "acceptInsecureCerts", any news for supporting this?  Thanks!
+1 on "acceptInsecureCerts" This option is in high need for implementation. Thanks!

Comment 37 by tymf...@gmail.com, Sep 28 2017

+1 on "acceptInsecureCerts" This option is in high need.
Selenium 3.6.0 was released a few days ago, and they (silently) dropped support for PhantomJS. This fix cannot come soon enough, please!

Comment 39 by gre...@gmail.com, Oct 2 2017

+1 on "acceptInsecureCerts"  This option is in high need.

when this issue will be closed..
Same issue here, cannot test an internal webapps with a self signed certificate. Looking forward for "acceptInsecureCerts"...
Really annoying that this feature is not available. +1 for acceptInsecureCerts
+1 on "acceptInsecureCerts". Really need this.
Anyone tried with chrome 62 version in Windows.
Is it working..
Please let me know.
+1 for "acceptInsecureCerts".  Critical for headless selenium with self-signed certs. Killer use case for chrome headless.
+1 for "acceptInsecureCerts" from me as well.

Comment 47 by h...@chrisaw.com, Nov 13 2017

+1 here too - this is absolutely vital for chrome headless to fully replace PhantomJS for me.
Tested on Windows 7 with Chrome 62 and Chromedriver 2.33, works with the flag --allow-insecure-localhost



@nick I believe this only applies to localhost. Does not help if the headless browser is on a different machine. I'm not on windows so please correct if I am wrong...
I tried today with chrome driver 2.33 and chrome 62.
Still it is not working..

Yes, sorry this will only work on localhost.
Is there any updates on this item?  I have encountered this issue when attempting to execute Selenium integration tests as part of a CI build.  Upgrading to Selenium WebDriver v3.7.1 appears to have exposed a new method on the ChromeOptions class (#setAcceptInsecureCerts(boolean acceptInsecureCerts)), but it doesn't appear to have any impact when running with chromedriver 2.33.0 and chrome 62.

Comment 53 Deleted

Comment 54 by mattm@chromium.org, Nov 23 2017

Cc: mattm@chromium.org
 Issue 786851  has been merged into this issue.
 Issue 786851  is happen in Windows 7.
So the solution should include OS = Windows.

Thanks!
'--disable-web-security', '--allow-running-insecure-content' support needed in HEADLESS mode.

I am using headless chrome via puppeteer API, I am launching chrome with following flags '--disable-web-security', '--allow-running-insecure-content'. When I use real chrome(headfull mode), it works perfect with some warnings in console(which is fine).
But when I enable headless mode, all my tests are failing. Please help.
Is there any update on this issue or estimate as to if/when it will be addressed?  Is there any suggestion as to a workaround that may be used in a headless CI environment?

Comment 58 by m...@orino.ch, Nov 29 2017

Workaround suggestion:
Use ssh to set up a local port forwarding from the machine running Chrome to the target webserver. Then start Chrome with '--allow-insecure-localhost' and run the tests against the local port.

Comment 59 by mikl...@gmail.com, Nov 29 2017

might aswell continue using xvfb than using that workaround. We need headless to support insecure hosts, otherwise there is no point in switching to headless. 
I'm working on a change for this. About 70% of the code was done. However I've been busy with black friday/cyber monday. I'll target sometime in December. But please don't let that stop anyone else from working on a CL, since this is far from my top priority.
+1 to this flag. We have a lot of different systems, some of which are not running on localhost, that use self-signed certificates. Without insecure flag, as phantomjs and chrome (non-headless), it will be difficult to migrate.
+1 please implement an acceptInsecureCerts flag asap.
+1 for this, without this we can't use this feature

Comment 64 Deleted

+1 please implement acceptInsecureCerts flag.

Owner: eseckler@chromium.org
Status: Started (was: Available)
I'll take a stab at adding support for the acceptInsecureCerts capability to ChromeDriver.
Turns out that the approach outlined in #18 doesn't work for target=_blank navigations, because it seems may not connect to the new window's DevTools target (and therefore send Security.enable) quickly enough.

I think we'll probably need a way to override certificate errors globally from the browser target.
Blockedon: 792468
+1, please implement an acceptInsecureCerts flag
+1 please implement acceptInsecureCerts flag.
I'm afraid this requires more work in chromedriver than I expected. Here's why:

To ensure that the acceptInsecureCerts mode is applied globally (for existing and new targets), we would need to override and handle certificateError events on the browser-target DevTools client, after  bug 792468  is fixed.

However, ChromeDriver internally often blocks while polling a single target's DevTools client, e.g. waiting for a response to a command. Because certificateError events may occur on the browser DevTools client while ChromeDriver is blocked on another client, say during a navigation, it's possible that the other client gets stuck because the navigation depends on handling of the certificateError event on the browser client.

Thus, ChromeDriver first needs to implement multi-plexing over other devtools clients while waiting for command responses, so that the certificateError event can be handled concurrently on the browser client.

@johnchen, any idea if that's feasible?
ChromeDriver was designed with the assumption that the automation app works on one window at a time. There might be other windows or tabs around, but generally it only communicates with one window at a time. Events from the other tabs are queued by the network, and are not actively monitored by the code. It's certainly possible to change the design, but it's likely to be a big project.

How about this: the app needs to switch to a window in order to handle certificate errors in that window. Navigation in non-active windows might be blocked by certificate errors, but the next time app switches to that window, any pending certificate errors are handled, and the navigation continues. Would that be good enough for most people?
That would work for my scenario and I suppose it would cover the majority of use cases. The deficiency that you highlighted could probably be considered as a corner case for now. Basically this Cert scenario is killing everybody who just wants to use a non-local test server, which is a very big subset of Headless Chrome users and wannabes.

Kudos to you guys for all the thought you are putting into this. Thanks & good luck
That works for me!
That should work. The only exception I can see is, as johnchen said, having multiple windows. And even then, it would only be a problem if the two windows needed to communicate / rely on each other and the non-active window had a certificate error. That seems unlikely because if the two windows are interdependent they are probably on the same domain and so the certificate error would already have been accepted on the first window and therefore shouldn't come up on the second, right? Seems like a very rare edge case that could be gotten around by the person using the chromedriver.
#72: This doesn't work for navigations that happen before ChromeDriver connects to a new target as I mentioned in #67. That is, the certificate error event might not be sent to DevTools because it can happen *before* the Security domain and the override is enabled. I've got a WIP patch here with a test that illustrates this (testNavigateNewWindow in run_py_tests.py):

https://crrev.com/c/810790

One way around this would be to override and handle these errors globally on the browser target. An alternative might be to add a way to start new targets/windows in a "paused" state to DevTools, so that ChromeDriver (and alike) can perform setup operations before resuming their loading. That's a larger feature request though (see discussion in  bug 792468 ).

#75: Certificate error overriding via DevTools doesn't remember past decisions AFAICT, so you'd see another error in the second window, even if it's the same domain.
The issue with sending certificate error events to the browser target is ChromeDriver would need to monitor the browser target while managing a navigation on a window. So far as I know this isn't easy to do, though I could be wrong.

I think the current design is way too complicated for a simple requirement. --ignore-certificate-errors would have been a much simpler solution, but it was mentioned earlier that this option is going away. Would it be possible to add a DevTools command that is equivalent to --ignore-certificate-errors? The new command could set a global flag, and then all future certificate errors are automatically handled on all windows without raising any event.
Switch --allow-insecure-localhost works as intended, but only for
localhost. Would it be possible to change what's in there for a broader
scope (any host)?

Em 8 de dez de 2017 2:55 PM, "johnc… via monorail" <
monorail+v2.3997543311@chromium.org> escreveu:
I would like to encourage the developers to focus on the primary use-case for this: running tests in some CI environment. I think having a solution that is global (all tabs, always) is perfectly fine, certainly for now. No existing functionality would be broken, and therefore no existing users would be impacted. Just get the primary use-case to work first.
Just my two bits. Thanks.
What I don't understand about this issue is why is this being fixed in ChromeDriver?

In normal chrome this works perfectly without any changes (not even configuration) to ChromeDriver. Why is this so much different in chrome headless? I was under the impression, that chrome headless is just chrome without the UI.
Headless chrome is a separate content embedder, and doesn't support --ignore-certificate-errors. We are inclined not to add support for this flag because we were told that there are plans to remove it from chromium altogether. Instead, both headless and desktop support a DevTools-controlled override that replaces the command line flag. Sadly, that override isn't currently compatible with ChromeDriver.

I think adding a simpler global DevTools-controlled override should be possible. I'll prepare a patch and will see what DevTools owners say.
DevTools patch is out on https://crrev.com/c/817443 for those following along.
Looking forward to being able to see this work.  Eric, it looks like we should be using CertificateErrorOverrideMode=ignore-all if we want to turn the cert errors off?
#83: Correct, a ChromeDriver patch that hooks it up to acceptInsecureCerts is out on https://crrev.com/c/810790.
May i know when this patch is available for everyone? Thanks Prathima
Please tell me, how this will work with puppeteer?
Project Member

Comment 88 by bugdroid1@chromium.org, Dec 20 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/790e30ff7ade211a00e051792d687330f90de789

commit 790e30ff7ade211a00e051792d687330f90de789
Author: Eric Seckler <eseckler@chromium.org>
Date: Wed Dec 20 11:08:26 2017

devtools: Add setIgnoreCertificateErrors, also on browser target.

All known clients use certificate error overrides to ignore all
certificates, so we're planning to replace it with a simpler
"ignore all cert errors" mode instead. This patch deprecates the old
override command in favor of a new setIgnoreCertificateErrors command.

It also exposes the Security domain on the browser target to
facilitate applying this override globally for the whole browser.

Bug:  721739 ,  792468 
Change-Id: I89bd929247877f43abac7c31a420d0756a8fdf89
Reviewed-on: https://chromium-review.googlesource.com/817443
Commit-Queue: Eric Seckler <eseckler@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#525304}
[modify] https://crrev.com/790e30ff7ade211a00e051792d687330f90de789/content/browser/devtools/browser_devtools_agent_host.cc
[modify] https://crrev.com/790e30ff7ade211a00e051792d687330f90de789/content/browser/devtools/devtools_agent_host_impl.cc
[modify] https://crrev.com/790e30ff7ade211a00e051792d687330f90de789/content/browser/devtools/devtools_agent_host_impl.h
[modify] https://crrev.com/790e30ff7ade211a00e051792d687330f90de789/content/browser/devtools/protocol/devtools_protocol_browsertest.cc
[modify] https://crrev.com/790e30ff7ade211a00e051792d687330f90de789/content/browser/devtools/protocol/security_handler.cc
[modify] https://crrev.com/790e30ff7ade211a00e051792d687330f90de789/content/browser/devtools/protocol/security_handler.h
[modify] https://crrev.com/790e30ff7ade211a00e051792d687330f90de789/content/browser/ssl/ssl_manager.cc
[modify] https://crrev.com/790e30ff7ade211a00e051792d687330f90de789/content/public/browser/devtools_agent_host.h
[modify] https://crrev.com/790e30ff7ade211a00e051792d687330f90de789/third_party/WebKit/Source/core/inspector/browser_protocol.json
[modify] https://crrev.com/790e30ff7ade211a00e051792d687330f90de789/third_party/WebKit/Source/core/inspector/browser_protocol.pdl

#89: In that case, please raise a bug with puppeteer. There seems to be one issue referencing ignoreHTTPSErrors: https://github.com/GoogleChrome/puppeteer/issues/1159.
Project Member

Comment 91 by bugdroid1@chromium.org, Dec 20 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/816f01bc8b6a76716b4bd80394d4c4f737211bbc

commit 816f01bc8b6a76716b4bd80394d4c4f737211bbc
Author: Eric Seckler <eseckler@chromium.org>
Date: Wed Dec 20 13:27:57 2017

[ChromeDriver] Add acceptInsecureCerts capability for headless.

Implemented using a new DevTools method to override certificate
error handling browser-wide. This allows ignoring certificate
errors in headless mode, too.

Bug:  721739 
Change-Id: I99d1962147ae638ef83dad5cad6fe1311e7c98b1
Reviewed-on: https://chromium-review.googlesource.com/810790
Commit-Queue: Eric Seckler <eseckler@chromium.org>
Reviewed-by: John Chen <johnchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#525318}
[modify] https://crrev.com/816f01bc8b6a76716b4bd80394d4c4f737211bbc/chrome/test/chromedriver/capabilities.cc
[modify] https://crrev.com/816f01bc8b6a76716b4bd80394d4c4f737211bbc/chrome/test/chromedriver/capabilities.h
[modify] https://crrev.com/816f01bc8b6a76716b4bd80394d4c4f737211bbc/chrome/test/chromedriver/capabilities_unittest.cc
[modify] https://crrev.com/816f01bc8b6a76716b4bd80394d4c4f737211bbc/chrome/test/chromedriver/chrome/chrome.h
[modify] https://crrev.com/816f01bc8b6a76716b4bd80394d4c4f737211bbc/chrome/test/chromedriver/chrome/chrome_impl.cc
[modify] https://crrev.com/816f01bc8b6a76716b4bd80394d4c4f737211bbc/chrome/test/chromedriver/chrome/chrome_impl.h
[modify] https://crrev.com/816f01bc8b6a76716b4bd80394d4c4f737211bbc/chrome/test/chromedriver/chrome/stub_chrome.cc
[modify] https://crrev.com/816f01bc8b6a76716b4bd80394d4c4f737211bbc/chrome/test/chromedriver/chrome/stub_chrome.h
[modify] https://crrev.com/816f01bc8b6a76716b4bd80394d4c4f737211bbc/chrome/test/chromedriver/chrome_launcher.cc
[modify] https://crrev.com/816f01bc8b6a76716b4bd80394d4c4f737211bbc/chrome/test/chromedriver/client/chromedriver.py
[modify] https://crrev.com/816f01bc8b6a76716b4bd80394d4c4f737211bbc/chrome/test/chromedriver/session_commands.cc
[modify] https://crrev.com/816f01bc8b6a76716b4bd80394d4c4f737211bbc/chrome/test/chromedriver/test/run_py_tests.py
[modify] https://crrev.com/816f01bc8b6a76716b4bd80394d4c4f737211bbc/chrome/test/chromedriver/test/webserver.py
[add] https://crrev.com/816f01bc8b6a76716b4bd80394d4c4f737211bbc/chrome/test/data/chromedriver/invalid_ssl_cert.pem

Status: Fixed (was: Started)
The commit in #91 adds support for acceptInsecureCerts [1] to ChromeDriver, starting from Chrome M65.

[1] https://www.w3.org/TR/webdriver/#dfn-accept-insecure-tls-certificates
Labels: ChromeDriver-2.35
Hi ,i am also unable to open intranet site in headless mode .I m using ChromeDriver 2.33 and chrome 62. Selenium 3.4.5.
Could you please let me know from where I can get above fix chromedriver 2.35 ?
Chrome 65, as well as chromedriver 2.35, is not yet released. We need to wait while it will be released. Or as an option, you can build chromium 65 and chromedriver 2.35 from sources
chromedriver 2.35 now released. Reading through the thread it should just be a case of adding a capability option of:

acceptInsecureCerts, true

Unless I am mistaken?
#96: Correct, provided you run against a recent M65 build. If that doesn't work for you, please file another bug against ChromeDriver.
How do you do this in python when using headless mode for chromedriver?
chrome_options = Options()
chrome_options.add_argument('--headless')



acceptInsecureCerts, true is working for Mac Chrome but not working for Windows Chrome. Is this a bug or I am missing some thing.
I can't make acceptInsecureCerts work, this is my configuration configuration: 
const options = new ChromeOptions();
            var str = size.replace("x",",");
            options.addArguments("--headless",
                "--remote-debugging-port=9222",
                "--acceptInsecureCerts=true",
                "--window-size="+str);

Can someone share there config please ? 

Comment 101 Deleted

You need to make sure following:
1) You have latest version of chromedriver - 2.35
2) You need 65+ version of Chrome. E.g. install Canary which is 66 version now. In your tests you need to point to the canary executable.

Here is example of working config:

        ChromeOptions options = new ChromeOptions()
        options.setBinary("C:\\Users\\Administrator\\AppData\\Local\\Google\\Chrome SxS\\Application\\chrome.exe")

        options.addArguments("window-size=1920,1080")
        options.addArguments("headless")
        DesiredCapabilities caps = DesiredCapabilities.chrome()
        caps.setCapability(ChromeOptions.CAPABILITY, options)
        caps.setCapability("acceptInsecureCerts", true)
        WebDriver driver = new ChromeDriver(caps)


Hope this helps,
Roman
Works like a charm!

Thanks Roman, you are my God!

Mike
Does the accept acceptInsecureCerts flag include net::ERR_CERT_AUTHORITY_INVALID errors?
How acceptInsecureCerts call should look like with Python?
I finally made python script work headless with unsecure ssl on Linux 

Google Chrome: google-chrome-unstable-65.0.3325.31-1.x86_64
Web Driver: 2.35.528139
Selenium: 3.8.1
Python: 2.7.13
OS: SUSE Linux Enterprise Server 12 SP2  (x86_64)

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities


options = webdriver.ChromeOptions()
options.binary_location = '/usr/bin/google-chrome-unstable'
options.add_argument('headless')
options.add_argument('--no-sandbox')
options.add_argument('--allow-running-insecure-content')
options.add_argument('--ignore-certificate-errors')


capabilities = DesiredCapabilities.CHROME.copy()
capabilities['acceptSslCerts'] = True
capabilities['acceptInsecureCerts'] = True
driver = webdriver.Chrome(chrome_options=options, desired_capabilities=capabilities)
Unfortunately this is not working for me.

I'm testing with Chrome dev channel (65.0.3325.31)
Without AcceptInsecureCerts, I get a nice certificate invalid error, no problem.

When I set the capability on, I don't see any error, just requests pending indefinitely.

I'm checking by using the remote debugger.

Any idea ? Thanks
Also, just realized, this is only happening when I'm using the proxy-server option. Without it it's working fine !
Still not working with --headless for me, Chrome 66 & chromedriver 2.35.
Only works without it.
I still did not manage to make this work.
I am currently on Chromium 65.0.3298.3 for Ubuntu 16.04, ChromeDriver 2.35.528139.
Trying to make this work in Ruby:

Capybara.register_driver :headless_chromium do |app|
      capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
        acceptInsecureCerts: true,
        chromeOptions: {
          'binary' => '/usr/bin/chromium-browser',
          'args' => ['--headless', '--disable-web-security', '--incognito',
                     '--no-sandbox', '--disable-gpu', '--window-size=1920,1080']
        })
      Capybara::Selenium::Driver.new(
        app,
        browser: :chrome,
        desired_capabilities: capabilities
      )
    end

Anyone? Any ideas what I am doing wrong?
Move acceptInsecureCerts: true into the chromeOptions object.
Thank you for the reply.
If I try something like this I get and error like: "from unknown error: unrecognized chrome option: acceptInsecureCerts" :(
If I put it as argument. it will still not bypass SSL certs error.
Maybe I am not writing it well?
Nope, getting the same thing.
Are you sure that

/usr/bin/chromium-browser -version

is 65.0.3298.3?

https://launchpad.net/ubuntu/xenial/+source/chromium-browser is version 64.0.3282.167-0ubuntu0.16.04.1

Comment 115 Deleted

Yes, doing /usr/bin/chromium-browser -version, echoes Chromium 65.0.3298.3 Ubuntu 16.04
Also, I used these commands on installing the Beta version: https://itsfoss.com/install-chromium-dev-beta-ubuntu-1310/
Hi,

Managed to resolve this.
As it turned out I had 2 versions on Chromium Browser installed 64 and 65.
I completely removed chromium-browser from Ubuntu, and then only installed 65 (after that 66), and it works great.
"acceptInsecureCerts: true" works perfectly.

Thank you for the help getting me unblocked !

Here is my setup if someone else works with Ruby + Capybara testing and has the same problem:

Capybara.register_driver :headless_chromium do |app|
      capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
        acceptInsecureCerts: true,
        binary: '/usr/bin/chromium-browser',
        chromeOptions: {
          'args' => ['--headless', '--disable-web-security', '--incognito',
                     '--no-sandbox', '--disable-gpu', '--window-size=1920,1080']
        })
      Capybara::Selenium::Driver.new(
        app,
        browser: :chrome,
        desired_capabilities: capabilities
      )
    end

Comment 118 Deleted

Comment 119 Deleted

now we can use mitmproxy and chrome headless
-------------------------
from selenium import webdriver
from pyvirtualdisplay import Display
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

#_____________________基本设定___________________________
CHROME_DRIVER_PATH = r'/usr/bin/chromedriver' 
PROXY = "http://127.0.0.1:8080"
#_____________________启动参数___________________________
options = webdriver.ChromeOptions()
options.add_argument('--headless')  
options.add_argument('--disable-gpu')  
options.add_argument("window-size=1024,768")  
options.add_argument("--no-sandbox")

#_____________________代理参数___________________________
desired_capabilities = options.to_capabilities()
desired_capabilities['acceptSslCerts'] = True
desired_capabilities['acceptInsecureCerts'] = True
desired_capabilities['proxy'] = {
    "httpProxy": PROXY,
    "ftpProxy": PROXY,
    "sslProxy": PROXY,
    "noProxy": None,
    "proxyType": "MANUAL",
    "class": "org.openqa.selenium.Proxy",
    "autodetect": False,
}
#_____________________启动浏览器___________________________
driver = webdriver.Chrome(
    chrome_options=options, 
    executable_path=CHROME_DRIVER_PATH,
    desired_capabilities = desired_capabilities,
                         )

for i in range(1):
    driver.get('https://www.iplocation.net')
    contant = driver.page_source
    driver.save_screenshot('hello.png')
    print(contant)
    driver.close()
    driver.quit()

mitmdump -p 8080
#120 worked for me.

The options and desired_capabilities worked. I left out the proxy arg for desired_capabilities.

Comment 122 by anji.i...@gmail.com, Sep 17 (4 days ago)

Hi
   Any Idea does this fix is available in chromium browser package 65.0.3325.181 of ubuntu 14.04 (trusty)?? For me It doesn't work for chromium browser opened in headless mode with chrome driver 37 setting acceptInsecureCerts. 
Your quick help is much appreciated.

Thanks.
Showing comments 23 - 122 of 122 Older

Sign in to add a comment