【发布时间】:2015-07-08 11:58:39
【问题描述】:
我正在使用 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$accessor$6vHNXtoG(Unknown Source)
at com.ui4j.webkit.browser.WebKitPage$ByteBuddy$sjifLXwz$auxiliary$0UdQY8PH.call(Unknown Source)
at com.ui4j.webkit.proxy.WebKitProxy$CallableExecutor.run(WebKitProxy.java:46)
at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
at com.sun.javafx.application.PlatformImpl$$Lambda$51/1744951114.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:294)
at com.sun.javafx.application.PlatformImpl$$Lambda$50/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 );
我是否遗漏了什么,或者是否有针对 ui4j 下的“window.scrollTo”的解决方法以避免 NullPointerException?
【问题讨论】:
-
一点也不。我没有问 NullPointerException 是什么!我的问题是关于上述具体情况(在 ui4j 中调用 'window.scrollTo' 导致 'ScrollBarThemeImpl.getThumb' 中出现 NPE)。
标签: javascript java javafx webkit ui4j