以下未能导航第二次,为什么?
UI4J中是否存在错误或我的代码/系统中存在错误?在Ubuntu 15.10上。使用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()
}
}
答案 0 :(得分:0)
好的,所以在研究完之后,似乎需要打电话:
Platform.setImplicitExit(假);
防止此问题发生。