The following code disables stylesheets and images on a page loaded with Selenium Firefox webdriver:
from selenium import webdriver
firefox_profile = webdriver.FirefoxProfile()
firefox_profile.set_preference('permissions.default.stylesheet', 2)
firefox_profile.set_preference('permissions.default.image', 2)
driver = webdriver.Firefox(firefox_profile)
driver.get('http://www.stackoverflow.com/')
driver.close()
It works fine with stackoverflow.com, facebook.com, yahoo.com... but interestingly doesn't with Google Search; only the Google logo disappears and its stylesheet remains in place.
If you try with the following link http://google.com/search?q=nelson+mandela
, you will get:
Whereas the expected result should look like this (no stylesheet + no picture):
- What is going on?
- How do I fix it?