Selenium – ways to handle dropdown menus

Every web Page has at least one drop down menu bar, the bar may be horizontal or vertical.

Each item in the menu bar is a link corresponds to another page.

Menu bar have root items and in each root items we have one or more sub menus/items.

Actions on Root elements of a menu bar can be done as normal links, but sub elements are ( are hidden) only visible if we mouse hover to their corresponding root element,


as shown in above screenshot, to get the AntReporting item, we need to mouse hover on Selenium item.

Let’s see code implementations to the above scenario…

Some scenarios, this above Action mouse hover doesn’t work well, then we can use different approach like:

For each root or sub menu items, there is a url link associated, so instead of mouse hover directly use driver.get(“link of the root/sub menu item”);


Let’s see how this works:

To click on the Selenium -> ExcelRW item, instead of mouse hover, we can use the url link associated with the ExcelRW item i.e- http://www.qavalidation.com/2015/03/selenium-excel-read-and-write-apachePOI.html

 

Content posted is based on learning or working experience, please leave comments if anything needs to be added or updated, discuss your queries on our facebook:qavalidation.com, Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: