Skip to main content



      Home
Home » Eclipse Projects » SWTBot » Browse For Folder dialog
Browse For Folder dialog [message #34772] Thu, 07 May 2009 10:00 Go to next message
Eclipse UserFriend
I'm still fairly new to SWTBot, but so far it's been quite fun working
with it.
I'm having trouble with the Browse For Folder dialog.
It's found at:
Window->Preferences->Plug-in Development->Target Platform->Browse...

Below is part of the code I use to get to said dialog:

bot.menu("Window").menu("Preferences").click();
SWTBotTree preferencesSelectionTree = bot.tree();
preferencesSelectionTree.expandNode("Plug-in Development").select("Target
Platform");
bot.button("Browse...").click();
// Having trouble with below line
bot.textWithLabel("Folder:").setText("");


I tried using SpyView for this dialog but it doesn't spy it (I'm guessing
since it's a system dialog?)

Does anyone know the best way to find out how to focus on the Folder: text
field?



Much Appreciated,

Derek
Re: Browse For Folder dialog [message #34805 is a reply to message #34772] Thu, 07 May 2009 10:12 Go to previous messageGo to next message
Eclipse UserFriend
Unfortunately, the folder selection dialog is a native dialog for which
SWTBot offers no support.

Kay
Re: Browse For Folder dialog [message #34839 is a reply to message #34805] Thu, 07 May 2009 10:47 Go to previous messageGo to next message
Eclipse UserFriend
Awwwww, bummer.

Thanks for response :)
Re: Browse For Folder dialog [message #34996 is a reply to message #34772] Thu, 07 May 2009 23:07 Go to previous messageGo to next message
Eclipse UserFriend
I suppose you just need the FolderDialog to 'return' a specific value:

class FolderDialog{

FolderDialog(Shell parent, int flags){
this.shell = shell;
this.flags = flags;
}

// return a 'special' value in test mode.
String open(){
if (System.getProperty('isTest').equals('true'))
return System.getProperty('folderDialogValue');
else
return new org.eclipse...FolderDialog(shell, flags).open()
}
}

This folder dialog is now a drop in replacement for swt's folder dialog.
To drive this from the swtbot tests:

@BeforeClass
public void beforeClass(){
System.setProperty('isTest');
}
...

@Test
public void test(){
System.setProperty('folderDialogValue', '/path/to/my/folder');
bot.button('browse').click(); // the mock dialog will now return the
folder above :)
}

-- Ketan


Derek wrote:

> I'm still fairly new to SWTBot, but so far it's been quite fun working
> with it.
> I'm having trouble with the Browse For Folder dialog.
> It's found at:
> Window->Preferences->Plug-in Development->Target Platform->Browse...

> Below is part of the code I use to get to said dialog:

> bot.menu("Window").menu("Preferences").click();
> SWTBotTree preferencesSelectionTree = bot.tree();
> preferencesSelectionTree.expandNode("Plug-in Development").select("Target
> Platform");
> bot.button("Browse...").click();
> // Having trouble with below line
> bot.textWithLabel("Folder:").setText("");


> I tried using SpyView for this dialog but it doesn't spy it (I'm guessing
> since it's a system dialog?)

> Does anyone know the best way to find out how to focus on the Folder: text
> field?



> Much Appreciated,

> Derek
Re: Browse For Folder dialog [message #490267 is a reply to message #34996] Thu, 08 October 2009 03:12 Go to previous message
Eclipse UserFriend
Ketan Padegaonkar schrieb:
> I suppose you just need the FolderDialog to 'return' a specific value:
>
> class FolderDialog{
>
> FolderDialog(Shell parent, int flags){
> this.shell = shell;
> this.flags = flags;
> }
>
> // return a 'special' value in test mode.
> String open(){
> if (System.getProperty('isTest').equals('true'))
> return System.getProperty('folderDialogValue');
> else
> return new org.eclipse...FolderDialog(shell, flags).open()
> }
> }
>
> This folder dialog is now a drop in replacement for swt's folder dialog.
> To drive this from the swtbot tests:
>
> @BeforeClass
> public void beforeClass(){
> System.setProperty('isTest');
> }
> ..
>
> @Test
> public void test(){
> System.setProperty('folderDialogValue', '/path/to/my/folder');
> bot.button('browse').click(); // the mock dialog will now return the
> folder above :)
> }
>
> -- Ketan
>
>
> Derek wrote:
>
>> I'm still fairly new to SWTBot, but so far it's been quite fun working
>> with it.
>> I'm having trouble with the Browse For Folder dialog.
>> It's found at:
>> Window->Preferences->Plug-in Development->Target Platform->Browse...
>
>> Below is part of the code I use to get to said dialog:
>
>> bot.menu("Window").menu("Preferences").click();
>> SWTBotTree preferencesSelectionTree = bot.tree();
>> preferencesSelectionTree.expandNode("Plug-in
>> Development").select("Target Platform");
>> bot.button("Browse...").click();
>> // Having trouble with below line
>> bot.textWithLabel("Folder:").setText("");
>
>
>> I tried using SpyView for this dialog but it doesn't spy it (I'm
>> guessing since it's a system dialog?)
>
>> Does anyone know the best way to find out how to focus on the Folder:
>> text field?
>
>
>
>> Much Appreciated,
>
>> Derek
>

I think its unnecessary to test the native dialogs, they just return
some value that I know before my test case runs. So one can use this
value to call text.setText("") directly and if you have some actions
which have to be performed after setting the text, just use the
ModifyListener on your Text widget.

hope it helps
Previous Topic:Version Tags for dev builds
Next Topic:TImeout Question
Goto Forum:
  


Current Time: Fri Jun 13 13:39:33 EDT 2025

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

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

Back to the top