I've spent the last few days messing around with Selenium, Tor, and Firefox as a combination for multiple tasks. I've managed to write a simple script in Python that takes control of Firefox through Selenium, while Firefox is connected to Tor for privacy.
Now, I'm looking for a way to save resources, so I thought of running Firefox in headless mode, which I thought was a common feature but it doesn't seem to be that. I'm looking for a method to do just that. The reason for it being Firefox and not some terminal based browser is because of the extension "TorButton" that I'm using within Firefox. It has javascript injections built in to it that help with privacy.
If anyone has done this before (which I'm sure many have!), some tips would be greatly appreciated, thank you!
Starting with Firefox 55, Firefox can run in a headless mode. To use headless mode, pass the headless argument when creating a new Browser instance.
Headless Execution Firefox Driver It is quite simple to run your tests in the headless mode. You need simply to add the "--headless" argument to the FirefoxOptions object.
Headless Chrome is just a regular Chrome but without User Interface(UI). We need Chrome to be headless because UI entails CPU and RAM overheads. For this, we will use ChromeDriver, Which is a web server that provides us with a way to interact with Headless Chrome.
Headless Browsers are Faster than Real Browsers But you will typically see a 2x to 15x faster performance when using a headless browser. So if performance is critical for you, headless browsers may be a way to go.
xvfb is a common way of doing this. Searching for "selenium xvfb" should find lots, such as:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With