1

I need to disable CSP for that I can do that manually by opening Firefox() web driver, going to about:config, and disabling: security.CSP.enable.

I am new to selenium, have coded all the stuff I need to just I need to automate disabling of CSP, I don't know much about marionette, capabilities, and other details. I just want to automate the disabling of CSP. Is it possible? Is it possible by doing some capabilities changes or by doing: driver.get('about:config'); some code or by adding another extension? There may be other solutions like downloading geckodriver with no CSP, which I cant find, or maybe even compiling geckodriver with no CSP if its open source.

I cant use chromium for some reason, so I need to work with geckodriver in Linux.

Machinexa
  • 626
  • 1
  • 8
  • 17

2 Answers2

1

This is the ugliest way, building from source code. Steps:

  • Download source of Firefox: Firefox Source. Then, unzip it.
  • cd/Mozilla-central-83bf4fd3b1fb/testing/geckodriver/src/ and edit prefs.rs with your favourite editor. At end write this:
// Disable CSP
("security.csp.enable", Pref::new(false)),
  • Build geckodriver using cargo or mach. I used cargo build

  • Load it using:

webdriver.Firefox(executable_path='./mozilla-central-83bf4fd3b1fb/testing/geckodriver/target/debug/geckodriver')

Finding docs and going through the source code and editing was quite painful as I don't know Rust. Here's the docs: Building Docs

Machinexa
  • 626
  • 1
  • 8
  • 17
0

a small addition, in order to compile the source code on my pc (windows 10), without any other prerequisites prepared, i was required to install rust and c++ build tools (c++ tools for rust)

dorinjj
  • 23
  • 4
  • 1
    This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/30346918) – Bracken Nov 16 '21 at 16:28