Note: Advice in this article will only work for JxBrowser 6. See the corresponding article for JxBrowser 7 here.

JxBrowser DOM API provides functionality that allows you to simulate click on any HTML element on the loaded web page. To simulate click you need to make sure that web page is loaded completely and find the required HTML element in document: 

DOMDocument document = browser.getDocument();
DOMElement link = document.findElement(By.tagName("button"));

Once you get the reference to the required HTML element, you can simulate click using the method.;

Please note that this method works asynchronously. When this method returns, it doesn't mean that click simulation is finished.

This functionality can be useful in automated testing when you need to simulate user actions including mouse clicks on specified HTML elements.

import com.teamdev.jxbrowser.chromium.Browser;<span class="fr-marker" data-id="0" data-type="false" style="display: none; line-height: 0;"></span><span class="fr-marker" data-id="0" data-type="true" style="display: none; line-height: 0;"></span>
import com.teamdev.jxbrowser.chromium.dom.By;
import com.teamdev.jxbrowser.chromium.dom.DOMDocument;
import com.teamdev.jxbrowser.chromium.dom.DOMElement;
import com.teamdev.jxbrowser.chromium.swing.BrowserView;

import javax.swing.*;
import java.awt.*;

 * This sample demonstrates how to simulate click on a specific HTML element.
public class DOMSimulateClickSample {
    public static void main(String[] args) {
        Browser browser = new Browser();
        BrowserView browserView = new BrowserView(browser);

        JFrame frame = new JFrame();
        frame.add(browserView, BorderLayout.CENTER);
        frame.setSize(800, 600);

        browser.addLoadListener(new LoadAdapter() {
            public void onFinishLoadingFrame(FinishLoadingEvent event) {
                if (event.isMainFrame()) {
                    Browser browser = event.getBrowser();
                    DOMDocument document = browser.getDocument();
                    DOMElement link = document.findElement(By.tagName("button"));
                    if (link != null) {
        browser.loadHTML("<html><body><button id='button' " +
                "onclick=\"alert('Button has been clicked!');\">Click Me!</button>" +