|Custom Context Menus and Dialogs [message #696786]
||Thu, 14 July 2011 20:21
Registered: July 2011
I apologize for the generous length of this post, but I have two issues I am trying to settle here.
I am currently in the process of using SWTBot to automate the majority of the testing for my organization's Eclipse SDK plugin. One of the tests requires the bot to right click on a project in the 'Project Explorer' view, bringing up a context menu, then to select a custom context menu and one of its respective sub-menus. Performing this action on one of the built-in context menus, such as the "Run As" menu, works just fine. For instance,
'<SWTBotTreeItem>.contextMenu("Run As").menu("Run Configurations...").click()'
executes as expected with no errors. However, when I try to perform this same action on my own context menu, I receive a WidgetNotFoundException claiming my context menu has been 'disposed'. After cruising the forums and our favorite search engine, I found an external solution to this problem written by Mariot Chauvin called SWTBotUtils. After applying this fix, my bot is able to select the context menu and its sub-menu no problem. My first question within this forum post is to see if there is a built-in fix to my problem. I have no issue using the SWTBotUtils package, however, if there was already a solution within SWTBot itself, it would be great.
Now once the bot successfully selects the context menu and its sub-menu, a dialog specific to our SDK pops up. The class for the dialog is an extension of the Dialog class and the dialog takes a Shell as a parameter when instantiated. The shell that is passed to instantiate the dialog is instantiated as so:
Once the bot opens this dialog, I have found that I must create a SWTBotShell for the dialog and activate it in order for the bot to be able to interact with it. The issue I am having is that once the dialog is closed, the bot can no longer access the simple built-in Eclipse menus. For instance, I have another test that follows a test that opens this problematic dialog, and it calls:
However, when this line is called, I receive a WidgetNotFoundException claiming 'The widget was null'. I am under the impression that this error has something to do with the 'PlatformUI.getWorkbench()' call that occurs when the dialog from the previous test opens. Regardless, I have tried all possible solutions I can think of including creating a new SWTBotShell before trying to access the Eclipse menus, yet nothing seems to work. I am curious if anyone else has encountered a similar problem or if there are any experts out there who may have some insight. As usual, any advice is greatly appreciated. Please let me know if there is any more information I can provide.
Powered by FUDForum
. Page generated in 0.01305 seconds