mjs
mjs

Reputation: 22379

UI4J - navigate show hide error bug ? Full sample code included.

This below fails to navigate the second time, why?

Is there a bug in UI4J or something in my code/system? On Ubuntu 15.10. Using Java 8u40.

package mypackage.Web.tests.main;

import com.ui4j.api.browser.BrowserEngine;
import com.ui4j.api.browser.BrowserFactory;
import com.ui4j.api.browser.Page;

public class UI4JNavigateShowHideErrorDemo {

    public static void main(String[] args) throws InterruptedException {
        BrowserEngine engine = BrowserFactory.getWebKit();

        navigateShowAndClose(engine);

        navigateShowAndClose(engine);

        System.out.println("Never reaches this stage because on the second navigate it gets stuck.");
    }

    public static void navigateShowAndClose(BrowserEngine engine) throws InterruptedException {
        System.out.println("Navigating");

        Page page = engine.navigate("http://www.google.com/");

        System.out.println("Showing");

        page.show();

        System.out.println("Sleeping");

        Thread.sleep(500);

        System.out.println("Closing");

        page.close();   // Same with page.hide()
    }       
}

Upvotes: 0

Views: 140

Answers (1)

mjs
mjs

Reputation: 22379

Ok, so after researching this it appears that one needs to call:

Platform.setImplicitExit(false);

to prevent this issue from occuring.

Upvotes: 0

Related Questions