From the Microsoft Dynamics 365/CRM Blogs: Easy Repro; Connections; DocumentsCorePack; Product hierarchies

June 29 2018

This week on the Dynamics 365-CRM blog roundup:

About MSDW Reporter

More about MSDW Reporter

Comments

shahrukh2077's picture

Easyrepro- When run a test case, once done successfully but the another time it throws different exceptions

Whenever I run the code it works fine only first time. However, if I run again the same code without any customization it throws different exceptions every time.

Exceptions are :
-[ ]OpenQA.Selenium.ElementNotInteractableException: 'Element
could not be scrolled into view'
-[ ]System.InvalidOperationException: 'Composite Control: fullname Does not exist'
Here is the code.

using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Dynamics365.UIAutomation.Api;
using Microsoft.Dynamics365.UIAutomation.Browser;
using System;
using System.Security;
using System.Collections.Generic;

namespace Microsoft.Dynamics365.UIAutomation.Sample.Web
{
[TestClass]
public class CreatePatient
{

private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString();
private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString();
private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString());

[TestMethod]
public void WEBTestCreateNewOpportunity()
{
using (var xrmBrowser = new Api.Browser(TestSettings.Options))
{
xrmBrowser.LoginPage.Login(_xrmUri, _username, _password);
xrmBrowser.GuidedHelp.CloseGuidedHelp();

xrmBrowser.ThinkTime(500);
xrmBrowser.Navigation.OpenSubArea("Service", "Contacts");

xrmBrowser.ThinkTime(200);
xrmBrowser.Grid.SwitchView("Patients");

xrmBrowser.ThinkTime(2000);
xrmBrowser.CommandBar.ClickCommand("New");

xrmBrowser.ThinkTime(6000);
//xrmBrowser.Entity.SetValue("mzk_gender", "Male");
xrmBrowser.ThinkTime(3000);
var fields = new List<Field>
{
new Field() {Id = "firstname", Value = "Shahrukh"},
new Field() {Id = "lastname", Value = "Easyrepro"}
};
xrmBrowser.Entity.SetValue(new CompositeControl() { Id = "fullname", Fields = fields });

//xrmBrowser.Entity.SetValue("description", "Testing the create api for Opportunity");

xrmBrowser.CommandBar.ClickCommand("SAVE");
xrmBrowser.ThinkTime(2000);
}
}
}
}