Skip to content
Mark Humphreys edited this page Jan 29, 2017 · 21 revisions

Welcome to the ui-automation wiki!

Further examples

Excel

Assuming that the application has already been started, the following code shows how to get data out of cells.

AutomationWindow window = application.getWindow("Book1 - Excel");
logger.info(window.name());

AutomationPanel panelX = window.getPanelByClassName(0, "XLDESK");
logger.info(panelX.name());
logger.info(panelX.getClassName());

AutomationTab tab = panelX.getTab(0);
logger.info(tab.name());
AutomationDataGrid grid = tab.getDataGrid(0);
logger.info(grid.name());

// Get some data
AutomationDataGridCell cell = grid.getItem(0,0);
logger.info(cell.name());
logger.info(cell.value());

NOTE: The call to getPanelByClassName is only available post release 0.3.10

Word

Word has a nice control hierarchy, and uses 'Pages' which are Custom controls.

AutomationWindow window = application.getWindow("Document1 - Word");
logger.info(window.name());

AutomationPanel pane = window.getPanel("Document1");
logger.info(pane.name());
logger.info(pane.getClassName());
AutomationPanel pane1 = pane.getPanel(0);
logger.info(pane1.name());

AutomationDocument doc = pane1.getDocument(0);
logger.info(doc.name());

AutomationDocumentPage page0 = doc.getPage(0);
logger.info(page0.name());

AutomationEditBox edit = page0.getEditBox(0);
logger.info(edit.name());

String text = edit.getText();
logger.info("Text = " + text.substring(0,10));
Clone this wiki locally