1

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

code4jhon
  • 5,725
  • 9
  • 40
  • 60

1 Answers1

2

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();
Joel Watson
  • 173
  • 4
  • Yeah I was going down that path as well (click event) ... the only problem is that this menucheckitem could be already checked and with a click I could be checking it or unchecking it. I can probably add some of the classes to the selector in addition to the text but this would be fragil when we do a Ext framework upgrade. – code4jhon Jun 14 '17 at 21:13
  • 1
    Well, another possible option would be to create your own component future. We don't really have much in terms of documentation for creating your own, and it's not safe from conflicts with future implementations, but it should work. This is pretty untested, but a simple case seems to work: https://gist.github.com/joelwatson/2e5664ac6695de3e6259d3a26dac7a46 – Joel Watson Jun 15 '17 at 01:24
  • Oh, interesting! Will take a look at that, thanks Joel. – code4jhon Jun 15 '17 at 01:28