Webelement click does not work
-
@fgdevel
QWebElement el = webView->page()->mainFrame()->findFirstElement("#tool_open");
Does this return the exact element that you wanted ?
You can just doqDebug() << el.toPlainText(); //prints the button text
If this works then
evaluateJavaScript
should work too. -
[ Qt ]
QWebElement el = webView->page()->mainFrame()->findFirstElement("#tool_open");
qDebug() << "WebElement : " + el.attribute("type");it works, el.plainText does not work for this kind of webelement
el.evaluateJavaScript("this.click()");
it does not work
-
I try to simulate a webelement click thanks Qt.
In a web navigator the 'tool_open' click() opens an another web page (with javascript code...). I would like to do the same (simulate mouse clic) with Qt.
[ HTML ]
[ ... ]
<ul>
<li id="tool_clear">
<div></div>
Nouvelle Configuration
</li>
<li id="tool_open" >
<div id="fileinputs">
<div></div>
</div>
Open Image
</li>
</ul>
[ ... ] -
@fgdevel I dont see any code which gets invoked on click of
tool_open
. For eg . the following works i.ealert
is called<script> function click(){ alert("Clicked"); } </script> <li id="list" onclick="click()">Clickable list</li>
and from Qt
QWebElement b = ui->webView->page()->mainFrame()->findFirstElement("#list"); b.evaluateJavaScript("this.click()");
-
-
evaluateJavaScript is your friend
Exemple of code working with Jquery, replace with javascript code
QString jsToExecute += "$('#login-btn').click(); "; ui->webView_login->page()->mainFrame()->documentElement().evaluateJavaScript(jsToExecute + "; null" );