Unable to create run configuration with SWTBot [message #1802277] |
Tue, 05 February 2019 13:24  |
Eclipse User |
|
|
|
Hi,
I want to create a run configuration as part of an SWTBot testcase. In order to do so, I navigate via the context menu of a sample project to the run configurations dialog and create the new configuration with a specified name, like this:
bot.viewByTitle("Model Explorer").show();
bot.tree().getTreeItem("Minimum_Project").contextMenu("Run As").menu("Run Configurations...").click();
bot.tree().getTreeItem("SimuBench").select();
bot.toolbarButtonWithTooltip("New launch configuration").click();
bot.textWithLabel("&Name:").setText("A_Minimum_Configuration");
bot.button("Apply").click();
No problem so far. Now have a look at this image, pls:

I need to set some text in the highlighted text fields, but SWTBot is not able to find/access them. It seems like it would be only possible to use "structures" that are not within these tabs ("Architecture Model(s)", "Simulation", etc.). The next problem is, that I have to switch to the "Simulation"-tab, to fill out another form.
Is it somehow possible to access the "structures" (buttons, text fields, ...) inside these tabs as part of a SWTBot test? If so, please tell me how. (I assume that if you can give me an example that works on the run configuration of a "normal" eclipse project, the same strategy should work in my case as well).
Note that using keyboard shortcuts is not possible, because if you "click" on an UI element and, as a result, focus it, and then let SWTBot perform some shortcuts, the focus seems to be somehow reset before the shortcuts are pressed. Therefore pressing the indent key as many times as needed to navigate to the appropriate buttons is not possible.
I am using Eclipse Version: 4.8.0.v20180611-0656 Build id: I20180611-0500 together with SWTBot 2.6.201706141832.
If you have any questions, don't hesitate to ask. I'll do my best to give you as much information as you need.
Thank you in advance.
|
|
|
|
|
Re: Unable to create run configuration with SWTBot [message #1807671 is a reply to message #1802894] |
Wed, 05 June 2019 17:24  |
Eclipse User |
|
|
|
Hi N M,
Sorry for the really late reply, but in case someone reads this and wants to know:
SWTBot shellBot = bot.shell("Run Configurations").activate().bot();
This can be split in 3 steps:
SWTBotShell shell = bot.shell("Run Configurations"); // Get the shell by name. It will wait for the shell to appear.
shell.activate(); // Activate the shell. A new shell that appears does not always become the active shell. The method returns itself.
SWTBot shellBot = shell.bot(); // Get a SWTBot for this shell. This SWTBot can be used to search for widgets within this shell only.
When you use the SWTWorkbenchBot to search for widgets (e.g. bot.button("Run" ), it searches in the current active shell (or fails if there is no active shell). The code above is more robust because it ensures the expected shell exists and is activated, and restricts the search for widgets to the expected shell.
There is not a lot of up-to-date documentation for SWTBot, but there is some info in the Users Guide.
A good step would be to look at SWTBot's own unit tests in org.eclipse.swtbot.eclipse.finder.test and org.eclipse.swtbot.swt.finder.test plugins.
Patrick
|
|
|
Powered by
FUDForum. Page generated in 0.04004 seconds