Using WebDriver Actions class to interact with TeamMentor contextual menu

I was trying to add a test to verify that TeamMentor contextual menu, was displayed using mouse right-click, so you should be able to see a menu like this one :

Image

Fortunately, WebDriver provide a class to interact with some user actions like double-click for instance. This class is named ActionsTo give you an idea on what methods this class provides, I’ve auto generate the following class diagram, which gives the big picture of the Actions class definition ( and all the user actions it’s able to handle).

Image

Therefore if we need to perform the right-click action, you will need to use the following syntax:

 //Defining Actions
   var action = new Actions(driver);
   action.ContextClick(jsTree).Build().Perform();

Now we are able to display (via browser automation) this context menu, therefore our purpose here is to verify that two options are displayed when the context menu was displayed. Using jQuery selectors, we can now access the context menu and perform some asserts on that:

Code

If you want to see the unit test for that, you can see Contextual_Menu_Is_Displayed_On_Right_Click

Code

About Michael Hidalgo

Michael is a Software Developer Engineer based on San José, Costa Rica. He leads the OWASP Chapter from Costa Rica. You can take a look at my blog at http://blog.michaelhidalgo.info/
This entry was posted in JQuery, UnitTests, WebDriver and tagged , . Bookmark the permalink.

Leave a comment