[英]Simplifying Ctype union in Python (to send Keyboard events in Windows)
[英]Python windows app UI automation testing: how to send mouse and keyboard events to winappdriver?
我正在测试 window 应用程序(window 表单)。 我使用 python(appium,robotframework),winAppDriver。
我的任务:
我需要做什么:
我找到了元素。 但我浏览了文档,仍然无法在 python 中找到如何操作。
是否可以通过:
我的短代码:
#to test a window application, wrote by C# windows form
from appium import webdriver
desired_caps = {}
desired_caps["app"] = "D:\\sample.exe"
driver =webdriver.Remote(command_executor='http://127.0.0.1:4723',desired_capabilities=desired_caps)
button= driver.find_element_by_name("Root")
#button.contextClick()??
#how to
#I managed to use pyautogui, to send mouse and keyboard event, but the code look ugly. FYI.
driver_location=driver.get_window_position()
root=driver.find_element_by_name("Root")
root.click()
button_location=root.location
x, y = pyautogui.position()
pyautogui.moveTo(button_location['x']+driver_location['x'],button_location['y']+driver_location['y'])
pyautogui.click( button='right')
您可以使用 driver.send_keys(Keys.SHIFT + Keys.F10)(键盘上的 Shift+F10 是右键单击的快捷方式)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.