0

So I've inherited a bit of code for squish and really have no guidance towards the program at all besides what I can scrounge up online, so this might be a simple problem...

I have a function, delete_fixture, which is shown here and refers to the activateMenuItem function, shown afterward... What happens is the edit menu gets clicked, but it doesn't seem to click anything else and no popup about deletion comes up, which is what the test is for. I was just wondering if anyone could see any glaring error in this or if I could get some guidance

def delete_fixture(name, confirm=True):
   click_data_tab("Fixtures")
   click_fixture(name)
   activateMenuItem("Edit", "Delete")
   if confirm:
       mouseClick(waitForObject("{text='OK' type='QPushButton' visible='1'}"))
   else:
       mouseClick(waitForObject("{text='Cancel' type='QPushButton' visible='1'}"))


def activateMenuItem(*menuPath):
   snooze(1)
   menu = "{type='QMenuBar' visible='true'}"
   parent = "{name='MainWindow' type='MainWindow'}"
   try:
       waitForObject(parent)
       for item in menuPath[:-1]:
           activateItem(waitForObjectItem(menu, item))
           menu = "{title='%s' type='QMenu' visible='1' window=%s}" % (item, parent)
           parent = menu
       activateItem(waitForObjectItem(menu, menuPath[-1]))
   except LookupError as e:
       test.log("Unable to find main window: %s" % HOST_NAME)
       raise LookupError("%s -- %s" % (HOST_NAME,e))
bad_coder
  • 11,289
  • 20
  • 44
  • 72
seanscal
  • 568
  • 2
  • 9
  • 33

2 Answers2

1

Try using the first argument of *menu_path as an object (like :menu_bar ) and then the rest of the args as strings. That worked for me.

Einar Sundgren
  • 4,325
  • 9
  • 40
  • 59
0

The activateMenuItem appears to expect that menuPath is a list, but it unpacks the arguments.

Try changing

def activateMenuItem(*menuPath):

to

def activateMenuItem(menuPath):
Community
  • 1
  • 1
Frerich Raabe
  • 90,689
  • 19
  • 115
  • 207