Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Accessing the Problems View
Accessing the Problems View [message #813723] Mon, 05 March 2012 16:39 Go to next message
Roy Wood is currently offline Roy WoodFriend
Messages: 4
Registered: March 2012
Junior Member
Hi, this is my 2nd day using SWTBot so please forgive noobishness.

I want to be able to access the Problems View and count the number of errors (not warnings) there and possibly store the Description too. I've been digging around in various tutorials and guides but can't find anything.

In the short term I want a test to check if a project has no errors. In the long term test to check a project doesn't have some specific error.
Re: Accessing the Problems View [message #814445 is a reply to message #813723] Tue, 06 March 2012 13:10 Go to previous messageGo to next message
Benjamin Ratiarisolo is currently offline Benjamin RatiarisoloFriend
Messages: 16
Registered: January 2010
Location: Paris, France
Junior Member
Hi Roy,

You could try something like that:

    String viewName = "Problems";
    // This will work fine if the view is already opened in your workbench layout.
    // Otherwise, you will have to "simulate" clicking on the "Window -> Show View -> Problem" workbench menu so that the view is indeed displayed in the workbench.
    SWTBotView view = getWorkbench().getBot().viewByTitle(viewName);
    view.show();
    view.bot().tree();
    String category = "Errors";
    int nbOfErrors = 0;
    for (SWTBotTreeItem item : tree.getAllItems()) {
      String text = item.getText();
      if (text != null && text.startsWith(category)) {
        item.expand();
        nbOfErrors = item.getNodes().size();
        break;
      }
   }


Note that the view name itself and the markers categories are actually defined in the plugin.properties file located at the root of the org.eclipse.ui.ide plug-in. In case you want to have your tests run under multiple locales, you should retrieve their actual values from this file instead of hard-coding them.

Hope this helps,
--
benjamin


--
Benjamin Ratiarisolo
IBM ODM Decision Server Rules - Software Developer
IBM Software - France Lab

[Updated on: Tue, 06 March 2012 13:10]

Report message to a moderator

Re: Accessing the Problems View [message #814448 is a reply to message #814445] Tue, 06 March 2012 13:15 Go to previous message
Roy Wood is currently offline Roy WoodFriend
Messages: 4
Registered: March 2012
Junior Member
Hey Benjamin, thanks much for the tips! There's plenty there for me to go on. I'm learning loads more each day.
Language and locale aren't an issue but I'll bear the properties file tip in mind as it might be useful for more things.
Previous Topic:SWTBotMenu.click
Next Topic:Need Help with SWTBOT testing
Goto Forum:
  


Current Time: Fri Mar 29 10:40:45 GMT 2024

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

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

Back to the top