I’m trying to set up automated browser testing in JMeter without displaying the actual browser window. When I use the HtmlUnit driver configuration, I keep running into JavaScript errors. The main error I see is about missing JavaScript functions like getComputedStyle.
I found out that HtmlUnit might not handle JavaScript properly. I’m wondering if there’s a way to make this work in JMeter, or if I should try a different approach for browser automation testing. My setup is running on a Linux server.
I also tried using PhantomJS with a webdriver sampler. Here’s what my test looks like:
But when I run this test, nothing appears in my test results. Do I need to add extra configuration elements to make this work? What’s the best way to get browser automation working properly in JMeter on Linux?
PhantomJS got deprecated in 2018, so that’s why you’re seeing inconsistent results. Your WebDriver sampler code looks fine, but you need to add assertions or response extractors to actually capture data in JMeter’s results tree. Without them, JMeter just runs the commands silently.
For headless testing on Linux, I’d switch to Firefox with --headless instead of Chrome. Firefox headless is way more stable in server environments and doesn’t need as many system dependencies. Just configure your WebDriver sampler to use GeckoDriver, set the headless preference in Firefox options, and throw in a simple assertion like checking the page title or specific text. This setup has worked reliably for me across different Linux distros without the JavaScript compatibility issues you’re getting with HtmlUnit.
I’ve hit the same wall with HtmlUnit on JavaScript-heavy sites. Its JS engine just can’t keep up with real browsers, so those missing functions are totally normal. For PhantomJS, you’re probably not seeing results because you need assertions to actually capture the data. JMeter won’t show anything useful without them, even if the browser stuff works fine. I’d ditch both and go with Chrome headless using WebDriver Sampler. Set up ChromeOptions with the headless flag, and make sure you’ve got Chrome and ChromeDriver installed on your Linux box. Way better JS support than HtmlUnit and still runs without a GUI.
totally agree, PhantomJS is like old news. try using Chrome in headless mode with that --headless flag. it works way better for js and u’ll def get better results in JMeter. trust me on this!