HtmlUnit API Issue in Java Headless Browser?

Using HtmlUnit in Java to change a dropdown and click a button, yet the CAPTCHA never appears as in a normal browser. Why?

HtmlPage pg = new BrowserX().act();

it could be that htmlunit isnt firing all js events. try making sure js is fully enabled and add a little delay after the dropdown change. this sometimes helps captcha load as expected

HtmlUnit can sometimes fall short when it comes to replicating the behavior of full browsers, particularly with dynamic elements like CAPTCHAs. In my experience, the JavaScript execution and event handling in HtmlUnit do not perfectly mimic real user interactions, often resulting in some elements not being activated as expected. I encountered similar issues and found that considering alternative approaches such as using Selenium WebDriver in headless mode helped overcome these limitations by offering a more accurate simulation of a user’s browser.