Microsoft dynamics CRM Selenium Automation Simplified!

Microsoft dynamics CRM Selenium Automation Simplified!

Many times we encounter to a situation where, even if we know all the selenium functions very well, still we face lot of problems while writing or executing Selenium scripts.

This blog explains few commonly encountered problems while automating web application developed in Microsoft dynamics CRM.

Why Selenium script can not find web elements, though we can see it?
Why can’t we switch to a frame even though frame is present in the DOM (Document Object Model)?
Unable to select drop down option?
Why fields filled by automation script gets ignored or does not get saved?
So, where things go wrong and why it happens?

With above questions, I want to highlight very important study/analysis we miss/ignores/took causally before actually starting the automation.

i.e. DOM (Document Object Model).

It’s very important to do DOM (Document Object Model) study and web page behavior study on different web browser identified for automation.

Now, let’s understand the solution of Microsoft dynamics CRM automation problems?

  • Multiple iframes tags with same content.
  • Inconsistent element behavior (Dynamic elements).
  • Auto save.
  • Using appropriate wait.


iframe:
On Microsoft dynamics CRM application, content loads in different frame each time. But if we open web page source we can see both iframes with all the web elements.

Inaccurate way of identifying iframe or using static iframe identification leads to a failing of script.

But appropriate study of DOM will show us that there is attribute in DOM which will tell us where exactly contents are loaded at particular time.

Highlighting element using developer mode (F12) of the browser might not help. But as shown in below example “currentContent ” attribute shows us in which iframe page has loaded.

We simply need to add dynamic method which will identify and switchToFrame to correct iframe.

Example:

iframe selenium

Dynamic fields:
Almost all fields are dynamic in Microsoft dynamics. Mostly fields are displayed as Inactive (Refer below diagram) element.

Its very easy to change state of an element from Inactive to active and vise versa, if we know previous state. But there are situations where element shows inconsistent behavior. Sometimes it displayed as inactive and sometimes as active.

It’s very difficult to interact with the element, if state of an element is not consistent.

Which DOM parameters can help us here?

We can see in below example “display” attribute will tell us state of an element. That will help us in identifying state of an element.
<div id=”#11_i” display=”Yes”>
<input id=”#11_a” display=”no”>

dynamic element

Auto Save:

In Selenium automation this functionality creates lot of problems while interacting with web elements. You must have observed that Selenium script enters value in field, still it does not get saved. Or inactive element turns into active automatically.

What could be the reason behind it?
We need to understand auto save functionality for that. In Microsoft Dynamics, Auto Save triggers every 30 seconds after editing any field (For more information on Auto save refer Microsoft site). If auto save get triggered, when selenium script starts entering value in particular field, that value will get ignored by the auto save functionality.

When page does auto saving, mandatory field check get happens, which causes mandatory field to turn into active from inactive.

How to handle this behavior in Selenium Automaton?

One way I found useful is to check all the fields on the page before doing last Save on the page (i.e. before moving towards next page).

Missing field can be identified from error message displayed next to Save button, as error messages are very descriptive and has consistent format.

Handling Waits:

Proper implementation of wait is also important while automating Microsoft dynamics CRM application.

Microsoft dynamics DOM gives us very good information about status of an element. It is very important to analyse element attributes to implement wait.

Explicit wait solves almost all wait problems. Below are the few important methods help us handling waits in selenium automation.

Here, key of success is to identify correct attribute or element from DOM and apply correct wait method.

ExplicitWait

Above discussed problems are not limited to Microsoft dynamics CRM selenium automation.

I hope you have like this blog, you could have encountered with the problems which are not discussed above.

Comment your problems in comment section I am happy to help you.

-Testingbits.com


1 thought on “Microsoft dynamics CRM Selenium Automation Simplified!”

Leave a Reply