前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >DUIR Framework 相关技术介绍

DUIR Framework 相关技术介绍

作者头像
用户1172223
发布2018-01-30 10:48:28
7390
发布2018-01-30 10:48:28
举报
文章被收录于专栏:哲学驱动设计哲学驱动设计

开发者在搭建界面自动化测试框架时,又或者在开发界面自动化控制的机器人时,往往需要对界面进行自动化的程序控制。而现在公司内部使用的杜尔自动化框架,就是一个封装了界面自动化控制逻辑的程序框架。基于该框架,开发者可以轻松、快速的控制各类程序的界面,这些界面可以包含 Windows 界面、浏览器界面。

五年前曾经写过一篇关于自动化测试的框架的文章:《搭建 WPF 上的 UI 自动化测试框架》。杜尔自动化框架,也是基于类似的技术,今天整理一下这个框架所使用的技术,在这里和大家简单分享一下。

杜尔的架构如下图所示:

对图中的所涉及技术,简单介绍如下:

最底层平台,是 Windows 平台,我们的框架只考虑该平台界面的自动化。

最上层,是框架的使用者、客户端,目前这个框架会集成在我公司的另一个智能客户端 VICA (VAT Intelligent Client Assistant)中。

再往下,就是 DUIR: Dben UI Robot Framework,中文名:杜尔机器人框架。

杜尔框架主要分为两层:下层是对 windows 下各类普通控件的查找、定位、封装;上层则是基于部分常见的场景,使用下层的控件来实现的各类场景逻辑的封装。其核心,自然是底层的控件封装。该层的实现,主要依赖三类技术:

  1. 直接使用句柄、消息机制等底层 Windows 机制来实现控制的控制。
  2. 使用 UI Automation for Managed Code 来实现控件自动化。
  3. 使用 VSTT(Visual Studio Testing Tool)& RPF 框架来实现控件自动化以及录制功能。

第 1 项技术:句柄消息机制,很常见,在此不赘述。

第 2、3 两项技术,都主要依赖于底层的 Windows Automation API,该技术是整个体系的核心。介绍如下:

“Microsoft UI Automation is an accessibility framework that enables Microsoft Windows applications to provide and consume programmatic information about user interfaces (UIs). It provides programmatic access to most UI elements on the desktop. It enables assistive technology products, such as screen readers, to provide information about the UI to end users and to manipulate the UI by means other than standard input. UI Automation also allows automated test scripts to interact with the UI.”

详情,见:《Windows Automation API: UI Automation》。

再回过头来看 UI Automation for Managed Code,这是 UI Automation 的托管代码框架。详见:《UI Automation for Managed Code》。

另一项技术,则是 RPF,详见《Record and Playback Framework》。RPF 支持录制与播放,集成了 Win32、MSAA、UIA、IE 等底层平台,介绍如下:

“RPF is a tool used to record meaningful steps performed by a user against a UI-based target application and then generate a code/script to play these steps back. RPF consists of two parts Recording and Playback. Both parts use Win32 and Microsoft Active Accessibility (MSAA) or UIAutom ation(UIA) as the underlying technologies, however at this time RPF has full support for Win32 and MSAA only and UIA is supported by Playback only. Also RPF natively supports Internet Explorerwhich makes it the first (and the only at the moment) tool that natively supports Win32, MSAA, UIA and IE on Vista and XP.”

另外,图中的 VSTT,全称为 Visual Studio Testing Tool。是 Visual Studio 中 Coded UI Test 框架的基础框架。其使用托管代码构建,基于下层的 RPF 框架构建。通过使用 VSTT,使得我们可以以一种更加简单的 API、更加易用的托管代码,并配合更加方便使用的工具来实现 UI 自动化。详见:《Introduction to Record and Playback Engine in VSTT 2010》。

目前,虽然 DUIR 支持 Win32、UIA、VSTT,但是大部分的场景,都会直接基于 VSTT 来实现。只有少量 VSTT 无法实现的情况下,我们才会使用另外两个技术来实现,并封装在 DUIR 内部。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017-12-23 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档