Tabbed Properties

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

Tabbed Properties

Postby jeremyweber » Tue Feb 03, 2009 4:15 pm

Clicking a tab in a properties sheet is resulting in an resolved import of

import org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList$ListElement;

ui.click(new XYLocator(new SWTWidgetLocator(
TabbedPropertyList$ListElement.class, new ViewLocator(
"org.eclipse.ui.views.PropertySheet")), 31, 10));

Any work arounds?
jeremyweber
 
Posts: 10
Joined: Wed Jun 11, 2008 3:48 am

Re: Tabbed Properties

Postby Phil Quitslund » Thu Feb 05, 2009 9:17 am

Hi Jeremy,

See my previous post re: a repro on our end. Once we experience it and have a working example we can put something together for you.

You might also send this to support, since this is where we track bug reports and feature requests such as these:

wintest-support@instantiations.com

Thanks!


-phil
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Re: Tabbed Properties

Postby jeremyweber » Thu Feb 05, 2009 10:09 am

Sending an email off in just a moment.
jeremyweber
 
Posts: 10
Joined: Wed Jun 11, 2008 3:48 am

Re: Tabbed Properties

Postby Phil Quitslund » Thu Feb 05, 2009 12:52 pm

Thanks for following up. We'll pick this up on our support channel.
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Re: Tabbed Properties

Postby 3061 » Thu Mar 05, 2009 4:11 am

Having a similar problem. When I run the Recorder and click on tabbed properties button (or whatever those horizontally arranged sub-tabs on the left are called), I get the same thing, the recorder outputs:
Code: Select all
import org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList$ListElement;
//[...]
TabbedPropertyList$ListElement.class, new ViewLocator("org.eclipse.ui.views.PropertySheet")), 31, 10));
and can't compile it because of the import is unresolved.

I can make my test click on the Properties tab just fine using
Code: Select all
IWidgetLocator propertiesTab = new CTabItemLocator("PROPERTIES");
ui.click(Properties);


but I'm still looking for a way to click on "Button" or "Andvanced" (on the left) like in this example:
Image
(image from http://www.eclipse.org/articles/Article-Tabbed-Properties/tabbed_properties_view.html)


I tried some random things, but non of those worked, I always get Widget NOT Found Exceptions when running the test:
Code: Select all
ui.click(new CTabItemLocator("Properties/Button"));
ui.click(new TabItemLocator("Button")); // Widget NOT found         
ui.click(new SectionLocator("Button")); // Widget NOT found
ui.click(new ButtonLocator("Button")); // Widget NOT found
ui.click(new TableCellLocator("Button",0)); // Widget NOT found
ui.click(new TableCellLocator("Button",1)); // Widget NOT found


My workaround right now is to do this:
Code: Select all
IWidgetLocator propertiesTab = new CTabItemLocator("Properties");
ui.click(new XYLocator(propertiesTab, 48,38));

The coordinates are relative to the top left corner of the Tabbed window

Would still like to reference those things by name though... they may get rearranged, resized, a skin might screw up the coordinates alltogether, etc.
3061
 
Posts: 42
Joined: Mon Feb 23, 2009 12:43 am

Re: Tabbed Properties

Postby 3061 » Thu Mar 05, 2009 5:36 am

Here's my workaround:
Code: Select all
/**
    * Attempts to click the given button in the Properties View. A click on the
    * "Properties" Tab is executed here, then the coordinates of the desired
    * button a calculated and the button is clicked.
    *
    * This is a workaround because there's no WindowTester Locator for the
    * vertical sub-tabs like General, Description, Detail, Attributes, etc...
    * Those sub-tabs are not declared in source code, but in the properties of
    * an Eclipse application...
    *
    * TODO Find a better way to do this so it doesn't break if buttons are
    * resized
    *
    * @link http://www.eclipse.org/articles/Article-Tabbed-Properties/tabbed_properties_view.html
    *
    * @param buttonName
    *            examples: "General", "Description", "Details", "Attributes"
    */
   protected void clickOnButtonInPropertiesView(String buttonName) throws Exception
   {
      // click on Properties Tab
      IWidgetLocator propertiesTab = new CTabItemLocator("Properties");
      ui.click(propertiesTab);

      /*
       * offset coordinates of the topmost tabbed property button (relative to
       * the top left corner of the Properties View)
       */
      int xOffset = 45;
      int yOffset = 45;
      int buttonHeight = 20; // button is 20 pixels high
      boolean givenButtonNameIsValid = false;

      // check if the given buttonName is valid
      int lastButtonIndex = TPB_UNDER_PROPERTIES.length;
      for (int i = 0; i < lastButtonIndex; i++)
      {
         if (TPB_UNDER_PROPERTIES[i].equals(buttonName))
         {
            yOffset += buttonHeight * i; // the new relative y coordinate
            givenButtonNameIsValid = true;
            break;
         }
      }
      
      assertTrue("Can't find a button named " + buttonName + " under " + TPB_UNDER_PROPERTIES + ".", givenButtonNameIsValid);
      
      if (givenButtonNameIsValid)
      {
         // click that button

                                 /*
             * The Properties View might be too small and the button
             * not visible. So let's maximize the Properties VIew.
             */
                                ui.keyClick(SWT.CTRL, 'm'); // maximize current view            
                                ui.click(new XYLocator(propertiesTab, xOffset, yOffset));
                                ui.keyClick(SWT.CTRL, 'm'); // restore current view to its previous size
      }
   }




TPB_UNDER_PROPERTIES is a String array containing all the buttons in the same order as they appear in the Interface. (TPB stands for "Tabbed Properties Button")
In the example where I posted the screenshot (see post above this one), it would look like this:
Code: Select all
public static final String[] TPB_UNDER_PROPERTIES = new String[] {"Button", "Advanced"};


This assumes you're not using a Theme on Eclipse and have not set custom fonts or sizes for the buttons. Per default, the buttons are 20 pixels high and the middle of the topmost button is at x=45,y=45.
If you add or rearrange buttons in the code, just insert it at the right place in TPB_UNDER_PROPERTIES.
3061
 
Posts: 42
Joined: Mon Feb 23, 2009 12:43 am

Re: Tabbed Properties

Postby Phil Quitslund » Fri Mar 06, 2009 10:25 am

Thanks for sharing this workaround. We have first class support for Tabbed Properties on our feature wish list and will update this thread when we have a beta to try. In the meantime, thanks so much for your help!
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Re: Tabbed Properties

Postby 3061 » Thu Apr 09, 2009 3:45 am

I'm sure this has already been discussed, but I just couldn't find it in the forums.

How do I get the Text inside a fielt in a PropertySheet?

All I can do is click the text using
Code: Select all
ui.click(new XYLocator(new LabeledTextLocator("Name:", new ViewLocator(propertySheetView)), 0, 0));


I want to read out the text from that LabeledTextLocator.
3061
 
Posts: 42
Joined: Mon Feb 23, 2009 12:43 am

Re: Tabbed Properties

Postby Phil Quitslund » Tue Apr 14, 2009 7:54 am

Hmmm... No easy/obvious way with our API. Could you send in a support request? How would you like this to look? Are you wanting to collect values or make assertions? (Or both?)
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Re: Tabbed Properties

Postby 3061 » Wed Apr 15, 2009 1:08 am

Phil Quitslund wrote:Hmmm... No easy/obvious way with our API. Could you send in a support request? How would you like this to look? Are you wanting to collect values or make assertions? (Or both?)


To enter Text in the "Name" text field, I currently do
Code: Select all
ui.click(new LabeledTextLocator("Name"));
ui.keyClick(SWT.CTRL, 'a');
ui.enterText("Hello World!");


I'd love to be able to do something like
Code: Select all
String nameTextBoxContent;
nameTextBoxContent = ui.readText(new LabeledTextLocator("Name"));
assertEquals("Hello World!", nameTextBoxContent);



I haven't found any clipboard handling, which I could have used to get the text (copy text from editable text box, have WIindowTester read out the clipboard).
Ideally, the recorder would output the content of a text box when it is clicked.
3061
 
Posts: 42
Joined: Mon Feb 23, 2009 12:43 am

Re: Tabbed Properties

Postby Phil Quitslund » Mon Apr 20, 2009 10:29 am

What about something like?:

Code: Select all
ui.assertThat(new LabeledTextLocator("Name").hasText("Hello World!"));


Would this work OK for you?
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Re: Tabbed Properties

Postby win » Wed May 13, 2009 7:26 am

Hi ,

With regard to the TPB_UNDER_PROPERTIES workaround
Are you suggesting instead of the XYLocator use the TPB_UNDER_PROPERTIES within the CTabItemLocator

Please advise .

my example is below :

I prefer not using the XYlocator as I will be running these tests on Window/linux/MacOS

IWidgetLocator propertiesTab = new CTabItemLocator("Properties");
ui.click(new XYLocator(propertiesTab, 58,98));
ui.click(new XYLocator(propertiesTab, 360,90));

ui.click(new CTabItemLocator(TPB_UNDER_PROPERTIES[1]));
win
 
Posts: 7
Joined: Mon May 11, 2009 4:14 am

Re: Tabbed Properties

Postby Phil Quitslund » Thu May 14, 2009 11:04 am

I've created an incubator project and have committed some first cuts exploring locators for property tab items. There's still work to be done, but it's a start... Any additions greatly appreciated!

The test that drives this provisional functionality can be browsed here:

http://code.google.com/p/wt-commons/sou ... gTest.java

If you really want to play with this, you'll want to grab the whole project from subversion. SVN access is described here:

http://code.google.com/p/wt-commons/source/checkout

Thanks!

-phil
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Re: Tabbed Properties

Postby karthik.intels12 » Mon Jun 28, 2010 8:49 pm

Hello,

i have gone through that code which you have given in this link. I want to know when it will be available for licenced version.. it seems like i have a solution for my problem what I'm facing in properties view.
Thanks and Regards,
Karthik.M.S
karthik.intels12
 
Posts: 35
Joined: Wed Mar 31, 2010 4:37 am

Re: Tabbed Properties

Postby Phil Quitslund » Tue Jun 29, 2010 8:04 am

We do not have as of yet have a timeline for integtrating the incubator work into the product but will update this thread as soon as we do. In the meantime, any feedback on the provisional API is greatly appreciated!
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am


Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest