mmarquee.demo.TestMainPowerpoint Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ui-automation Show documentation
Show all versions of ui-automation Show documentation
A Java library that wraps the MS UIAutomation library.
/*
* Copyright 2016-17 [email protected]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package mmarquee.demo;
import mmarquee.automation.AutomationElement;
import mmarquee.automation.UIAutomation;
import mmarquee.automation.controls.*;
/**
* @author Mark Humphreys
* Date 26/02/2016.
*
* Test the automation wrapper on Excel.
*/
public class TestMainPowerpoint extends TestBase {
public void run() {
UIAutomation automation = UIAutomation.getInstance();
AutomationApplication application = null;
try {
// 0. Load Powerpoint
try {
// Start the application
application = automation.launchOrAttach("\"C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\POWERPNT.EXE\"");
} catch (Throwable ex) {
// Smother
logger.error("Failed to launch or attach Powerpoint");
}
// 1. Load the file
// You'll have to do that manually
// 2. Get the sheet
AutomationWindow window = application.getWindow("This is text.pptx - PowerPoint");
logger.info(window.getName());
AutomationPanel panelX = window.getPanelByClassName(0, "MDIClient");
logger.info(panelX.getName());
logger.info(panelX.getClassName());
AutomationPanel panel1 = panelX.getPanel("PowerPoint Edit View - [This is text.pptx]");
logger.info(panelX.getName());
AutomationPanel panel2 = panel1.getPanel("Slide");
logger.info(panel2.getName());
AutomationPowerpointSlide slide = panel2.getPowerpointSlide("Slide 1 - This is text");
logger.info(slide.getName());
// Oddly enough this is an image control, and has text in it's selection
AutomationImage image = slide.getImage("Title TextBox");
AutomationElement element = image.getSelectionContainer();
// logger.info(text.getValue());
AutomationImage image1 = slide.getImage(0);
logger.info("++ ALL DONE ++");
} catch (Exception ex) {
logger.info("Something went wrong - " + ex.getClass());
}
}
}