devexpress winforms controls内置140多个ui控件和库,完美构建流畅、美观且易于使用的应用程序。无论是office风格的界面,还是分析处理大批量的业务数据,devexpress winforms都能轻松胜任。devexpress广泛应用于ecm企业内容管理、 成本管控、进程监督、生产调度,在企业/政务信息化管理中占据一席重要之地。
【适用范围】:各种桌面、web应用程序开发,尤其是winforms应用程序开发。
点击获取devexpress v19.2完整版试用下载:https://www.evget.com/product/740/download
在针对visual studio 2019的发行说明中,microsoft 宣布coded ui测试的生命周期终止。
microsoft建议将appium with winappdriver 一起用于测试桌面和uwp应用,此消息引起广大用户的兴趣:devexpress控件是否与appium兼容?经过devexpress团队的反复测试,答案是肯定的!使用appium创建自动ui测试的方法如下。
1. 跳转到 https://github.com/microsoft/winappdriver/releases然后下载两个app,
winappdriver- 允许您运行测试,需要安装。
winappdriver ui recorder- 允许您在运行时记录测试,不需要安装 - 将下载的存档解压到任何文件夹。
2. 在windows中打开developer mode。
3. 以管理员身份运行winappdriver.exe并使其运行,请注意应用程序正在侦听的地址,稍后您将需要它。
4. 打开您要测试的visual studio解决方案,或创建一个新的示例解决方案。
5. 将新的单元测试项目添加到解决方案。
6. 在solution explorer中右键单击unit test project,然后选择“manage nuget packages…”,安装最新的稳定appium.webdriver程序包。
7. 打开unit test项目的unittest1.cs文件,并添加两个类:maindemosession(定义开始和结束测试会话的方法)和helper(包含查找被测试的ui元素的方法),将步骤3中的地址用作windowsapplicationdriverurl值。
public class maindemosession{protected const string windowsapplicationdriverurl = http://127.0.0.1:4723;private const string applicationpath = @c:\users\...\appiumtest.exe; protected static windowsdriver desktopsession; public static void setup(testcontext context) { // launch a new instance of the tested application if (desktopsession == null) { // create a new session to launch the tested application appiumoptions options = new appiumoptions(); options.addadditionalcapability(app, applicationpath); desktopsession = new windowsdriver( new uri(windowsapplicationdriverurl), options); assert.isnotnull(desktopsession); assert.isnotnull(desktopsession.sessionid); // set implicit timeout to 1.5 seconds //to make element search to retry every 500 ms //for at most three times desktopsession.manage().timeouts().implicitwait = timespan.fromseconds(1.5); } } public static void teardown() { // close the application and delete the session if (desktopsession != null) { desktopsession.close(); desktopsession.quit(); desktopsession = null; } } } public static class helper { public static windowselement findelementbyabsolutexpath( this windowsdriver desktopsession, string xpath, int ntrycount = 3) { windowselement uitarget = null; while (ntrycount-- > 0) { try { uitarget = desktopsession.findelementbyxpath(xpath); } catch { } if (uitarget != null) { break; } else { system.threading.thread.sleep(400); } } return uitarget; } }
8. 修改自动生成的unittest1类,如下所示:
[testclass]public class unittest1 : maindemosession{[testmethod]public void testmethod1(){//test start //test finish } [classinitialize] public static void classinitialize(testcontext context) { setup(context); } [classcleanup] public static void classcleanup() { teardown(); } }
9. 运行您的应用程序,并将其拖到主系统显示屏上(如果您具有多屏幕设置)。
10. 启动winappdriver ui recorder然后点击“record”, 将鼠标悬停在要与之交互的第一个ui元素上,然后等待它开始闪烁蓝色。recorder的状态栏会将其文本从“active”更改为“xpath ready”。
11. 当该元素闪烁时,recorder已准备就绪,您可以执行ui操作:单击此元素、将其拖动、输入新值等。完成此元素后,将鼠标悬停在另一个ui元素上,等待 recorder的确认并重复该过程。
12. 记录了要重现的一系列步骤后,请在recorder中单击“pause”,您可以打开actions selector确保已记录所有ui操作。
13. 单击“generate and copy c# code to clipboard”按钮来复制所有记录的操作代码,将此代码粘贴到unittest1.testmethod1方法中。 例如,下面的代码选择“job”标签。
[testmethod] public void testmethod1() { //test start // leftclick on tabitem job at (20,31) console.writeline(leftclick on tabitem \job\ at (20,31)); string xpath_leftclicktabitemjob_20_31 = /pane\[@classname=\#32769\\][@name=\desktop 1\]/window\[starts-with(@automationid,\xtraform\)]/pane[@name=\the xtralayoutcontrol\\][starts-with(@automationid,\datalayoutcontrol\)]/table[@name=\root\]/table[@name=\autogeneratedgroup0\]/table[@name=\root\]/table[@name=\photo\]/table[@name=\firstandlastname\]/tab[@name=\tabs\]/tabitem[@name=\job\]; var winelem_leftclicktabitemjob_20_31 = desktopsession.findelementbyabsolutexpath(xpath_leftclicktabitemjob_20_31); if (winelem_leftclicktabitemjob_20_31 != null) { winelem_leftclicktabitemjob_20_31.click(); } else { console.writeline($failed to find element using xpath: {xpath_leftclicktabitemjob_20_31}); return; } //test finish }
14. 在内部测试期间,自动生成的代码可能无法通过其完整路径找到ui元素:
/pane\[@classname=\#32769\\][@name=\desktop 1\]/window[starts-with…
如果发生这种情况,请缩短所有元素路径,使其以“ / window”开头。
string xpath_leftclicktabitemjob_20_31 = /window[starts-with(@automationid...;
此外,您可以使用assert.fail而不是console.writeline来调试测试(如果找不到ui元素,则可以)。
assert.fail($failed to find element...);
15. 在visual studio中右键单击unit test project,然后单击“run tests”。测试将启动您的应用程序,重复所有记录的步骤,然后关闭应用程序。 所有测试操作都记录在步骤3中启动的winappdriver控制台中。
您可以通过与coded ui相同的方式启动appium测试,唯一的区别是您需要在测试执行计算机上运行winappdriver。
5G+全栈国产化赋能智能电网,助力“5G智慧之城”
阿里物流机器人小蛮驴上岗 浙大全球首个纯机器人送货高校
炫酷LED环的制作教程
华为P30 Pro正式发布了墨玉蓝和嫣紫色两款新配色
基于单片机的VRAM型彩色液晶显示模块设计
如何使用DevExpress Winforms实现UI自动化
FSR3性能画质双超DLSS3!AMD RX 6750 GRE首发评测:远强于RTX 4060
AMD最顶级的RX 6900 XT下个月即将上市
MAX8607 1MHz PWM boost转换器,用于驱动
合宙Air系列开发板官方demo学习(二):camera-摄像头:(1)-capture
TI推出采用CapTIvate™技术的MSP430™微控制器(MCU)系列产品
赛普拉斯半导体推可编程汽车级USB-C控制器 符合PD 2.0标准
村田购买了索尼的电池业务,还想借此转行到电动车领域
怎样测量电机的绝缘电阻
光刻工艺的苛刻高精度、重复性和稳定性要求
如何最大程度的降低电源模块的电磁干扰
带通滤波器宽阻带技术解析
Pasternack射频开关有三种基本类型
电机技术种类有哪些 典型的电机选型过程
联通沃视频为用户提供端到端的全场景沉浸式VR体验