Frage

I want to write test in SWTBot. The test should press on table add new row and then press on button of DateCombo and insert value to the cell.( value from the calender )

This is my code :

 public SWTBotTable AppExp_getGridTable(SWTBotView appExpView) {
    return appExpView.bot().tableWithId("GridViewer.Table"); //$NON-NLS-1$
}
public List<Widget> getWidgetListOfType(java.lang.Class type) {
    Matcher matcher = allOf(widgetOfType(type));
    List<Widget> widgets = bot.getFinder().findControls(matcher);
    return widgets;
}

SWTBotTable swtbotTable = utilsList.AppExp_getGridTable(view);
 //Put the foucs on the cell

 swtbotTable.doubleClick(0, 1);
  Display.getDefault().syncExec(new Runnable() {
        @Override
        public void run() {
        List<Widget> widgetListOfType =       utilsList.getWidgetListOfType(DateCombo.class);
            DateCombo dateCombo = (DateCombo) widgetListOfType.get(0);
            List<Widget> widgetListOfType = utilsList.getWidgetListOfType(Button.class);
            Button bt = (Button) widgetListOfType.get(0);   
        }
    });

How I can trigger the click on the button or on the dateCombo?

And then How I can select value from the calendar ?

War es hilfreich?

Lösung

I have no idea what DateCombo is, since it's not part of the default API, but you can simulate the Button click like this:

Event event = new Event();
event.widget = button;
event.type = SWT.Selection;

button.notifyListeners(SWT.Selection, event);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top