in Microsoft.Dynamics365.UIAutomation.Api.UCI/WebClient.cs [2765:2840]
private void TrySetDateValue(IWebDriver driver, ISearchContext container, DateTimeControl control, FormContextType formContextType)
{
string controlName = control.Name;
IWebElement fieldContainer = null;
var xpathToInput = By.XPath(AppElements.Xpath[AppReference.Entity.FieldControlDateTimeInputUCI].Replace("[FIELD]", controlName));
if (formContextType == FormContextType.QuickCreate)
{
// Initialize the quick create form context
// If this is not done -- element input will go to the main form due to new flyout design
var formContext = container.WaitUntilAvailable(By.XPath(AppElements.Xpath[AppReference.QuickCreate.QuickCreateFormContext]));
fieldContainer = formContext.WaitUntilAvailable(xpathToInput, $"DateTime Field: '{controlName}' does not exist");
var strExpanded = fieldContainer.GetAttribute("aria-expanded");
if (strExpanded == null)
{
fieldContainer = formContext.FindElement(By.XPath(AppElements.Xpath[AppReference.Entity.TextFieldContainer].Replace("[NAME]", controlName)));
}
}
else if (formContextType == FormContextType.Entity)
{
// Initialize the entity form context
var formContext = container.WaitUntilAvailable(By.XPath(AppElements.Xpath[AppReference.Entity.FormContext]));
fieldContainer = formContext.WaitUntilAvailable(xpathToInput, $"DateTime Field: '{controlName}' does not exist");
var strExpanded = fieldContainer.GetAttribute("aria-expanded");
if (strExpanded == null)
{
fieldContainer = formContext.FindElement(By.XPath(AppElements.Xpath[AppReference.Entity.TextFieldContainer].Replace("[NAME]", controlName)));
}
}
else if (formContextType == FormContextType.BusinessProcessFlow)
{
// Initialize the Business Process Flow context
var formContext = driver.WaitUntilAvailable(By.XPath(AppElements.Xpath[AppReference.BusinessProcessFlow.BusinessProcessFlowFormContext]));
fieldContainer = formContext.WaitUntilAvailable(xpathToInput, $"DateTime Field: '{controlName}' does not exist");
var strExpanded = fieldContainer.GetAttribute("aria-expanded");
if (strExpanded == null)
{
fieldContainer = formContext.FindElement(By.XPath(AppElements.Xpath[AppReference.Entity.TextFieldContainer].Replace("[NAME]", controlName)));
}
}
else if (formContextType == FormContextType.Header)
{
// Initialize the Header context
var formContext = driver.WaitUntilAvailable(By.XPath(AppElements.Xpath[AppReference.Entity.HeaderContext]));
fieldContainer = formContext.WaitUntilAvailable(xpathToInput, $"DateTime Field: '{controlName}' does not exist");
var strExpanded = fieldContainer.GetAttribute("aria-expanded");
if (strExpanded == null)
{
fieldContainer = formContext.FindElement(By.XPath(AppElements.Xpath[AppReference.Entity.TextFieldContainer].Replace("[NAME]", controlName)));
}
}
else if (formContextType == FormContextType.Dialog)
{
// Initialize the Dialog context
var formContext = driver.WaitUntilAvailable(By.XPath(AppElements.Xpath[AppReference.Dialogs.DialogContext]));
fieldContainer = formContext.WaitUntilAvailable(xpathToInput, $"DateTime Field: '{controlName}' does not exist");
var strExpanded = fieldContainer.GetAttribute("aria-expanded");
if (strExpanded == null)
{
fieldContainer = formContext.FindElement(By.XPath(AppElements.Xpath[AppReference.Entity.TextFieldContainer].Replace("[NAME]", controlName)));
}
}
TrySetDateValue(driver, fieldContainer, control.DateAsString, formContextType);
}