Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added modal dialog using same convention. #5

Merged
merged 1 commit into from Apr 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -245,6 +245,7 @@ public static class QuickCreate

public static class ModalDialog
{
public static string TextFieldContainer = "ModalDialog_TextFieldContainer";
public static string SaveButton = "ModalDialog_SaveButton";
public static string SaveAndCloseButton = "ModalDialog_SaveAndCloseButton";
public static string CancelButton = "ModalDialog_CancelButton";
Expand Down Expand Up @@ -498,6 +499,7 @@ public static class AppElements
{ "QuickCreate_CancelButton", "//button[contains(@id,'quickCreateCancelBtn')]"},

//ModalDialog
{ "ModalDialog_TextFieldContainer", "//section[contains(@id,'DialogContainer')]//*[contains(@id, \'[NAME]-FieldSectionItemContainer\')]" },
{ "ModalDialog_SaveButton" , "//section[contains(@id,'DialogContainer')]//button[contains(@data-id, 'Save')]" },
{ "ModalDialog_SaveAndCloseButton", "//section[contains(@id,'DialogContainer')]//button[contains(@data-id, 'SaveAndClose')]"},
{ "ModalDialog_CancelButton", "//section[contains(@id,'DialogContainer')]//button[contains(@id,'CloseIconButton')]"},
Expand Down
Expand Up @@ -128,7 +128,7 @@ public MultiValueOptionSet GetValue(MultiValueOptionSet field)
/// <param name="value">Value of the field</param>
public void SetValue(string field, string value)
{
_client.SetValueWithXPathPrefix(field, value, xPathPrefix);
_client.SetDialogValue(field, value);
}

/// <summary>
Expand Down
66 changes: 50 additions & 16 deletions Microsoft.Dynamics365.UIAutomation.Api.UCI/WebClient.cs
Expand Up @@ -1875,21 +1875,67 @@ public BrowserCommandResult<bool> CloseRecordSetNavigator(int thinkTime = Consta
});
}

///// <summary>
///// Set Value
///// </summary>
///// <param name="field">The field</param>
///// <param name="value">The value</param>
///// <example>xrmApp.Entity.SetValue("firstname", "Test");</example>
//internal BrowserCommandResult<bool> SetDialogValue(string field, string value)
//{
// return Execute(GetOptions("Set Value"), driver =>
// {

// var xpath = AppElements.Xpath[AppReference.Entity.TextFieldContainer].Replace("[NAME]", field);
// xpath = "//section[contains(@id,'DialogContainer')]" + xpath;

// var fieldContainer = driver.WaitUntilAvailable(By.XPath(xpath));

// IWebElement input;
// bool found = fieldContainer.TryFindElement(By.TagName("input"), out input);

// if (!found)
// found = fieldContainer.TryFindElement(By.TagName("textarea"), out input);

// if (!found)
// throw new NoSuchElementException($"Field with name {field} does not exist.");

// SetInputValue(driver, input, value);

// // Needed to transfer focus out of special fields (email or phone)
// var label = fieldContainer.ClickIfVisible(By.TagName("label"));
// if (label == null)
// driver.ClearFocus();

// return true;
// });
//}

/// <summary>
/// Set Value
/// </summary>
/// <param name="field">The field</param>
/// <param name="value">The value</param>
/// <example>xrmApp.Entity.SetValue("firstname", "Test");</example>
internal BrowserCommandResult<bool> SetValue(string field, string value)
{
return SetValueWithXPathPrefix(field, value, string.Empty);
}

/// <summary>
/// Set Value
/// </summary>
/// <param name="field">The field</param>
/// <param name="value">The value</param>
/// <param name="xPathPrefix">XPath prefix to locate the element (e.g. QuickCreate section or Modal Dialog Section(</param>
/// <example>xrmApp.Entity.SetValueWithXPathPrefix("firstname", "Test", "//section[contains(@id,'DialogContainer')]");</example>
internal BrowserCommandResult<bool> SetDialogValue(string field, string value)
{
return Execute(GetOptions("Set Value"), driver =>
{
var XPath = AppElements.Xpath[AppReference.ModalDialog.TextFieldContainer].Replace("[NAME]", field);

var xpath = AppElements.Xpath[AppReference.Entity.TextFieldContainer].Replace("[NAME]", field);
xpath = "//section[contains(@id,'DialogContainer')]" + xpath;

var fieldContainer = driver.WaitUntilAvailable(By.XPath(xpath));
var fieldContainer = driver.WaitUntilAvailable(By.XPath(XPath));

IWebElement input;
bool found = fieldContainer.TryFindElement(By.TagName("input"), out input);
Expand All @@ -1910,18 +1956,6 @@ internal BrowserCommandResult<bool> SetDialogValue(string field, string value)
return true;
});
}

/// <summary>
/// Set Value
/// </summary>
/// <param name="field">The field</param>
/// <param name="value">The value</param>
/// <example>xrmApp.Entity.SetValue("firstname", "Test");</example>
internal BrowserCommandResult<bool> SetValue(string field, string value)
{
return SetValueWithXPathPrefix(field, value, string.Empty);
}

/// <summary>
/// Set Value
/// </summary>
Expand Down