EasyRepro Tips: one way to work with invisible elements

By | August 3, 2018


When using EasyRepro for automated testing on your Dynamics projects, you will almost inevitably run into the ElementNotVisibleException:


This exception may happen in different places, and, if you wanted to understand why, this thread at StackOverflow will provide a very good explanation:


Basically, as mentioned there, Selenium has been specifically written to NOT allow interaction with hidden elements.

Dynamics is using a lot of hidden elements to optimize the UI, so, if you try utilizing Selenium web driver as is, you’ll keep running into this kind of issues even more often. EasyRepro seems to be taking a really good care of a lot of those situations, but, every now and then, you’ll still be running into them.

The good news is that, if you look at that StackOverflow thread above, there is, also, a workaround. Instead of trying to work with the hidden element through the web driver, you can ask the web driver to execute a javascript:

IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
js.ExecuteScript(“arguments[0].click();”, element);

This won’t be a complete emulation of the user actions, but it can be good enough as long as we are getting better test coverage that way.

For example, one scenario where you may run into this problem is when you have a subarea which is not immediately visible, so you have to navigate to the second page of the corresponding area:


In which case if you try opening that subarea with a call to xrmBrowser.Navigation.OpenSubArea, you will, most likely, see an error.

So, if that happens, just apply that javascript workaround to the OpenSubArea method which is located in the Navigation.cs file:


That should take care of the problem.

Leave a Reply

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