调用 javascript window.scrollTo 时出现 ui4j NullPointerException

ui4j NullPointerException when calling javascript window.scrollTo

我正在使用 ui4j 测试一个网站。当我执行

page.executeScript("window.scrollTo(0,document.body.scrollHeight)");

滚动到页面末尾时出现以下 NullPointerException:

Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
    at com.sun.javafx.webkit.theme.ScrollBarThemeImpl.getThumb(ScrollBarThemeImpl.java:400)
    at com.sun.javafx.webkit.theme.ScrollBarThemeImpl.thumbPosition(ScrollBarThemeImpl.java:284)
    at com.sun.javafx.webkit.theme.ScrollBarThemeImpl.getThumbPosition(ScrollBarThemeImpl.java:380)
    at com.sun.webkit.WebPage.twkExecuteScript(Native Method)
    at com.sun.webkit.WebPage.executeScript(WebPage.java:1427)
    at javafx.scene.web.WebEngine.executeScript(WebEngine.java:948)
    at com.ui4j.webkit.spi.WebKitJavaScriptEngine.executeScript(WebKitJavaScriptEngine.java:26)
    at com.ui4j.webkit.browser.WebKitPage.executeScript(WebKitPage.java:231)
    at com.ui4j.webkit.browser.WebKitPage$ByteBuddy$sjifLXwz.executeScript$accessorvHNXtoG(Unknown Source)
    at com.ui4j.webkit.browser.WebKitPage$ByteBuddy$sjifLXwz$auxiliary[=13=]UdQY8PH.call(Unknown Source)
    at com.ui4j.webkit.proxy.WebKitProxy$CallableExecutor.run(WebKitProxy.java:46)
    at com.sun.javafx.application.PlatformImpl.lambda$null0(PlatformImpl.java:295)
    at com.sun.javafx.application.PlatformImpl$$Lambda/1744951114.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater1(PlatformImpl.java:294)
    at com.sun.javafx.application.PlatformImpl$$Lambda/929850074.run(Unknown Source)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) 

我在 mac 上用 ui4j 2.0 和 1.2.0 试过了。 JDK 版本 1.8.0_45 .

是否缺少 ui4j 上的某些配置才能执行 'window.scrollTo'?

我按以下方式加载网页:

BrowserEngine engine = BrowserFactory.getWebKit();
Page page = engine.navigate( url );

我是不是遗漏了什么或者是否有 'window.scrollTo' 在 ui4j 下避免 NullPointerException 的解决方法?

page.executeScript() 调用之前 page.show()

import static com.ui4j.api.browser.BrowserFactory.getWebKit;

import com.ui4j.api.browser.Page;

public class Sample {

    public static void main(String[] args) {
        Page page = getWebKit().navigate("http://whosebug.com");
        page.show();
        page.executeScript("window.scrollTo(0,document.body.scrollHeight)");
    }
}