[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[swtbot-dev] Using SWT Bot with RCP
|
Hello Ketan and Mario,
On the FAQ, it's mentionned that we can use SWT Bot to test on RCP
application.
Anyway can you have an example how to do?
I tried this naive approach
package test;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.junit.Test;
public class RCPTest {
@Test
public void testRCP() throws Exception {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout());
Button button = new Button(shell, SWT.NULL);
button.setText("Click");
button.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
@Override
public void widgetSelected(SelectionEvent e) {
System.out.println("Click");
}
});
shell.pack();
shell.open();
SWTBot bot = new SWTBot();
bot.buttonWithLabel("Click").click();
while(!shell.isDisposed()) {
if(!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
I replaced
SWTBot bot = new SWTBot();
bot.buttonWithLabel("Click").click();
with
SWTBotButton swtBotButton = new SWTBotButton(button);
swtBotButton.click();
And I add the "Click" displayed in the console.
Do you have any advice / example where I should create the SWTBot to be
able to have the find feature of the SWTBot working?
Thanks a lot,
Ivan
*******************************
This e-mail contains information for the intended recipient only. It may contain proprietary material or confidential information. If you are not the intended recipient you are not authorised to distribute, copy or use this e-mail or any attachment to it. Murex cannot guarantee that it is virus free and accepts no responsibility for any loss or damage arising from its use. If you have received this e-mail in error please notify immediately the sender and delete the original email received, any attachments and all copies from your system.