piotr.dobrogost
26th August 2009, 19:36
I'm trying to use evaluateJavaScript() to call some js function on the page I'm logged into. Calling this function should initiate ajax call to retrieve data. When I call it from within Firebug (Firefox's plugin) I can see network traffic initiated and data downloaded. When I do the same programmatically using evaluateJavaScript() nothing happens. I'm fighting with this for the last 3 days... Any help would be much appreciated. Thanks in advance.
Things I tried;
1. I tried also QWebElement::evaluateScript() on the element which has the js function. This element is an anchor and it looks like this
<a class="InfoLink" href="javascript:mySelectHandler('X','290 877',32,'0','','','')">290 877</a>
2. I tried evaluating this js function from within Web Inspector and got "undefined" in response which I take as function was called successfully with no result returned.
3. I wrote ugly method to click on given element which you can see below. WebPage inherits from QWebPage. It doesn't work in this case as well.
void
WebPage::clickElement(QWebElement element)
{
QPoint clickPoint = element.geometry().center();
QMouseEvent * buttonPress =
new QMouseEvent(QEvent::MouseButtonPress,
clickPoint,
Qt::LeftButton,
Qt::LeftButton,
Qt::NoModifier);
QMouseEvent * buttonRelease =
new QMouseEvent(QEvent::MouseButtonRelease,
clickPoint,
Qt::LeftButton,
Qt::LeftButton,
Qt::NoModifier);
event(buttonPress);
event(buttonRelease);
}
Things I tried;
1. I tried also QWebElement::evaluateScript() on the element which has the js function. This element is an anchor and it looks like this
<a class="InfoLink" href="javascript:mySelectHandler('X','290 877',32,'0','','','')">290 877</a>
2. I tried evaluating this js function from within Web Inspector and got "undefined" in response which I take as function was called successfully with no result returned.
3. I wrote ugly method to click on given element which you can see below. WebPage inherits from QWebPage. It doesn't work in this case as well.
void
WebPage::clickElement(QWebElement element)
{
QPoint clickPoint = element.geometry().center();
QMouseEvent * buttonPress =
new QMouseEvent(QEvent::MouseButtonPress,
clickPoint,
Qt::LeftButton,
Qt::LeftButton,
Qt::NoModifier);
QMouseEvent * buttonRelease =
new QMouseEvent(QEvent::MouseButtonRelease,
clickPoint,
Qt::LeftButton,
Qt::LeftButton,
Qt::NoModifier);
event(buttonPress);
event(buttonRelease);
}