How to handle Mixed Content blocker in Firefox via WebDriver

How to handle Mixed Content blocker in Firefox via WebDriver

In new version of Firefox, recently I encountered mixed content blocker where page given in specific frame was not loading. I noticed on the top of the screen in latest Firefox there is an icon on the top of the screen


1

What is Mixed Content?

You can find very detailed explanation on Mozilla support page but just for quick explanation if you don’t want to read there:

“HTTP is not encrypted but HTTPS and if you have a http content into HTTPS page then there are chances that your content can be hacked and its known as Mixed content”

How to Handle manually

To handle that you need to click on dropdown next to Keep Blocking and select option “Disable Protection on This Page”.

2

After disabling, your content will display but with orange warning  triangle as below.

3

To learn more about this refer:

https://support.mozilla.org/en-US/kb/how-does-content-isnt-secure-affect-my-safety?as=u&utm_source=inproduct

How to handle using WebDriver

To handle this, you need to change the preference setting before starting the Firefox driver. To access preference type about:config in address bar, accept the agreement and type “mixed_content” in search field, you will see the following.

4

security.mixed_content.block_active_content  : false

security.mixed_content.block_display_content : true

This is causing content not to display. Before launching Firefox driver, you need to change these preferences to allow content to display as below.

Code

5

Now if you open website with mixed content, it will load without any issue.

Warning: Just make sure with your development team if it’s valid for application to load.

5 Comments

    1. Aditya

      Kannan,
      Try this:

      Start your driver like this:

      driver = Selenium::WebDriver.for :ie, :switches => %w[–ignore-certificate-errors –disable-popup-blocking –disable-translate]

      Open your browser as an Admin, and change settings in Internet Options to allow popups and also keep “Protected Mode”disabled.

Leave a Reply