element ui 获取文件的路径_win10使用WinAppDriver实现UI自动化
生活随笔
收集整理的這篇文章主要介紹了
element ui 获取文件的路径_win10使用WinAppDriver实现UI自动化
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
win10使用WinAppDriver實(shí)現(xiàn)UI自動(dòng)化
WinAppDriver說(shuō)明
- WinAppDriver(Windows Application Driver)是一個(gè)類似Selenium的UI自動(dòng)化測(cè)試服務(wù)
- 系統(tǒng)要求: Windows10或Windows Server 2016
- 支持應(yīng)用程序: UWP, WPF, WinForms, Win32
開發(fā)配置
- 要求系統(tǒng)啟用開發(fā)人員模式
- 設(shè)置 -> 更新和安全 -> 開發(fā)者選項(xiàng)
測(cè)試環(huán)境
系統(tǒng): win10 Python3.6.3下載&安裝&運(yùn)行
- 下載安裝: https://github.com/Microsoft/WinAppDriver/releases
- 運(yùn)行WinAppDriver.exe
示例
- 連接WinAppDriver服務(wù)
- 元素查找
- 元素可以通過(guò)inspect.exe獲取, 系統(tǒng)一般自帶, 路徑C:Program Files (x86)Windows Kits10binx64
- 也可以通過(guò)WinAppDriver UI Recorder獲取
- 元素查找方法對(duì)照表
- 實(shí)踐: 操作記事本
參考代碼
import unittestfrom appium import webdriver from selenium.webdriver.common.keys import Keysclass NotepadTests(unittest.TestCase):@classmethoddef setUpClass(self):desired_caps = {}desired_caps['app'] = r"C:WindowsSystem32notepad.exe"self.driver = webdriver.Remote(command_executor='http://127.0.0.1:4723',desired_capabilities=desired_caps)@classmethoddef tearDownClass(self):self.driver.quit()def test_edit(self):self.driver.find_element_by_name("文本編輯器").send_keys("polyv")self.driver.find_element_by_name("文件(F)").click()self.driver.find_element_by_xpath('//MenuItem[starts-with(@Name, "保存(S)")]').click()self.driver.find_element_by_xpath('//Pane[starts-with(@ClassName, "Address Band Root")]').find_element_by_xpath('//ProgressBar[starts-with(@ClassName, "msctls_progress32")]').click()self.driver.find_element_by_xpath('//Edit[starts-with(@Name, "地址")]').send_keys(r"D:test" + Keys.ENTER)self.driver.find_element_by_accessibility_id('FileNameControlHost').send_keys("note_test.txt")self.driver.find_element_by_name("保存(S)").click()self.driver.find_element_by_name("關(guān)閉").click()if __name__ == "__main__":suite = unittest.TestLoader().loadTestsFromTestCase(NotepadTests)unittest.TextTestRunner(verbosity=2).run(suite)參考: https://github.com/Microsoft/WinAppDriver
總結(jié)
以上是生活随笔為你收集整理的element ui 获取文件的路径_win10使用WinAppDriver实现UI自动化的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: table切换数据 vue_Vue 知识
- 下一篇: cap流程图_3D流程图