ui4j 无法使用 java 找到元素
ui4j can not find element using java
我正在尝试使用 ui4j 为站点创建自动化程序,但我停了下来。过去曾使用过 UI4J 并且工作得很好,但现在它找不到我需要它单击以移动到另一个页面的项目。
来自 website 的代码是这样的
<div>
<a id="T:df6yt:0:jfcx6" class="x1sq xfd" href="#" onclick="return false;" title="Αναζήτηση"></a>
</div>
我在我的 java 程序中使用它
BrowserEngine webkit = BrowserFactory.getWebKit();
Page page = webkit.navigate("http://www.eprocurement.gov.gr");
page.show();
Document document = page.getDocument();
Thread.sleep(30000);
document.query("T:df6yt:0:jfcx6").click();
这给了我这个错误
Exception in thread "JavaFX Application Thread" com.ui4j.api.util.Ui4jException: org.w3c.dom.DOMException
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/1876181116.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/1995813168.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.lambda$null(GtkApplication.java:139)
at com.sun.glass.ui.gtk.GtkApplication$$Lambda/345577659.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.w3c.dom.DOMException
at com.sun.webkit.dom.DocumentImpl.querySelectorImpl(Native Method)
at com.sun.webkit.dom.DocumentImpl.querySelector(DocumentImpl.java:1102)
at com.ui4j.webkit.spi.W3CSelectorEngine.query(W3CSelectorEngine.java:41)
at com.ui4j.webkit.dom.WebKitDocument.query(WebKitDocument.java:42)
at com.ui4j.webkit.dom.WebKitDocument$ByteBuddy$rFtzsPLl.query$accessor$fcVUXi0a(Unknown Source)
at com.ui4j.webkit.dom.WebKitDocument$ByteBuddy$rFtzsPLl$accessor$K6O5cVza.call(Unknown Source)
at com.ui4j.webkit.proxy.WebKitProxy$CallableExecutor.run(WebKitProxy.java:44)
... 10 more
有什么帮助吗?
T:df6yt:0:jfcx6 不是有效的选择器。冒号字符must be escaped。作为替代解决方案,使用此 a[title='Αναζήτηση'].x1sq 选择器。
我正在尝试使用 ui4j 为站点创建自动化程序,但我停了下来。过去曾使用过 UI4J 并且工作得很好,但现在它找不到我需要它单击以移动到另一个页面的项目。 来自 website 的代码是这样的
<div>
<a id="T:df6yt:0:jfcx6" class="x1sq xfd" href="#" onclick="return false;" title="Αναζήτηση"></a>
</div>
我在我的 java 程序中使用它
BrowserEngine webkit = BrowserFactory.getWebKit();
Page page = webkit.navigate("http://www.eprocurement.gov.gr");
page.show();
Document document = page.getDocument();
Thread.sleep(30000);
document.query("T:df6yt:0:jfcx6").click();
这给了我这个错误
Exception in thread "JavaFX Application Thread" com.ui4j.api.util.Ui4jException: org.w3c.dom.DOMException
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/1876181116.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/1995813168.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.lambda$null(GtkApplication.java:139)
at com.sun.glass.ui.gtk.GtkApplication$$Lambda/345577659.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.w3c.dom.DOMException
at com.sun.webkit.dom.DocumentImpl.querySelectorImpl(Native Method)
at com.sun.webkit.dom.DocumentImpl.querySelector(DocumentImpl.java:1102)
at com.ui4j.webkit.spi.W3CSelectorEngine.query(W3CSelectorEngine.java:41)
at com.ui4j.webkit.dom.WebKitDocument.query(WebKitDocument.java:42)
at com.ui4j.webkit.dom.WebKitDocument$ByteBuddy$rFtzsPLl.query$accessor$fcVUXi0a(Unknown Source)
at com.ui4j.webkit.dom.WebKitDocument$ByteBuddy$rFtzsPLl$accessor$K6O5cVza.call(Unknown Source)
at com.ui4j.webkit.proxy.WebKitProxy$CallableExecutor.run(WebKitProxy.java:44)
... 10 more
有什么帮助吗?
T:df6yt:0:jfcx6 不是有效的选择器。冒号字符must be escaped。作为替代解决方案,使用此 a[title='Αναζήτηση'].x1sq 选择器。