How to access the widget of external application.
-
Hi,
I am trying to write GUI automation for -QT- Qt Application. The idea is to launch the application under test and the automation should be able to click on the menu items, button, slider based on the widget name. I read that if the widgets are implementing QAccessibleWidget , then external application can query for the widgets.
Can anyone guide me how to go about this?
-Thanks
-
If the application is to operate on the opened widget on screen I think that a starting point would be to identify the widget that has focus on screen .With this info it is possible to access its menus and tool bars and do whatever you want to do with it.
Hope this helps.
-
As you said first i want to get the focus on the main application.
Main Application Code:
@
int main(int argc, char **argv)
{
QApplication app (argc, argv);
QPushButton button ("Hello world !");
button.show();return app.exec();
}
@
My Test Application:
Here i am trying to launch my main application and try to simulate the click on the push button. Code is below. I can see that the application is getting launched. But not able to get any control. Hope i am more clear this time.@
QString program = "MyApp.exe";
QProcess *myProcess = new QProcess(this);myProcess->startDetached(program ); myProcess->waitForStarted(); QList<QPushButton *> list = myProcess->findChildren<QPushButton *>(); if(list.size() == 0){ printf("Its null :("); }else{ printf("Its not null :) "); }
@
-
Judging from the way you're asking this question, I think this task is beyond your skills. I am sorry to put it so bluntly, but that's what it is.
Instead of building this yourself, I would like to recommend you take a look at some already existing implementations. "Squish":http://www.froglogic.com/squish/gui-testing/editions/qt.php would be an excellent candidate, of course, but there are other alternatives as well, like "Sikuli":http://www.sikuli.org/ (based on taking screen shots) and "many":http://en.wikipedia.org/wiki/List_of_GUI_testing_tools others.
-
Yes Andre. I am not even a wk old in -QT- Qt. I have gone through squish before posting this thread. I wanted to learn how it works. Alteast the basic idea
Edit: please use the proper name. It is called Qt, not QT. QT is short for QuickTime; Andre
-
What Squish does is install hooks in the Qt libraries, gaining direct access to the Qt application under test. That allows it to inspect all its properties, and trigger all slots, and send events to the application at will. A very powerful solution, but not trivial to replicate at all. KDAB's "GammaRay":http://www.kdab.com/kdab-products/gammaray/ application does something similar, and that application is open source.
-
Thanks a lot. I will check GammaRay