How to check a checkmenuitem in Sencha Test

410 Views Asked by At

Using Sencha Test 2.1

So I'm trying to check a checkboxmenuitem which is an item in a button menu.

I can reference it but the method check is not availble for it:

component.gotoButton('[text=See]').gotoCheckBox('menucheckitem[text=All]').check();

-calling check on a ST.future.CheckBox does work but this is a checkboxmenuitem

1

There are 1 best solutions below

3
On BEST ANSWER

For a menucheckitem, the checkbox isn't an instance of Ext.form.field.CheckBox, so you'd want to retrieve the ST.Element future from the menuitem future, and then perform a click() on it.

For example, using this url: http://examples.sencha.com/extjs/6.5.0/examples/kitchensink/?classic#toolbar-menus

ST.button('button[text="Button w/ Menu"]') // button future
  .expand() // expand to reveal menu
  .gotoComponent('menuitem[text="I like Ext"]') // menuitem future
  .down('>> .x-menu-item-checkbox') // use down() to get Element future
  .click(); // execute click on Element future

If you want to be less verbose, you could also do something like this directly from the Button future:

ST.button('button[text="Button w/ Menu"]')
  .expand()
  .down('menu => .x-menu-item-checkbox') // use composite query to locate element
  .click();