Selenium: How to disable image loading with firefox and python? -


i have read similar questions, 1 supposed answer, when tried it gave partial solution.

i refer question: disable images in selenium python

my problem tried solution , of images not appear images arrive from:

<img href="www.xxx.png">  

are being loaded. there way tell firefox/selenium not it? if not, there way discard dom element back, via

self._browser.get(url) content=self._browser.page_source 

for example doing kind of find replace on dom tree?

the browser configuration same browser previous question:

    firefox_profile = webdriver.firefoxprofile()     # disable css     firefox_profile.set_preference('permissions.default.stylesheet', 2)     # disable images     firefox_profile.set_preference('permissions.default.image', 2)     # disable flash     firefox_profile.set_preference('dom.ipc.plugins.enabled.libflashplayer.so', 'false')     # set modified profile while creating browser object     self._browser = webdriver.firefox(firefox_profile=firefox_profile) 

-------------------------------------correction-------------------------------------

kept on digging , learned that,
if inspect text document selenium/firefox combo did see that, didn't bring images, , kept links.

but when did:

self._browser.save_screenshot("info.png")  

i got 24 mega file img links loaded.
can explain me matter?
thanks

you can disable images using following code:

firefox_profile = webdriver.firefoxprofile() firefox_profile.set_preference('permissions.default.image', 2) firefox_profile.set_preference('dom.ipc.plugins.enabled.libflashplayer.so', 'false')  driver = webdriver.firefox(firefox_profile=firefox_profile) 

if need block specific url... hm... think need add string:

127.0.0.1 www.somespecificurl.com  

to hosts file before test start , delete after test finish.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -