I am writing test automation for a web app whose navigation is behind a 'hamburger menu'. That is, an icon must be clicked to display the navigation options.
I am considering two different designs:
1) The code to click a menu item only clicks the menu item. In this case, a test requiring navigation would look something like:
hamburgerMenu.click() // opens menu menuItem.click() // clicks item
2) The code to click a menu item contains the call to open the menu. In this case, a test requiring navigation would look like:
menuItem.click() // internally calls hamburgerMenu.click()
The code for the second option would be slightly more compact, since the 'click on hamburgerMenu' call would only exist once, in the definition of menuItem.click(), rather than needing to be repeated each time a menu item needs to be clicked.
On the other hand, someone unfamiliar with this code might find it less intuitive, and expect it to not work, since they won't see the call to open the menu, and think the test code is trying to click on items that are not visible yet.
The question is:
1) Are there other considerations that make one or the other of these designs better, which I might not have thought of?
2) Is one of these generally considered to be much better than the other, or does it not really matter?