Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Browse For Folder dialog
Browse For Folder dialog [message #34772] Thu, 07 May 2009 14:00 Go to next message
Derek  is currently offline Derek
Messages: 30
Registered: July 2009
Member
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 14:12 Go to previous messageGo to next message
Kay-Uwe Graw is currently offline Kay-Uwe Graw
Messages: 24
Registered: July 2009
Junior Member
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 14:47 Go to previous messageGo to next message
Derek  is currently offline Derek
Messages: 30
Registered: July 2009
Member
Awwwww, bummer.

Thanks for response :)
Re: Browse For Folder dialog [message #34996 is a reply to message #34772] Fri, 08 May 2009 03:07 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan Padegaonkar
Messages: 873
Registered: July 2009
Senior Member
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 07:12 Go to previous message
as Missing name is currently offline as Missing name
Messages: 33
Registered: July 2009
Member
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: Wed Oct 22 08:07:42 GMT 2014

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

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