I'm aware this question has been asked before, the issue is that none of the solutions do the job quite the same as the Developer tools extension which is what I'm in need of. This is achieved by going into the WebDeveloper extension menu and clicking 'Disable all styling' in the css section.
I need the page to look like this for some automation.
Needed Format (No CSS styling at all)
The first solution is
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
def disableImages(self):
## get the Firefox profile object
firefoxProfile = FirefoxProfile()
## Disable CSS
firefoxProfile.set_preference('permissions.default.stylesheet', 2)
## Disable images
firefoxProfile.set_preference('permissions.default.image', 2)
## Disable Flash
firefoxProfile.set_preference('dom.ipc.plugins.enabled.libflashplayer.so',
'false')
## Set the modified profile while creating the browser object
self.browserHandle = webdriver.Firefox(firefoxProfile)
However, this only removes some images and not everything as you can see below.
Then I found a script
var queries = ['link[rel=stylesheet][href]', 'style'];
for (var i = 0; i < queries.length; i++) {
var remove = document.querySelectorAll(queries[i]);
for (var j = 0; j < remove.length; j++) {
remove[j].outerHTML = '';
}
}
var inline = document.querySelectorAll('*[style]');
for (var i = 0; i < inline.length; i++) {
inline[i].removeAttribute('style');
}
The full explanation of how it worked is on this answer Disable styling on Google Search with Selenium FirefoxDriver which still did not turn out the same.
Any help would be greatly appreciated? Thanks in advance.