Python Selenium disable CSS with PhantomJS webdriver -


there seems confusion on whether it's possible disable css when using phantomjs webdriver selenium. appears possible when using firefox adapting firefox profile, i'm hoping use phantomjs since faster firefox.

is possible disable css in instance? if so, provide idea of how implement it?

phantomjs doesn't seem have option disable css. can work around limitation removing css yourself:

driver.execute_script("""     var toremove = [];     toremove.push.apply(toremove, document.queryselectorall('link[type*=\"/css\"]'));     toremove.push.apply(toremove, document.queryselectorall('style'));     toremove.foreach(function(s){         s.parentnode.removechild(s);     });     [].foreach.call(document.queryselectorall('[style]'), function(e){         e.removeattribute('style');     }); """) 

this removes linked, local , inline styles , leaves default browser style alone. might want add kind of reset stylesheet.


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -