1

The following javascript is to be executed on google.com:

String js   =   "document.evaluate(\"//form[@name='f']\",
document, null, XPathResult.ANY_TYPE, null);";

Now when the form is found, I would like to have it as a QWebElement back in Qt. E.g.:

QWebElement element = (QWebElement)webView.page().mainFrame().evaluateJavaScript(js);

(I know the above works if I was to use a String object instead of QWebElement. )

Any ideas are highly appreciated!

S. M. Shahinul Islam
  • 2,780
  • 4
  • 36
  • 68
Nick
  • 11
  • 1

1 Answers1

0

I have no idea if this is working, I can't use QWebElement for some reason.
But here is a snippet that could work:

String js = "document.getElementById('testID')";
Object obj = view.page().mainFrame().evaluateJavaScript(js);
QWebElement element = obj;

Edit:
If it still doesn't work try to see what it is returning with this code:

String js = "document.getElementById('testID')";
String output = view.page().mainFrame().evaluateJavaScript(js);
System.out.println(output);

Hope it can help you.