我正在测试一个窗口应用程序(窗口表单)。我使用python(appium、robotframe)、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')
您可以使用驱动程序。send_keys(Keys. SHIFT Keys.F10)(从键盘移位F10是右键单击的快捷方式)。