Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Error with Permissions-Policy header", when using Chromedriver to a Headless Browser

Tags:

selenium

On Selenium, I am using chromedriver version 89 and my chrome browser version 89.0. too. When I run my code on a headless browser, I got an error; turn chrome to a headless browser to test the result. Here is my script-

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from shutil import which 

chrome_options = Options()
chrome_options.add_argument("--headless")

chrome_path = which("chromedriver")

driver = webdriver.Chrome(executable_path=chrome_path, options=chrome_options)
driver.get("https://duckduckgo.com/")

search_input = driver.find_element_by_id("search_form_input_homepage")
search_input.send_keys("My User Agent")

search_input.send_keys(Keys.ENTER)

And here is the VSCODE Terminal Output,

DevTools listening on ws://127.0.0.1:57195/devtools/browser/7464cfb0-5b3c-497d-a768-6eae3bb5b59b
[0408/112137.788:INFO:CONSOLE(0)] "Error with Permissions-Policy header: Unrecognized feature: 'interest-cohort'.", source:  (0)
[0408/112138.552:INFO:CONSOLE(0)] "Error with Permissions-Policy header: Unrecognized feature: 'interest-cohort'.", source:  (0)
[0408/112139.176:INFO:CONSOLE(0)] "Error with Permissions-Policy header: Unrecognized feature: 'interest-cohort'.", source:  (0)
[0408/112139.483:INFO:CONSOLE(0)] "Error with Permissions-Policy header: Unrecognized feature: 'interest-cohort'.", source:  (0)

VSCode Terminal Output

like image 513
AamenIs Avatar asked Dec 17 '22 11:12

AamenIs


2 Answers

This is the new header used to block Google's new tracking technology called Federated Cohorts of Learning (FLoC).

About FLoC

The header is being used by DDG to block FLoC tracking.

DuckDuckGo Announces Plans to Block Google’s FLoC

You get the same warning in Chrome dev tools if you access any website that blocks FLoC.

To block Google's FLoC on your own website, add the following header:

permissions-policy: interest-cohort=()
like image 58
Jed White Avatar answered Jun 17 '23 21:06

Jed White


If you just want to remove those warning messages then add

chrome_options.add_argument('--log-level=1')

More info here List of Chromium Command Line Switches

log-level: Sets the minimum log level.
Valid values are from 0 to 3: 

    INFO = 0 (default)
    WARNING = 1
    LOG_ERROR = 2
    LOG_FATAL = 3
like image 43
sound wave Avatar answered Jun 17 '23 19:06

sound wave