I'm using a Page Object model. And on my website most page have a menu, so I was thinking I should create a class MenuPage that every other page that have a menu would extends it.
But now I would like to regroups all my WebElement from the menu to kinda separate them from the one of the current page.
In other word, if an element is directly on the page, I would access it something like that.
MyPage mypage = new MyPage(); /*MyPage extends MenuPage*/
mypage.myWebElement.click();
But if the webelement is part of the menu, and not part of MyPage, I would like to access it from
MyPage mypage = new MyPage(); /*MyPage extends MenuPage*/
mypage.menu.myWebElement.click();
I know I could create a class menu and instance it into MenuPage, but since it will only be used there, I would prefer not to have it separated from the class MenuPage. And also, the menu also have submenu, and so I would like to represent it with multi-level fields. And having a new class for each submenu could make a lots of class for so little.
What would be the best way to do so, or do you know a other way to approch the problem?