Tuesday, March 31, 2020

RSAT and Selenium in action - Dynamics 365 for Finance & Operations Regression Test


Hi guys,

As you know, in order to handle the Regression Test in F&O we can use RSAT.

Here a couple of links:


One of the RSAT limit is the integration part, so you cannot use Task Recorder in order to recorder steps outside F&O.

The trick here is to use RSAT in combination with Selenium, https://www.selenium.dev/

Below the steps:

Generate the Recording of the Web application integrated to F&O through Selenium:















Create the Recording:








Export\Convert the Recording in a C# unit test file:














































The CS file will be looks like this:

// Generated by Selenium IDE
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Interactions;
using NUnit.Framework;

[TestFixture]
public class TEstTest {
  private IWebDriver driver;
  public IDictionary vars {get; private set;}
  private IJavaScriptExecutor js;
  [SetUp]
  public void SetUp() {
    driver = new ChromeDriver();
    js = (IJavaScriptExecutor)driver;
    vars = new Dictionary();
  }
  [TearDown]
  protected void TearDown() {
    driver.Quit();
  }
  [Test]
  public void Test() {
    // Test name: Test
    // Step # | name | target | value
    // 1 | open | /portale/web/guest | 
    driver.Navigate().GoToUrl("https://www.xxxxxxx.it");
    // 2 | setWindowSize | 1294x734 | 
    driver.Manage().Window.Size = new System.Drawing.Size(1294, 734);
    // 3 | click 
    driver.FindElement(By.LinkText("XXXXX")).Click();
    // 4 | click | css=p:nth-child(3) > a | 
    driver.FindElement(By.CssSelector("p:nth-child(3) > a")).Click();
    // 5 | close |  | 
    driver.Close();
  }
}

That said, will be enough to create an .NET C# class library with the above code.

Lastly, from X++, create a custom Menu in order to run from F&O the Selenium recording.
In order to achieve that, it's simple to create a custom project that reference the C# Library create before and call the "Selenium code".

Finally, with Task Recorder, walk through the custom menĂ¹ in order to simulate the External Application like Customer Engagement, Transportation Management System, PLM, etc.

Conclusion

In this way we will have an unique Console in order to handle our Regression Tests between Microsoft Dynamics 365 F&O and other external applications and so avoid to use different products or manual interactions.

Till soon!