Steve Vestal
Steve Vestal

Reputation: 11

How to select from an SWTBot Open Perspective popup

I have an "Ontology Manager" view in the "Manage Ontologies" perspective. I am trying to open the "Ontology Manager" view. Here is the current code.

    void test() {
        bot = new SWTWorkbenchBot();
        bot.menu("Window").menu("Perspective").menu("Open Perspective").menu("Other...").click();
        SWTBotTable table = bot.table(); \\ WidgetNotFoundException
        table.select("Manage Ontologies"); 
        bot.button("Open").click(); 
        SWTBotView ontoMgrView = bot.viewByTitle("Ontology Manager");
        ontoMgrView.show();
        assertTrue(ontoMgrView.isActive());
    }

This used to work. What started happening is that SWTBot shows the Open Perspective popup and waits for me to manually make a selection. A WidgetNotFoundException occurs where the comment is. If I comment out that and the following two lines, and do a manual selection, it works. How can I get SWTBot to not wait for manual entry, but instead have the bot make that selection?

I found a work-around for this one case,

SWTBotPerspective perspective = bot.perspectiveByLabel("Manage Ontologies");
perspective.activate();

but the general problem of dealing with popups continues. The following has also now started exhibited this same failure, not able to deal with a popup due to a menu item click.

        SWTBotView ontMgrView = bot.viewByTitle("Ontology Manager");        
        SWTBotTree ontMgrTree = ontMgrView.bot().tree();        
        SWTBotTreeItem workspace = ontMgrTree.getTreeItem("_workspace");
        workspace.contextMenu("Create ontology set...").click();        
        bot.textWithLabel("&Working set name:").setText("OntoSetContentFilters"); \\ WidgetNotFoundException
        bot.button("Finish").click();

Upvotes: 0

Views: 35

Answers (0)

Related Questions