Friday, 17 February 2017

Selecting Context Menu Item with Robot Framework

Automating flow after right-click i.e. selecting item from context menu may cause problems as Selenium cannot access the context menu elements. I found myself googling around this one and trying out some alternatives until satisfied to go on with a solution based on AutoIt Library. I decided to share the solution as someone may find it usable too.

I wrote about using Robot Framework's AutoIt Library in my earlier article. Problem with the context menu is that there's no way to get locators of the menu items for straightforward automation. As there are no direct shortcuts available either, suggested method is to simulate arrow down key presses and then enter key press to select the desired menu item, the 7th item "Save Image As..." in this example.




Locating native Windows elements such as "Button2" in the example must be done with caution as they depend on the Windows environment in question and must be appropriately mapped against those in a proper implementation.