Using Selenium Webdriver, we can manipulate and use a web browser programmatically. This is widely used in website testing as once a programmed script is written to run on a website, we can sit back and relax while the script is testing the desired outcomes of the website. Also there are many other use cases.

Now the thing about the driver is that it uses a real web browser to run the scripts. So once a web page is accessed, the browser will perform its normal functionality loading everything in the web page. This can slow down the script. However for your use case you might not need to wait till images are rendered or CSS files being loaded etc.

So I wanted to disable the images, CSS for my use case when I’m running the script on Firefox. So if you are ok with not having load the images, CSS and disable other stuff, you can manipulate Firefox profiler in the test window to achieve that. I think other browser can do similar like this to archive the same thing.  The code segment below works for Firefox.

That’s it. Now images, CSS and other stuff will not be loaded.

Conclusion

If disabling images, and other stuff break your website you will not get any value from this approach however for certain cases this might come handy. And it’s a great option to have if you want to speed up the execution of the scripts.