Documentation‎ > ‎

Frequently Asked Questions

If you have a question about JExplorer and it is not listed in this FAQ, please send it to us using the support forum and we will add it here after answering to you.

Can I embed Internet Explorer into a Swing container? Can I use Internet Explorer without displaying any windows?

Yes, JExplorer provides both these capabilities. There are two classes: Browser (a Swing component) and HeadlessBrowser (a class for automated testing without GUI).

How to get source of the HTML document?

Load a page using HeadlessBrowser instance and get the HTML document source by calling the WebBrowser.getContent() method:
WebBrowser browser = new HeadlessBrowser();
// Wait until page is loaded completely browser.waitReady(); String content = browser.getContent();
System.out.println("Source of page: ");
Attached files:

How to embed Internet Explorer into a Swing container?

Create a Browser component, add it into a Swing container:
Browser browser = new Browser();

JFrame frame = new JFrame("JExplorer - Create Browser Sample");
frame.setSize(800, 600);
frame.getContentPane().add(browser, BorderLayout.CENTER);

// Wait when the browser will be ready to work browser.waitReady(); browser.navigate("")

Attached files:

How to get an element in the HTML document as a Java object?

The WebBrowser.getDocument() method returns org.w3c.dom.Document object that can be used for finding elements in a document. The code below searches for the submit button by name:

public void execute(){
Element searchButton = getSearchButton(browser.getDocument());
private static Element
org.w3c.dom.NodeListinputs = document.getElementsByTagName("input");
for(int i = 0;i < inputs.getLength();i++){
org.w3c.dom.Elementinput = (org.w3c.dom.Element)inputs.item(i);
Stringname = input.getAttribute("name");
return input;
return null;

Attached files:,

How to get/set attributes of an element?

Find the element in the document and then call the org.w3c.dom.Document.getAttribute() or setAttribute() methods:
Element login = browser.getDocument().getElementById("i1");
// Get an element attribute String type = login.getAttribute("type");
// Set an element attribute login.setAttribute("value","john");

How to navigate to a link in the HTML document?

Find the link in the page and call the method:

Element groupsLink = browser.getDocument().getElementById("2a");
if(groupsLink != null){
DomRobot robot = newDomRobot(browser);
showMessage("Navigate Groups link");;

Attached files:

How to fill the form controls in an HTML document with specified values?

Find a control in a document, then set the "value" attribute for a text field, "checked" attribute for a checkbox, "selected" attribute for a radio button:
// Find a text field in the page Element textInput = getTextInput(browser.getDocument()); textInput.setAttribute("value","JExplorer");

Attached files:

How to submit a form to the server?

Find a submit button of the form and click the button using the method:

Element searchButton = getSearchButton(browser.getDocument());
DomRobot robot = newDomRobot(browser);;

Attached files:

How to execute JavaScript code?

Use the Browser.executeScript(String) method:
// Get JavaScript counter variable
String counter = (String)browser.executeScript("counter");
// Set JavaScript counter variable browser.executeScript("counter = 7;");
Attached files:

How to listen to events from the document elements in Java code?

Add an event listener to an element:
private void setupChangeListener(final org.w3c.dom.Element select){ eventTarget = (;
eventTarget.addEventListener("onchange",new EventListener(){
public void handleEvent(Eventevt){
            Element target = (Element)evt.getTarget();
            // Gets current value of selected target             String value = target.getAttribute("value");
showMessageSwingLoop("Selected product: "+value);

Is there any easy way to find the absolute screen position for a org.w3c.dom.html.HTMLElement ?

To obtain the absolute screen position of any org.w3c.dom.html.HTMLElement, you will need to cast an instance of such element to the HTMLElement interface from package and then use its getAbsoluteLocation() method. For example:
HTMLElement htmlElement = (HTMLElement)element;
Point point = htmlElement.getAbsoluteLocation();

Which methods should I use instead of deprecated methods of the DomRobot class?

The HTMLElement interface contains element-specific methods and HTMLDocument interface contains document-specific methods. The WebBrowser.setSilent(boolean) method enables/disables the error, alert, and confirmation dialogs.

Are there any guiding principles to avoid deadlocks in the application that uses JExplorer?

Don't call the WebBrowser.waitReady() method from Swing or OLE message loop thread.

If I work with JExplorer through COM interfaces (native peer objects), I get ComException: COM object method returns error code: 0x80004005; E_FAIL. What's wrong?

You should work with peer objects in the OLE message loop of the browser. See the chapter " Working with Native Peers and Avoiding Thread Issues" inside JExplorer Programmer's Guide. Otherwise, please refer to the corresponding interface's documentation in MSDN to get know method specific meaning of the error code.

When the browser component is visible all of my menus and tooltips seem to show under the browser panel. Can this be fixed?

To solve this problem, just add the following code to appropriate place in your application:


I get the following error: ciceroUIWNDFRAME: javaw.exe - apllication error[new]

This error is not caused by JNIWrapper, but rather by Microsoft Office's Speech and Handwriting Recognition. In order to continue using JNIWrapper, you will need to disable this Microsoft feature. To disable the Speech and Handwriting Recognition:
  • Click "Start" button at the bottom left of Microsoft Windows.
  • Click "Control Panel."
  • Click "Add/Remove Programs."
  • Click "Microsoft Office."
  • Click on the "Change" button
  • Browse to "Office Shared Features."
  • Click on "Alternative User Input."
  • For both the Speech and Handwriting Recognition, select "Not available."
Once this is disabled, the CiceroUIWndFrame messages disappear. Also, please check this Microsoft support site for a more detailed set of steps to remove these tools:;%5BLN%5D;326526.
Unknown user,
May 3, 2012, 3:02 AM
Unknown user,
May 3, 2012, 3:00 AM
Unknown user,
May 3, 2012, 3:07 AM
Unknown user,
May 3, 2012, 3:07 AM
Unknown user,
May 3, 2012, 3:07 AM
Unknown user,
May 3, 2012, 3:07 AM
Unknown user,
May 3, 2012, 3:07 AM