python实现windows自动化(webdriver+WinAppDriver+inspect.exe)

1.下载WinAppDriver,下载地址:https://github.com/microsoft/WinAppDriver/releases
可以直接打开WinAppDriver.exe,打开开发者模式,也可以在终端输入

WinAppDriver.exe 4727
WinAppDriver.exe 10.0.0.10 4725
WinAppDriver.exe 10.0.0.10 4723/wd/hub

python实现windows自动化(webdriver+WinAppDriver+inspect.exe)_第1张图片

2.python安装selenium和Appium-Python-Client,这里注意版本的问题,我这边因为这两个模块不匹配导致报错InvalidSelectorException:Message: Locator Strategy 'css selector' is not supported for this session'dict' object has no attribute 'click'
我这边的版本是Appium-Python-Client=0.14,selenium=3.3.1

3.使用inspect.exe查找元素,我的电脑没有自带这个软件,据说下载了Visual Studio之后就会有
python实现windows自动化(webdriver+WinAppDriver+inspect.exe)_第2张图片

4.上代码

from appium import webdriver
from selenium.webdriver.common.by import By
import time

desired_caps = {}
desired_caps['app'] = "C:/Users/lab3_dell/Desktop/JP_Release/JP.exe"
driver = webdriver.Remote(command_executor="http://127.0.0.1:4723",desired_capabilities=desired_caps)
# driver.find_element(by=By.CLASS_NAME,value="Button").click()
element = driver.find_element_by_accessibility_id("1015")
print(element)
element.clear()
element.send_keys("123456")
time.sleep(1)
driver.find_element_by_accessibility_id("1016").click()

你可能感兴趣的:(自动化,python,自动化)