Mittwoch, 9. September 2009

SWTBot Use Tips

1. Select the tree in the view
table = bot.viewByTitle(viewName).bot().table()

2. When more Widgets are in the main desktop, the temp of the SWTBot is important, Sometimes SWTBot can not find the wigdet, because the programm runs so quickly.
For controling, we perhaps can use:

long now = System.currentTimeMillis();

boolean check= false;

while (System.currentTimeMillis() - now < 60000 ) {
....;
if (check)
break;
Thread.sleep(100);
}
assertTrue(check);
}

3.Select the tab item in the view "Properties"

bot.viewByTitle(titleName).bot().cTabItem(tabItemName).activate();

4. Check the items in the Table or TabItem.
It seems, that only using the loop is correct. Or else, it has always Widget Not Found problem.
e.g. use the loop to call the items in the group
temp=bot.label(i).getText();
e.g. for one cell in the table:
if(j==0&& table.cell(i,j).equals(docName)){
flagName=true;
}

5.DateTime does not exist in the SWTBot, so we use CDateTime.
e.g. cDateTime1 = new SWTBotCDateTime((CDateTime)bot.widget(WidgetOfType.widgetOfType(CDateTime.class), 0));

6.If possible or necessary, call all of widgets with Helper class.

7. TableView:get the table in the view
SWTBotTable table = bot.viewByTitle(ViewTitle).bot().table();

8.control the speed of the test cases
// slow down tests
SWTBotPreferences.PLAYBACK_DELAY = 10;
// set to the default speed
SWTBotPreferences.PLAYBACK_DELAY = 0;

9.call the tabItem in view
bot.viewByTitle(title).bot().cTabItem(tabItemTitle).activate();

10.context menu:
//can only to be called according to tree, not tree item.
tree.contextMenu(entries.get(0)).menu(entries.get(1)).click();

11.global SWTBot Widget
In SWTBot, there is some widget to be repeatly used. In this situation, this widget can be defined as global variable in the class. e.g. for MainTree.

12.In my experience, write a test case, meanwhile generate a automatical report and analysis it. When man knows how the system is implemented, test cases can be designed much better at the beginning. e.g. SWTBot testet not only GUI and also testet the transport date between GUI and inside business object.

1 Kommentar:

Anonym hat gesagt…

10.context menu:
//can only to be called according to tree, not tree item.
tree.contextMenu(entries.get(0)).menu(entries.get(1)).click();

What is in the var "entries"?