Moderators: gnebling, Eric Clayberg, Dan Rubel, keertip, Phil Quitslund
import org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList$ListElement;
//[...]
TabbedPropertyList$ListElement.class, new ViewLocator("org.eclipse.ui.views.PropertySheet")), 31, 10));
IWidgetLocator propertiesTab = new CTabItemLocator("PROPERTIES");
ui.click(Properties);
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
IWidgetLocator propertiesTab = new CTabItemLocator("Properties");
ui.click(new XYLocator(propertiesTab, 48,38));
/**
* 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
}
}
public static final String[] TPB_UNDER_PROPERTIES = new String[] {"Button", "Advanced"};
ui.click(new XYLocator(new LabeledTextLocator("Name:", new ViewLocator(propertySheetView)), 0, 0));
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?)
ui.click(new LabeledTextLocator("Name"));
ui.keyClick(SWT.CTRL, 'a');
ui.enterText("Hello World!");
String nameTextBoxContent;
nameTextBoxContent = ui.readText(new LabeledTextLocator("Name"));
assertEquals("Hello World!", nameTextBoxContent);
ui.assertThat(new LabeledTextLocator("Name").hasText("Hello World!"));
Users browsing this forum: No registered users and 1 guest