Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Unable to create run configuration with SWTBot(The goal is to create a run configuration with SWTBot.)
Unable to create run configuration with SWTBot [message #1802277] Tue, 05 February 2019 18:24 Go to next message
N M is currently offline N MFriend
Messages: 2
Registered: September 2018
Junior Member
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:
index.php/fa/34816/0/
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 #1802617 is a reply to message #1802277] Tue, 12 February 2019 21:50 Go to previous messageGo to next message
Patrick Tasse is currently offline Patrick TasseFriend
Messages: 76
Registered: July 2009
Member
Hi N M,

I would expect to access these widgets with code similar to this:

        SWTBot shellBot = bot.shell("Run Configurations").activate().bot();
        shellBot.cTabItem("Architecture Model(s)").show();
        shellBot.buttonInGroup("Workspace...", "Allocation File").click();
        shellBot.textInGroup("Allocation File").setText(text);


Please let us know if this solves your issue or if you find another solution. If it doesn't work, what error are you getting instead?

Patrick
Re: Unable to create run configuration with SWTBot [message #1802894 is a reply to message #1802617] Mon, 18 February 2019 16:10 Go to previous messageGo to next message
N M is currently offline N MFriend
Messages: 2
Registered: September 2018
Junior Member
Hi Patrick,

thank you for your reply. I managed to solve the issue using a similiar code to the one suggested by you.
As a SWTBot-Newbie, I do not fully understand what this call does and why it is necessary:
SWTBot shellBot = bot.shell("Run Configurations").activate().bot();

Can you please explain this to me or send me some documentation where I can read it up? That'd be very nice.

Thank you in advance.
Re: Unable to create run configuration with SWTBot [message #1807671 is a reply to message #1802894] Wed, 05 June 2019 21:24 Go to previous message
Patrick Tasse is currently offline Patrick TasseFriend
Messages: 76
Registered: July 2009
Member
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
Previous Topic:Wrong tested application is started when tests are running with Tycho
Next Topic:SWTBot unable to access to "Table"
Goto Forum:
  


Current Time: Sun Sep 27 18:14:58 GMT 2020

Powered by FUDForum. Page generated in 0.02359 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top