Handle Mega-Menu Multi-layered menu structure-Selenium Challenging Scenario

This Scenario can be mentioned as an answer to the Question : Explain a challenging scenario/task you recently faced and how did you overcome it.

I am documenting the answer below with code snippet.

Answer: I recently handled a mega-menu in my current application. The structure of the menu was complex.

Explain the scenario first:

I am currently working on E commerce application. We have Mega -Menu structure which contains list of products structured in multi layered pop ups.

After clicking on the menu, Categories list is displayed. Categories like, mobile phones, cables etc.

After hovering on any specific Category, another pop up called as sub categories is displayed. Sub categories displays list like smart phone, basic phone, with camera , no-camera etc.

This Sub category list contains list of all the vendors list like: ‘Apple’,”1+’, ‘Samsung’ ‘oppo’  etc

Explain the Challenge and solution:

All these menu pop ups are very volatile, i.e. they go away as soon as mouse pointer is moved. I used Actions to handle it. Also, each pop up has to be validated after hovering.

Other than that, categories, sub categories and vendors links had to be identified at run time by iterating the links in corresponding pop ups respectively.