I’m working with test scripts created using the Selenium IDE Firefox extension and need to execute them in a headless environment. The IDE generates test files in HTML format when I build my test suites.
I want to set up automated testing that runs without any visible browser window, preferably using PhantomJS or similar headless solutions. I’ve seen suggestions about running Firefox in hidden mode, but that’s not truly headless like what PhantomJS offers.
I can already execute my tests from the command line with regular browsers like this:
However, I can’t figure out how to make the HTML test files work with PhantomJS or other headless drivers. The IDE can export tests in various programming languages, but I need my non-technical colleagues to keep using the Firefox plugin for creating tests. Is there a way to bridge this gap between IDE-generated HTML tests and headless execution?
The HTML test format from Selenium IDE doesn’t play nice with modern headless solutions. I got around this by using selenium-side-runner - it’s the official command-line tool for running Selenium IDE tests. Just install it through npm and it runs headless out of the box.
Skip the old selenium-server-standalone approach and try this:
Your colleagues can keep using the Firefox IDE plugin, but you’ll need to save tests as .side files instead of HTML. The side-runner handles WebDriver integration automatically and works with both Chrome and Firefox in headless mode. Way more reliable than trying to convert HTML suites manually, and barely changes how you create tests.
I’ve encountered a similar situation where our QA team wanted to retain the use of the Selenium IDE while transitioning to headless executions. The core issue is that HTML test suites generated by Selenium IDE aren’t compatible with headless drivers like PhantomJS. In our case, we implemented a two-step conversion: first, we exported the tests from HTML to a WebDriver-supported format, either in Python or Java, using the export functionality in the IDE. We switched from PhantomJS to using headless Chrome or Firefox, as PhantomJS is no longer maintained. To achieve headless operation in Chrome, we simply added the --headless flag to the WebDriver initialization. This approach allows for true headless execution while preserving the original test logic crafted by your colleagues. Although the automated conversion may require some manual adjustments, it helps maintain the structure of the tests. Another viable strategy could involve using a Selenium Grid with headless browsers, enabling you to continue utilizing the HTML format while still achieving the benefits of headless execution for continuous integration.
phantomjs is dead - don’t waste your time with it. use xvfb instead if ur on linux. it creates a virtual display so firefox runs headless but still thinks it has a gui. try this: xvfb-run -a java -jar selenium-server-standalone-2.39.0.jar -htmlSuite "*firefox" "http://localhost:8080" "test-suite/MainTestSuite.html" "output-results.html" - should work with ur html files.