Hello all,
For one of the scripts needed in some functional Safety Analysis, it was mandatory to create a Dialog Box window for asking the user to enter some values needed for the generation of ppFMEDA worksheets. The DialogBox was created using SWT and Shell classes, but unfortunately Qkit wasn't able to recognize the Buttons nor the widgets created on the Dialog Box even if during record they were well known. I've tried to use Jface too, but the issue still the same.
I'll provide also the function I created to generate this DialogBox:
function showDialog() {
var Shell = bind("org.eclipse.swt", "org.eclipse.swt.widgets.Shell", false);
var Label = bind("org.eclipse.swt", "org.eclipse.swt.widgets.Label", false);
var Text = bind("org.eclipse.swt", "org.eclipse.swt.widgets.Text", false);
var Button = bind("org.eclipse.swt", "org.eclipse.swt.widgets.Button", false);
var GridLayout = bind("org.eclipse.swt", "org.eclipse.swt.layout.GridLayout", false);
var GridData = bind("org.eclipse.swt", "org.eclipse.swt.layout.GridData", false);
var SWT = bind("org.eclipse.swt", "org.eclipse.swt.SWT", false);
var SWTComposite = bind("org.eclipse.swt", "org.eclipse.swt.widgets.Composite", false);
// Result container
var result = {
ok : false,
value1 : "",
value2 : ""
};
UI.execute(function enterValues(monitor) {
var parentShell = UI.getWorkbenchWindowShell();
var shell = new Shell(parentShell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE);
shell.setText("Enter t_lifetime & t_service");
shell.setLayout(new GridLayout(2, false));
var infoLabel = new Label(shell, SWT.WRAP);
infoLabel.setText("Please Enter the values to use for parameters t_lifetime and t_service: ");
var gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
gd.horizontalSpan = 2;
infoLabel.setLayoutData(gd);
// user_t_lifetime
var label1 = new Label(shell, SWT.NONE);
label1.setText("user_t_lifetime :");
var txtVar1 = new Text(shell, SWT.BORDER);
txtVar1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
// user_t_service
var label2 = new Label(shell, SWT.NONE);
label2.setText("user_t_service :");
var txtVar2 = new Text(shell, SWT.BORDER);
txtVar2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
// Set default values for t_lifetime and t_service
txtVar1.setText("44000");
txtVar2.setText("44000");
// Buttons
var okButton = new Button(shell, SWT.PUSH);
okButton.setText("OK");
okButton.addListener(SWT.Selection, function(event) {
result.ok = true;
result.value1 = txtVar1.getText();
result.value2 = txtVar2.getText();
shell.close();
});
var cancelButton = new Button(shell, SWT.PUSH);
cancelButton.setText("Cancel");
cancelButton.addListener(SWT.Selection, function(event) {
shell.close();
});
shell.pack();
var parentBounds = parentShell.getBounds();
var dialogBounds = shell.getBounds();
shell.setLocation(
parentBounds.x + Math.round((parentBounds.width - dialogBounds.width) / 2),
parentBounds.y + Math.round((parentBounds.height - dialogBounds.height) / 2)
);
shell.open();
var dialog = shell.getDisplay();
while (!shell.isDisposed()) {
if (!dialog.readAndDispatch()) {
dialog.sleep();
}
}
});
return result;
}
When recording the test case, QKit was able to generate the corresponding ECL to use without any issue at all; OK button and all widgets were also known for it during recording. Nevertheless, once I run the recorded test case, QKit got stuck and stop execution when coming to the click on any widget of this DialogBox. It throws an error at the end about time out exceeded (300 s).
I think the solution here is to use the same classes used by medini to generate popUps/Dialogs...
I've tried manythings like put Buttons inside a Composite and Jface, but unfortunately doesn't solve the issue.
Do you have any idea, How this can be solved? It seems that I need to create this interface using the same classes used by medini.
Thanks in advance for your support.
Regards,
Mohamed