2

I am testing a window app( window form). I use python(appium, robotframework), winAppDriver.

My task:

  • right click a button, show the context menu, and select one of them.

what I need to do:

  • using python to send out right click, and then select menu action( just like action chain in selenium web)

I have located the element. but I went through doc, still did not able to find out how to do it in python.

is it possible via:

  • send post to url 127.0.0.1:4723/:sessionId/buttondown.
  • using python to send keys to web element location?(i managed to do this in my code, but this is not what I want, the code looks ugly)

my short code:

#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')
Dharman
  • 30,962
  • 25
  • 85
  • 135
Bing
  • 378
  • 1
  • 3
  • 15

1 Answers1

0

You can use driver.send_keys(Keys.SHIFT + Keys.F10) (Shift+F10 from keyboard is shortcut for Right click).

Syed Azar
  • 11
  • 2