如何使用WinAppDriver实现windows程序自动化

本文介绍了如何利用WinAppDriver、inspect工具以及Python的appium库进行Windows应用的自动化测试。首先,通过WindowsSDK中的inspect工具来检查和理解UI元素。然后,启动WinAppDriver服务。接着展示了一个DEMO,展示了如何在Python中编写测试脚本,寻找并点击应用内的元素。最后,文章提及提供有软件测试学习资源可供读者领取。
摘要由CSDN通过智能技术生成

主要使用工具:WinAppDriver,inspect、python-client-appium

官网:https://appium.io/docs/en/drivers/windows/#inspecting-ui-elements

WinAppDriver版本:https://github.com/Microsoft/WinAppDriver/releases

1.window查找元素工具

https://docs.microsoft.com/en-us/windows/win32/winauto/inspect-objects

Microsoft Visual Studio 2015默认包含Windows SDK,它提供了检查您正在测试的应用程序的绝佳工具。此工具允许您查看可以使用Windows应用程序驱动程序查询 的每个UI元素/节点。可以在Windows SDK文件夹下找到此inspect.exe工具,例如 C:\Program Files (x86)\Windows Kits\10\bin\x86。该工具将显示各种元素属性。

如图:

2.启动WinAppDriver.exe

 

3.实现具体运用DEMO

import unittest

import time

from appium import webdriver

from selenium.webdriver.common.keys import Keys

class NotepadTests(unittest.TestCase):

def test_edit(self):

for i in range(1,5):

desired_caps = {}

desired_caps['app'] = r"C:\Program Files\tengyue\XXX.exe"

self.driver = webdriver.Remote(

command_executor='http://127.0.0.1:4723',

desired_capabilities=desired_caps)

self.driver.implicitly_wait(10)

try:

self.driver.find_element_by_name("重新检测").click()

time.sleep(5)

except:

print("第"+str(i)+"执行成功")

self.driver.quit()

if __name__ == "__main__":

aa=NotepadTests();

aa.test_edit()

最后: 为了回馈铁杆粉丝们,我给大家整理了完整的软件测试视频学习教程,朋友们如果需要可以自行免费领取 【保证100%免费】

 全套资料获取方式:点击下方小卡片自行领取即可

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值