2

I am testing a website using selenium web driver. The particular site contains nested iframes. I cannot access content of Iframes, because of the Same Origin Policy. Therefore I disabled web security in chrome web driver and access those contents using following Jquery script.

$(‘#data’).find(‘iframe’).contents().find(‘html’) 

I achieved this in chrome by setting these features when it is initializing.

ChromeOptions options = new ChromeOptions();
options.AddArguments("--allow-file-access-from-files");
options.AddArguments("--disable-web-security");
IWebDriver driver = new ChromeDriver(options);

(Domain of iframes are differ with my hosted domain.)

Now I need to do this in Firefox. I followed instructions in this URL. But that is not working.

about:config -> security.fileuri.strict_origin_policy -> false

Then I tried with these edits

about:config -> security.mixed_content.block_active_content -> false

about:config -> security.mixed_content.block_display_content -> false

Then I loaded Firefox profile and init web driver using that.

FirefoxProfile profile = new FirefoxProfile(@"C:\Users\admin\AppData\Roaming\Mozilla\Firefox\Profiles\0nan0gbv.default");

IWebDriver driver = new OpenQA.Selenium.Firefox.FirefoxDriver(profile);

I haven't got what I expected using above edits. Error was Permission denied to access property 'document'

Then I tried set these settings into new Firefox profile(not use default one in my machine) and load it.

OpenQA.Selenium.Firefox.FirefoxProfile profile = new FirefoxProfile();
profile.SetPreference("browser.privatebrowsing.autostart", true);
profile.SetPreference("security.fileuri.strict_origin_policy", false);
profile.SetPreference("security.mixed_content.block_active_content", false);
profile.SetPreference("security.mixed_content.block_display_content", true);

IWebDriver driver = new OpenQA.Selenium.Firefox.FirefoxDriver(profile);

Then I got this error and couldn't able to find proper solution.

Preference security.fileuri.strict_origin_policy may not be overridden: frozen value=False, requested value=False

I found this question has many ways to overcome SOP. But those are not answers for my problem.

There should be way to achieve this. I am using Firefox 29.0.1

Community
  • 1
  • 1
cdev
  • 5,043
  • 2
  • 33
  • 32
  • Possible duplicate of [Disable firefox same origin policy](http://stackoverflow.com/questions/17088609/disable-firefox-same-origin-policy) – Paul Sweatte Mar 10 '17 at 23:54

0 Answers0