example for modifying a preference setting [message #389399] |
Wed, 29 July 2009 20:33  |
Eclipse User |
|
|
|
I've run your webcast swtbot example sucessfully, and have looked at your
other current examples, but I'm having difficulty applying those to a more
complicated case.
I'd like to uncheck a checkbox in the Preference Settings in the Advanced
Capabilities Settings using the swtbot playback. This would have to
select Window->Preferences, then go to the Preferences shell and select
tree node General->Capabilities, then click button Advanced... in the
Capabilities panel, then switch to the Advanced Capabilities Settings
shell and select the Development->Java Development node in that tree, and
then uncheck its associated checkbox. Is this possible with swtbot?
I've tried several versions of code and, amazingly enough, this gets down
to the bot.checkbox().isChecked() test before it fails. Do you have some
way of selecting that checkbox that is associated with the tree node? I
was assuming that the node being selected would provide the context for
the bot at that point.
// bot is SWTWorkbenchBot
bot.menu("Window").menu("Preferences").click();
SWTBotShell prefsShell = bot.shell("Preferences");
prefsShell.activate();
// now bot is acting on prefsShell?
SWTBotTreeItem treeItem =
bot.tree().getTreeItem("General").select().expand().click();
SWTBotTreeItem treeNode =
treeItem.getNode("Capabilities").select().expand().click();
bot.button("Advanced...").click();
SWTBotShell advancedCapabilitiesShell = bot.shell("Advanced Capabilities
Settings");
advancedCapabilitiesShell.activate();
// now General->Capabilities->Advanced Capabilities Settings should be
open
SWTBotTreeItem devItem =
bot.tree().getTreeItem("Development").select().expand().click();
SWTBotTreeItem javaNode = devItem.getNode("Java
Development").select().expand().click();
if (bot.checkBox().isChecked()){
bot.checkBox().click();
}
bot.button("OK").click();
prefsShell.activate();
bot.button("OK").click();
|
|
|
|
|
|
|
Re: example for modifying a preference setting [message #411694 is a reply to message #404037] |
Thu, 30 July 2009 04:39  |
Eclipse User |
|
|
|
On 30/7/09 11:17, Jay Norwood wrote:
> I'm still foggy on how the context is seemingly
> updated for the bot
There is no context, you always tell it what to find by passing in a
matcher. Look at the SWTBot for how that works.
, and it also isn't clear to me which of select(),
> expand(), click() are really needed.
These depend on the context of what widget you're working with. Select
selects a tree node, and returns the same node. Expand and click do similar.
The reason the nodes return itself is so you can chain them together:
tree.expand("MyProject").expand("src").select("MyClass.java ") seems more
natural than:
p = tree.get("MyProject")
p.expand();
s = p.get("src")
s.expand();
....
a few more lines
....
--
Ketan
http://studios.thoughtworks.com/twist | http://twitter.com/ketanpkr
|
|
|
Powered by
FUDForum. Page generated in 0.04783 seconds