![JAR search and dependency download from the Maven repository](/logo.png)
mmarquee.automation.controls.AutomationTab 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.automation.controls;
import mmarquee.automation.*;
import mmarquee.automation.pattern.ItemContainer;
import mmarquee.automation.pattern.PatternNotFoundException;
import mmarquee.automation.uiautomation.TreeScope;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Mark Humphreys on 26/01/2016.
*
* Wrapper for the Tab element.
*/
public class AutomationTab extends AutomationContainer {
public List getTabItems() throws PatternNotFoundException {
// Now get the list of tab items
List tabItems = new ArrayList<>();
try {
List collection = this.findAll(new TreeScope(TreeScope.Descendants));
for (AutomationElement elem : collection) {
if (elem.getControlType() == ControlType.TabItem.getValue()) {
tabItems.add(new AutomationTabItem(elem));
}
}
} catch (AutomationException ex) {
logger.error(ex.getMessage());
}
return tabItems;
}
/**
* Selects the tab with the given name
* @param name The name of the tab to select
* @throws AutomationException Automation library error
* @throws PatternNotFoundException Pattern not found
*/
public void selectTabPage(String name) throws AutomationException, PatternNotFoundException {
boolean found = false;
for(AutomationTabItem item: this.getTabItems()) {
if (name.equals(item.getName())) {
found = true;
item.selectItem();
}
}
if (!found) {
throw new ElementNotFoundException();
}
}
/**
* Constructor for the AutomationTab
* @param element The underlying element
* @throws AutomationException Automation library error
* @throws PatternNotFoundException Expected pattern not found
*/
public AutomationTab (AutomationElement element) throws PatternNotFoundException, AutomationException {
super(element);
}
/**
* Constructor for the AutomationTab
* @param element The underlying element
* @param container The ItemContainer pattern
* @param instance Automation instance
* @throws AutomationException Automation library error
* @throws PatternNotFoundException Expected pattern not found
*/
public AutomationTab (AutomationElement element, ItemContainer container, UIAutomation instance) throws PatternNotFoundException, AutomationException {
super(element, container, instance);
}
/**
* Constructor for the AutomationTab
* @param element The underlying element
* @param container The ItemContainer pattern
* @throws AutomationException Automation library error
* @throws PatternNotFoundException Expected pattern not found
*/
public AutomationTab (AutomationElement element, ItemContainer container) throws PatternNotFoundException, AutomationException {
super(element, container);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy