我正在寻找一个自动UI测试框架/软件工具.在过去,我一直在使用TestComplete,虽然它是一个很好的软件,但GUI测试自动化的概念被认为是足够困难,我写了一些帖子来抱怨 它.
第三方测试自动化工具的一个问题是,您必须学习新语言才能提高工作效率,更不用说工具支持很差.我现在正计划研究.Net 3.0和White Framework附带的Microsoft UI Automation.但在我这样做之前,我想知道那里的结果是什么.
有没有经验可以分享?您是否在应用程序中使用UI自动化创建了可持续且成功的测试套件?
编辑:这似乎是一个非常难的问题.如果我在这几天内没有收到任何答案,我会为此设置赏金.
我们正在使用Microsoft的UIAutomation框架来开发一个监视特定应用程序事件的客户端,并以不同的方式响应它们.我们已经开始使用该框架的托管版本,但由于延迟问题,转移到UIACOMWrapper中包含的本机版本.在我们(大规模)WPF应用程序中出现更多性能问题后,我们决定将其移至单独的终端应用程序(通过UDP将事件传输到我们的WPF应用程序),这似乎解决了所有性能问题.唯一的问题是,似乎每隔几分钟,TabSelection,StructureChanged,WindowOpened和WindowClosed的事件就会被捕获几分钟.令人惊讶的是,当发生这种情况时,仍会接收和处理PropertyChanged事件.我将发布我们的事件监视器的相关代码,但这可能无关紧要,因为我们在使用Microsoft自己的AccEvent实用程序时已经看到类似的行为.我不能发布受监控应用程序的代码,因为它是专有的和保密的,我可以说它是一个承载WPF窗口的WinForms应用程序,也非常庞大.有没有人在使用UI自动化框架时看到过这种行为?感谢您的时间.
这是监视器代码(我知道事件处理在这里的UI自动化线程上,但是将它移动到专用线程并没有改变任何东西):
public void registerHandlers()
{
//Register on structure changed and window opened events
System.Windows.Automation.Automation.AddStructureChangedEventHandler(
this.getMsAutomationElement(), System.Windows.Automation.TreeScope.Subtree, this.handleStructureChanged);
System.Windows.Automation.Automation.AddAutomationEventHandler(
System.Windows.Automation.WindowPattern.WindowOpenedEvent,
this.getMsAutomationElement(),
System.Windows.Automation.TreeScope.Subtree,
this.handleWindowOpened);
System.Windows.Automation.Automation.AddAutomationEventHandler(
System.Windows.Automation.WindowPattern.WindowClosedEvent,
System.Windows.Automation.AutomationElement.RootElement,
System.Windows.Automation.TreeScope.Subtree,
this.handleWindowClosed);
this.registerValueChanged();
this.registerTextNameChange();
this.registerTabSelected();
this.registerRangeValueChanged();
}
private void registerRangeValueChanged()
{
if (this.getMsAutomationElement() != null)
{
System.Windows.Automation.Automation.AddAutomationPropertyChangedEventHandler(
this.getMsAutomationElement(),
System.Windows.Automation.TreeScope.Subtree, this.handlePropertyChange,
System.Windows.Automation.RangeValuePattern.ValueProperty);
}
}
private void unregisterRangeValueChanged()
{
System.Windows.Automation.Automation.RemoveAutomationPropertyChangedEventHandler(
this.getMsAutomationElement(),
this.handlePropertyChange);
}
private void registerValueChanged()
{
if (this.getMsAutomationElement() != null)
{
System.Windows.Automation.Automation.AddAutomationPropertyChangedEventHandler(
this.getMsAutomationElement(),
System.Windows.Automation.TreeScope.Subtree, this.handlePropertyChange,
System.Windows.Automation.ValuePattern.ValueProperty);
}
}
private void …Run Code Online (Sandbox Code Playgroud) 我在尝试通过Windows UI Automation识别Notification Area窗口(classname:ToolbarWindow32)中的按钮控件时遇到问题:
我通过Windows SDK中部署的Windows UI自动化工具验证了那些"图标"是类型的控件,但是当我尝试运行下面的代码时,我得到一个空引用异常,因为我使用的搜索条件没有得到任何控制.ControlType.Button
我做错了,或者我在Windows UI Automation中发现了某些限制?
这是代码,我将它与WinAPI调用混合,只是为了帮助那些可能会使用该方法的帮助用户.
Dim tskBarClassName As String = "Shell_TrayWnd"
Dim tskBarHwnd As IntPtr = NativeMethods.FindWindow(tskBarClassName, Nothing)
Dim systrayBarClassName As String = "TrayNotifyWnd"
Dim systrayBarHwnd As IntPtr = NativeMethods.FindWindowEx(tskBarHwnd, IntPtr.Zero, systrayBarClassName, Nothing)
Dim ntfyBarClassName As String = "ToolbarWindow32"
Dim ntfyBarHwnd As IntPtr = NativeMethods.FindWindowEx(systrayBarHwnd, IntPtr.Zero, ntfyBarClassName, Nothing)
Dim window As AutomationElement = AutomationElement.FromHandle(ntfyBarHwnd)
Dim condition As New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button)
Dim …Run Code Online (Sandbox Code Playgroud) 我真的想知道,Inspect.exe如何获取它的UI元素,因为它获得的元素比UISpy多得多(两者都在Microsoft Windows SDK 7中可用)
1)我认为UISpy通过UIAutomation库获取它的元素,对吗?(尝试使用UIAutomation并获得完全相同的元素,显示UISpy)
2)Inspect.exe使用哪个库?因为它显示了一些带有MacromediaFlashPlayerActiveX的应用程序的UI元素,我需要在自己的UI-Automation-Application中获取,希望有人知道它.
编辑:Inspect也有一个"UI自动化"模式,它是否也使用UIAutomation库?关于它的奇怪之处在于,在Inspect中它还显示了比UISpy更多的元素.
先感谢您
.net ui-automation ui-spy microsoft-ui-automation inspect.exe
我正在使用自动化来测试应用程序,但有时我想通过批处理文件启动应用程序.当我运行"process.WaitForInputIdle(100)"时,我收到一个错误:
"WaitForInputIdle失败.这可能是因为该进程没有图形界面."
如何判断进程是否具有图形界面?
在我们当前的自动化(使用Selenium/WebDriver/Java)中,我们使用@FindBy 非常广泛.例如:
@FindBy(css="a[name='bcrumb']") protected List<WebElement> breadCrumbLinks;
@FindBy(id="skuError") protected WebElement skuError;
@FindBy(className="reducedPrice") protected List<WebElement> reducedPrice;
@FindBy(partialLinkText="Injinji RUN 2.0") protected WebElement playButton;
@FindBy(linkText="annual member refund") protected WebElement annualMemberRefund;
@FindBy(xpath="//li[@itemprop='price']") protected WebElement productPrice;
Run Code Online (Sandbox Code Playgroud)
根据定义,@FindBy可以使用以下命令定位选择器:using,id,name,className,css,tagName,linkText,partialLinkText和xpath.
最近,我们的前端开发人员建议我们实现一个以'test ='开头的新属性类.我认为这是一个好主意,因为我们可以通过查找文本的模糊来找到WebElements,而不是@FindBy本身使用的值.我的问题是,这将是更好地扩大现有功能的@FindByOR,创建搜索,我们在我们的测试中使用WebElements的一种新的方式?
我有Android应用程序,我想使用Espresso框架来创建测试自动化工具和测试.但我不想在我的应用程序中创建一些东西,并希望使用Espresso的单独模块启动我的应用程序并使用Espresso进行测试.我使用Android Studio.那么..你有什么想法如何解决这个问题?
首先,基本上我相信我只是需要帮助来弄清楚如何计算它,数学并不是我的强项.
仅供参考,MS-Word很可能与解决我的问题无关,我基本上只是提及它,因此你知道我所处的背景,但我相信它对于那些不了解MS-Word的人也应该是可以解决的.
我有一个Word有属性的问题,VerticalPercentScrolled这是一个integer.
这并不像我需要的那样准确,考虑一个300页的Word文档,滚动条只能有integer0到100(百分比),所以例如,300页文档的25%是一个相当大的范围.
我已经离开并在UI Automation库的帮助下读取了正确的值- TestStack.White - 如果发生了一些不需要的滚动,可以成功地将其设置为旧值.
像这样:
var hWnd = (IntPtr)WordUtils.GetHwnd();
var processId = Process.GetCurrentProcess().Id;
var uiApp = TestStack.White.Application.Attach((int)processId);
var uiWindow = uiApp.GetWindow(WindowHandling.GetWindowText(hWnd), InitializeOption.NoCache);
var wf = (IUIItemContainer)uiWindow.Get(SearchCriteria.ByClassName("_WwF"));
var wbs= wf.GetMultiple(SearchCriteria.ByClassName("_WwB"));
if (wbs.Length != 1)
return;
var wb= (IUIItemContainer)wbs.First();
var wgs = wb.GetMultiple(SearchCriteria.ByClassName("_WwG"));
if (wgs.Length != 1)
return;
var wg = wgs.First();
var element = wg.AutomationElement;
var oldVerticalPercent = (double)element.GetCurrentPropertyValue(ScrollPattern.VerticalScrollPercentProperty);
Run Code Online (Sandbox Code Playgroud)
使用此代码,我得到一个百分比值,让我们说9.442248572683356而不是9.
要重置值,请使用以下代码:
object scrollPattern;
if …Run Code Online (Sandbox Code Playgroud) 我正在尝试对 flutter 应用程序中的用户流程进行自动化测试。为此,我使用 flutter 集成测试包(https://flutter.dev/docs/testing/integration-tests)。我已经使用 Integration_test 包编写了测试。虽然这些测试在物理设备上运行,但在某些情况下我必须与本机 UI 元素交互(例如,单击权限按钮以授予相机权限等)。但是,我无法与本机 UI 交互具体要素:
1.在系统权限对话框中点击“允许”
2.打开相机时点击“拍摄”按钮
3.从图库中选择图像
我想了解如何通过脚本实现上述情况并实现自动化。另外,像 appium-flutter-driver 或 flutter-driver 这样的框架可以与 flutter_integration 结合使用来实现这一点。任何指示都会有帮助。
ui-automation ×10
.net ×3
c# ×3
android ×1
automation ×1
flutter ×1
gradle ×1
inspect.exe ×1
instruments ×1
ios ×1
java ×1
ms-word ×1
selenium ×1
testing ×1
ui-spy ×1
vb.net ×1
wpf-4.0 ×1