Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python windows应用程序UI自动化测试:如何将鼠标和键盘事件发送到winappdriver?_Python_Winforms_Appium_Ui Automation_Winappdriver - Fatal编程技术网

Python windows应用程序UI自动化测试:如何将鼠标和键盘事件发送到winappdriver?

Python windows应用程序UI自动化测试:如何将鼠标和键盘事件发送到winappdriver?,python,winforms,appium,ui-automation,winappdriver,Python,Winforms,Appium,Ui Automation,Winappdriver,我正在测试一个窗口应用程序(窗口窗体)。我使用python(appium、robotframework)、winAppDriver 我的任务: 右键单击按钮,显示关联菜单,然后选择其中一个 我需要做的是: 使用python发送右键单击,然后选择菜单操作(就像SeleniumWeb中的操作链一样) 我已经找到了元素。但我浏览了doc,仍然无法找到如何在python中实现它 是否可以通过: 将帖子发送到url 127.0.0.1:4723/:sessionId/buttondown 使用p

我正在测试一个窗口应用程序(窗口窗体)。我使用python(appium、robotframework)、winAppDriver

我的任务:

  • 右键单击按钮,显示关联菜单,然后选择其中一个
我需要做的是:

  • 使用python发送右键单击,然后选择菜单操作(就像SeleniumWeb中的操作链一样)
我已经找到了元素。但我浏览了doc,仍然无法找到如何在python中实现它

是否可以通过:

  • 将帖子发送到url 127.0.0.1:4723/:sessionId/buttondown
  • 使用python将键发送到web元素位置?(我在代码中设法做到了这一点,但这不是我想要的,代码看起来很难看)
我的短代码:

#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')