我正在为应用程序自动进行 UI 测试,并且在 Windows 上的菜单项遇到问题。Fwiw,我让它在 Mac 上为姐妹应用程序工作。我正在使用 Python 中的 Appium。
我可以使用 Inspect.exe 找到菜单树,单击顶级菜单,然后打开下拉菜单,在这里我找到菜单项,我想单击,但 WinAppDriver 失败并出现以下错误:
{"status":105,"value":{"error":"element not interactable","message":"An element command could not be completed because the element is not pointer- or keyboard interactable."}}
下面的python重现了这个问题。
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()
关于如何单击菜单项的任何建议?