Introduction
EasyRepro provides the ability to do automate testing in Dynamics 365 CRM. It gives the power to interact with Dynamics 365 CRM UI and perform automated testing. However, in case of Business Process Flow (BPF) it only supports until the dialog box of BPF stage is accessible as shown below:
But what if you want to go to the Next Stage or Previous Stage or else Finish the BPF for the record?
You will get the answer for this question in this blog. Here, we will share with you a generic function to perform any BPF actions in the dialog box.
Let us take an example of Business Process Flow on Case record. Here we are on Identify stage and we want to proceed to next stage, which is Research. To make this happen we will use our generic function.
Now let us call our function. Here we have four arguments, which states that, we want to access the Identify stage and click on Next Stage button to proceed to Research stage. The other two are XrmApp and WebClient for performing EasyRepro methods.
Note:
The xrmApp and client are XrmApp and WebClient respectively which are both classes of EasyRepro.
PerformBPFaction(“Identify”, “Next Stage”, xrmApp, client);
After calling the above function the output can be seen in the below image. It has been proceeded to the Research stage.
Again, if we call our function and add the second argument as ‘Close’ (X), it will close the Pop-Up dialog box. Here, we have to close the ‘Research’ stage dialog box.
PerformBPFaction(“Research”, “Close”, xrmApp, client);
By calling the above function, we can see that the dialog box, which was previously open, is closed.
Similarly, we can achieve different actions like ‘Set Active’, ‘Finish’, ‘Back (<)’ as well as ‘Pin the stage flyout’ with the help of this generic function.
Now, let us understand the generic function.
The first two lines mentioned below will make sure that you are on your main window where the Business Process Flow is present.
var xrmBrowser = client.Browser;
var win = xrmBrowser.Driver.SwitchTo().Window(xrmBrowser.Driver.CurrentWindowHandle);
In the next line, it will select the stage and open the dialog box. Here ‘selectStage’ will be the stage name that you want to access.
xrmApp.BusinessProcessFlow.SelectStage(selectStage);
By using XPath, we find the button to click. As per our example, we want to click the Next Stage button so bpfButtonName will be Next Stage. After finding the button we click on it with the Click() method.
win.FindElement(By.XPath(“//button[@title='”+bpfButtonName+”‘]”)).Click();
After the click method, we will proceed as per the given arguments and your action will be performed.
Generic Function:
private void PerformBPFaction(string selectStage, string bpfButtonName, XrmApp xrmApp, WebClient client)
{
var xrmBrowser = client.Browser;
var win = xrmBrowser.Driver.SwitchTo().Window(xrmBrowser.Driver.CurrentWindowHandle);
try
{
xrmApp.BusinessProcessFlow.SelectStage(selectStage);
win.FindElement(By.XPath(“//button[@title='”+bpfButtonName+”‘]”)).Click();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
Conclusion
The above generic function will help you to perform different actions on Business Process Flow in Dynamics 365 CRM using EasyRepro.