Assert Table cell value

WindowTester allows you to easily create and run unit tests for every GUI they build. It can also be used to generate system level tests.

Moderators: gnebling, Eric Clayberg, Dan Rubel, keertip, Phil Quitslund

Assert Table cell value

Postby Jaap » Thu Feb 18, 2010 7:17 am

Hello,

I'm trying to validate a value from the eclipse variable view. In this view you see two colomns the first one contains a unique value (name of the variable) and the second colomn contains the value. I'm able to select the correct row using:

Code: Select all
ui.click(new TreeItemLocator("i", new ViewLocator(
            "org.eclipse.debug.ui.VariableView")));


But how do I select the related value. The second colomn in the row? I did try using a TableItemLocator and for both the cellLocator. But non of them gives me the expected result.

Thanx
Jaap
 
Posts: 1
Joined: Thu Feb 18, 2010 7:09 am

Re: Assert Table cell value

Postby keertip » Fri Feb 19, 2010 11:51 am

The TreeItemLocator api has a hasText() method that can be used to validate a value in a tree item. But currently it does not have support for tree items with multiple columns, we are looking into enhancing the api to add this support. For now, as a workaround, you could get the tree item and then validate the value from the second column.

Code: Select all
IWidgetReference ref = (IWidgetReference) ui.click(new TreeItemLocator("i",
                                 new ViewLocator("org.eclipse.debug.ui.VariableView")));
TreeItem treeItem = (TreeItem) ref.getWidget();
assertEquals("expected", getValue(treeItem));


where getValue gets the text from the second column in the tree item

Code: Select all
private String getValue(final TreeItem item){
   final String[] result = new String[1];
   Display.getDefault().syncExec(new Runnable() {
      @Override
      public void run() {
         result[0] = item.getText(1);
      }
   });
   return result[0];
}
keertip
Moderator
 
Posts: 221
Joined: Thu Mar 15, 2007 10:26 am


Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest