We need to find the element using js, in which the text is equal to the example of "San Jose Earthquakes".
String xpath = "//*[contains(text(),\"San Jose Earthquakes\")]"; webEngine.executeScript("document.evaluate('"+xpath+"', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).click();"); webEngine.executeScript("document.evaluate('//*[text()=\'San Jose Earthquakes\']', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE).click()"); It does not help, throws eksepshnami: (One of them
TypeError: undefined is not a function I also tried this
webEngine.executeScript("document.evaluate('//*[contains(child::text(), \"San Jose Earthquakes\")]/child::text()', document, null, XPathResult.ANY_TYPE, null);"); There are no errors, but how to click on the element, if of course something was found
I try webEngine.executeScript("document.evaluate('//*[contains(child::text(), \"San Jose Earthquakes\")]/child::text()', document, null, XPathResult.ANY_TYPE, null).singleNodeValue.click();");
But I get an error
Exception in thread "JavaFX Application Thread" netscape.javascript.JSException: Error: TYPE_ERR: DOM XPath Exception 52 at com.sun.webkit.dom.JSObject.fwkMakeException(JSObject.java:128) at com.sun.webkit.WebPage.twkExecuteScript(Native Method) at com.sun.webkit.WebPage.executeScript(WebPage.java:1439) at javafx.scene.web.WebEngine.executeScript(WebEngine.java:982) at com.valeobet.client.strategies.Bet365Strategy$1.lambda$run$0(Bet365Strategy.java:33) at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294) 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$49(GtkApplication.java:139) at java.lang.Thread.run(Thread.java:745)