0

I am working on automating UI-tests for an application and have trouble with menu items on Windows. Fwiw, I have it working on Mac for the sister-application. I am using Appium from Python.

I can find the menu tree using Inspect.exe, click the top-level menu, which then opens the dropdown, and in here I find the menu item, I want to click, but WinAppDriver fails with this error: {"status":105,"value":{"error":"element not interactable","message":"An element command could not be completed because the element is not pointer- or keyboard interactable."}}

The below python reproduces the problem.

import time
import unittest
from appium import webdriver

app_exe_path = "C:\\Program Files\\Phase One\\Capture One 12\\CaptureOne.exe"
menu_name = "Select"
menu_item_name = "First"
switch_window = True
# app_exe_path = "C:\\Windows\\Notepad.exe"
# menu_name = "File"
# menu_item_name = "Open..."
# switch_window = False


class ClickApplicationMenuItem(unittest.TestCase):
    def test_click_application_menu_item(self):
        driver = webdriver.Remote(
            command_executor="http://localhost:4723",
            desired_capabilities={"app": app_exe_path},
        )
        if switch_window:
            time.sleep(5) # non-optimal code for the sake of a simple repro
            handles = driver.window_handles
            driver.switch_to.window(handles[0])
        menu = driver.find_element_by_name(menu_name)
        menu.click() # fails in the Notepad case
        item = menu.find_element_by_name(menu_item_name)
        item.click() # fails in the CaptureOne case


if __name__ == "__main__":
    unittest.main()

Any advice on how to click the menu item?

2 Answers 2

1

Here is what ended up working for the menu item (I am keeping the menu.click() since that works for the application, I am testing):

   from selenium.webdriver.common.action_chains import ActionChains
   actions = ActionChains(driver)
   actions.click(item)
   actions.perform()
Sign up to request clarification or add additional context in comments.

2 Comments

So you didn't need those coordinates after all? That's even better :-).
Exactly :-) What puzzles me a little is why the WebElement.click method reports that the very same element isn't clickable. Perhaps some day someone will dig into that and maybe file an issue...
0

Since you are able to find those elements, I assume you have access to their properties. A simple workaround could be to click the elements coordinates instead of clicking the element itself. Usually, clicking coordinates is a bad idea, but since you get the coordinates from the element itself, I see no problem here.

Try something like this:

menu = driver.find_element_by_name(menu_name)
driver.Mouse.Click(menu.coordinates)
item = menu.find_element_by_name(menu_item_name)
driver.Mouse.Click(item.coordinates)

I did get a warning that the mouse functionality is obsolete and that the Actions or ActionBuilder class should be used. You could explore those options as well, but I found a issue that got closed on March 2018 on winappdriver's github page, about that Actions class. It's unclear why it's closed. You can find an alternative way of clicking the coordinates there to.

Resources: Actions issue

3 Comments

Thanks, that is an elegant proposal :-) I will try it out the next time I am working on that project - which is on the 21st
Great! Be sure to come back here to tell me how it worked out, I haven't implemented this solution so not sure if it will work out-of-the-box.
Thanks for setting me on the right track @PixelPlex ! I've just posted my own answer :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.