使用UI Automation实现自动化测试--4.2 (ExpandCollapsePattern)
2009-09-13 13:34
459 查看
ExpandCollapsePattern
表示以可视方式进行展开(以显示内容)和折叠(以隐藏内容)的控件。例如ComboBox控件支持ExpandCollapsePattern。ExpandCollapsePattern有两个主要方法:
Expand()方法:隐藏 AutomationElement 的全部子代节点、控件或内容。
Collapse()方法:显示 AutomationElement 的全部子节点、控件或内容。
以下代码是用ExpandCollapsePattern来测试ComboBox控件的Expand和Collapse。
using System;
using System.Text;
using System.Diagnostics;
using System.Threading;
using System.Windows.Automation;
namespace UIATest
以下代码为被测程序的xaml文件:
<Window x:Class="WpfApp.Window1"
2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4 Title="Window1" Height="219" Width="353">
5 <Grid>
6 <ComboBox Name="comboBox1" Height="23" VerticalAlignment="Top" Margin="94,58,0,0" HorizontalAlignment="Left" Width="119">
7 <ComboBoxItem>kaden</ComboBoxItem>
8 <ComboBoxItem>sam</ComboBoxItem>
9 </ComboBox>
10 </Grid>
11</Window>
12Summary
本文主要是对ExpandCollapsePattern 做简单的介绍,并使用ExpandCollapsePattern来操作ComboBox控件,对ComboBox进行Expand和Collapse操作。
相关文章推荐
- 使用UI Automation实现自动化测试--4.2 (ExpandCollapsePattern)
- 使用UI Automation实现自动化测试--4.3 (InvokePattern)
- 使用UI Automation实现自动化测试--4.6.1 (SelectionItemPattern)
- 使用UI Automation实现自动化测试--4.7 (TogglePattern)
- 使用UI Automation实现自动化测试--4.9 (ScrollPattern)
- 使用UI Automation实现自动化测试--4.7 (TogglePattern)
- 使用 UI Automation 实现自动化测试--4.2
- 使用UI Automation实现自动化测试--4.1 (DockPattern)
- 使用UI Automation实现自动化测试 (InvokePattern)
- 使用UI Automation实现自动化测试--4.6.2 (SelectItemPattern Demo)
- 使用UI Automation实现自动化测试 --微软提供的控件Pattern
- 使用UI Automation实现自动化测试--7.2 (模拟键盘复杂操作在自动化测试中的应用)
- 使用UI Automation实现自动化测试--1
- 使用 UI Automation 实现自动化测试--3
- 使用UI Automation实现自动化测试--4.6.1
- 使用UI Automation实现自动化测试--1
- 使用UI Automation实现自动化测试--4.6.2
- 使用UI Automation实现自动化测试--3
- 使用UI Automation实现自动化测试 -1
- 使用UI Automation实现自动化测试 -3