Home » Eclipse Projects » SWTBot » An example of opening an Eclipse perspective using SWTBot
| | | | | | | |
Re: An example of opening an Eclipse perspective using SWTBot [message #14084 is a reply to message #13231] |
Tue, 13 January 2009 16:14 |
Joe Luebker Messages: 36 Registered: July 2009 |
Member |
|
|
Thanks for the tip, that results in a cleaner looking test.
Joe
Ketan Padegaonkar wrote:
> Also realized that you wrote a bit too much of code, you should never
> have to do a bot.widget, unless it's finding a widget that SWTBot does
> not support, or using a matcher that SWTBot does not have.
>
> // Change the perspective via the Open Perspective dialog
> bot.menu("Window").menu("Open Perspective").menu("Other...").click();
> SWTBotShell openPerspectiveShell = bot.shell("Open Perspective");
> openPerspectiveShell.activate();
>
> bot.table().select("Debug");
> bot.button("OK").click();
>
> -- Ketan
>
> On 10/1/09 01:24, Joe Luebker wrote:
>> Hello,
>>
>> I just went through a trial an error session trying to figure out how I
>> could manipulate the Eclipse UI with SWTBot to open a perspective. Below
>> is a simple example of how to open the "Debug" perspective. I thought it
>> may be useful to others that may be getting started with creating tests
>> for Eclipse based products with SWTBot.
>>
>> // Change the perspective via the Open Perspective dialog
>> bot.menu("Window").menu("Open Perspective").menu("Other...").click();
>> SWTBotShell openPerspectiveShell = bot.shell("Open Perspective");
>>
>> SWTBotTable table = new SWTBotTable((Table)
>> bot.widget(widgetOfType(Table.class), openPerspectiveShell.widget));
>> table.select("Debug");
>>
>> SWTBotButton OkButton = new SWTBotButton((Button)
>> bot.widget(widgetOfType(Button.class), openPerspectiveShell.widget));
>> OkButton.click();
>>
>> I think it would be very useful to other test developers trying to use
>> SWTBot to test part various pieces of their Eclipse product if some
>> tutorials/guides were created that showed some real world examples.
>>
>> Thanks,
>> Joe
>
|
|
|
Re: An example of opening an Eclipse perspective using SWTBot [message #14101 is a reply to message #14084] |
Tue, 13 January 2009 16:47 |
Ketan Padegaonkar Messages: 873 Registered: July 2009 |
Senior Member |
|
|
You may be interested in the patch that David filed
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=260623)
It will make your code a one liner:
Eclipse.workbench().switchToPerspective("Debug");
Expect this api to evolve and stabilize over a few weeks, and any inputs
are always welcome.
-- Ketan
On 13/1/09 21:44, Joe Luebker wrote:
> Thanks for the tip, that results in a cleaner looking test.
>
> Joe
>
> Ketan Padegaonkar wrote:
>> Also realized that you wrote a bit too much of code, you should never
>> have to do a bot.widget, unless it's finding a widget that SWTBot does
>> not support, or using a matcher that SWTBot does not have.
>>
>> // Change the perspective via the Open Perspective dialog
>> bot.menu("Window").menu("Open Perspective").menu("Other...").click();
>> SWTBotShell openPerspectiveShell = bot.shell("Open Perspective");
>> openPerspectiveShell.activate();
>>
>> bot.table().select("Debug");
>> bot.button("OK").click();
>>
>> -- Ketan
>>
>> On 10/1/09 01:24, Joe Luebker wrote:
>>> Hello,
>>>
>>> I just went through a trial an error session trying to figure out how I
>>> could manipulate the Eclipse UI with SWTBot to open a perspective. Below
>>> is a simple example of how to open the "Debug" perspective. I thought it
>>> may be useful to others that may be getting started with creating tests
>>> for Eclipse based products with SWTBot.
>>>
>>> // Change the perspective via the Open Perspective dialog
>>> bot.menu("Window").menu("Open Perspective").menu("Other...").click();
>>> SWTBotShell openPerspectiveShell = bot.shell("Open Perspective");
>>>
>>> SWTBotTable table = new SWTBotTable((Table)
>>> bot.widget(widgetOfType(Table.class), openPerspectiveShell.widget));
>>> table.select("Debug");
>>>
>>> SWTBotButton OkButton = new SWTBotButton((Button)
>>> bot.widget(widgetOfType(Button.class), openPerspectiveShell.widget));
>>> OkButton.click();
>>>
>>> I think it would be very useful to other test developers trying to use
>>> SWTBot to test part various pieces of their Eclipse product if some
>>> tutorials/guides were created that showed some real world examples.
>>>
>>> Thanks,
>>> Joe
>>
|
|
|
Re: An example of opening an Eclipse perspective using SWTBot [message #14135 is a reply to message #14101] |
Tue, 13 January 2009 22:10 |
Joe Luebker Messages: 36 Registered: July 2009 |
Member |
|
|
Very nice. I created a utility class in my development project to do
just that. I can switch to using the convenience APIs added as a fix for
that bug once they are complete. Looks like the bug is fairly active and
the changes will be quite large. Maybe once the work is complete a
summary of the added APIs should be posted somewhere since they should
make it even easier to create tests for Eclipse based projects.
Joe
Ketan Padegaonkar wrote:
> You may be interested in the patch that David filed
> (https://bugs.eclipse.org/bugs/show_bug.cgi?id=260623)
>
> It will make your code a one liner:
>
> Eclipse.workbench().switchToPerspective("Debug");
>
> Expect this api to evolve and stabilize over a few weeks, and any inputs
> are always welcome.
>
> -- Ketan
>
>
> On 13/1/09 21:44, Joe Luebker wrote:
>> Thanks for the tip, that results in a cleaner looking test.
>>
>> Joe
>>
>> Ketan Padegaonkar wrote:
>>> Also realized that you wrote a bit too much of code, you should never
>>> have to do a bot.widget, unless it's finding a widget that SWTBot does
>>> not support, or using a matcher that SWTBot does not have.
>>>
>>> // Change the perspective via the Open Perspective dialog
>>> bot.menu("Window").menu("Open Perspective").menu("Other...").click();
>>> SWTBotShell openPerspectiveShell = bot.shell("Open Perspective");
>>> openPerspectiveShell.activate();
>>>
>>> bot.table().select("Debug");
>>> bot.button("OK").click();
>>>
>>> -- Ketan
>>>
>>> On 10/1/09 01:24, Joe Luebker wrote:
>>>> Hello,
>>>>
>>>> I just went through a trial an error session trying to figure out how I
>>>> could manipulate the Eclipse UI with SWTBot to open a perspective.
>>>> Below
>>>> is a simple example of how to open the "Debug" perspective. I
>>>> thought it
>>>> may be useful to others that may be getting started with creating tests
>>>> for Eclipse based products with SWTBot.
>>>>
>>>> // Change the perspective via the Open Perspective dialog
>>>> bot.menu("Window").menu("Open Perspective").menu("Other...").click();
>>>> SWTBotShell openPerspectiveShell = bot.shell("Open Perspective");
>>>>
>>>> SWTBotTable table = new SWTBotTable((Table)
>>>> bot.widget(widgetOfType(Table.class), openPerspectiveShell.widget));
>>>> table.select("Debug");
>>>>
>>>> SWTBotButton OkButton = new SWTBotButton((Button)
>>>> bot.widget(widgetOfType(Button.class), openPerspectiveShell.widget));
>>>> OkButton.click();
>>>>
>>>> I think it would be very useful to other test developers trying to use
>>>> SWTBot to test part various pieces of their Eclipse product if some
>>>> tutorials/guides were created that showed some real world examples.
>>>>
>>>> Thanks,
>>>> Joe
>>>
>
|
|
|
Goto Forum:
Current Time: Sat Nov 09 04:06:40 GMT 2024
Powered by FUDForum. Page generated in 0.03911 seconds
|