Skip to content

Commit

Permalink
Updating Lookup SetValue to scope just to main page and not header. A…
Browse files Browse the repository at this point in the history
…lso fixed issue with click after search text is entered. (#658)
  • Loading branch information
dtu11 authored Oct 25, 2019
1 parent 8032d0e commit 9362303
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public static class AppElements
{ "Entity_LookupFieldResultList", "//*[contains(@data-id, '[NAME].fieldControl-LookupResultsDropdown_[NAME]_tab')]" },
{ "Entity_LookupFieldResultListItem", "//*[contains(@data-id, '[NAME].fieldControl-LookupResultsDropdown_[NAME]_resultsContainer')]" },
{ "Entity_LookupFieldHoverExistingValue", "//*[contains(@data-id, '[NAME].fieldControl-LookupResultsDropdown_[NAME]_SelectedRecordList')]" },
{ "Entity_TextFieldLookupFieldContainer", "//*[contains(@data-id, '[NAME].fieldControl-Lookup_[NAME]')]" },
{ "Entity_TextFieldLookupFieldContainer", "//div[@role='tabpanel']/parent::*//*[contains(@data-id, '[NAME].fieldControl-Lookup_[NAME]')]" },
{ "Entity_RecordSetNavigatorOpen", "//button[contains(@data-lp-id, 'recordset-navigator')]" },
{ "Entity_RecordSetNavigator", "//button[contains(@data-lp-id, 'recordset-navigator')]" },
{ "Entity_RecordSetNavList", "//ul[contains(@data-id, 'recordSetNaveList')]" },
Expand Down
13 changes: 10 additions & 3 deletions Microsoft.Dynamics365.UIAutomation.Api.UCI/WebClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1802,6 +1802,7 @@ internal BrowserCommandResult<bool> SetValue(LookupItem control, int index = 0)

var fieldContainer = driver.WaitUntilAvailable(By.XPath(AppElements.Xpath[AppReference.Entity.TextFieldLookupFieldContainer].Replace("[NAME]", control.Name)));


ClearValue(control);

var input = fieldContainer.FindElements(By.TagName("input")).Count > 0
Expand All @@ -1814,7 +1815,9 @@ internal BrowserCommandResult<bool> SetValue(LookupItem control, int index = 0)
input.SendKeys(Keys.Backspace);
input.SendKeys(control.Value, true);

driver.ClickWhenAvailable(By.XPath(AppElements.Xpath[AppReference.Entity.TextFieldLookupSearchButton].Replace("[NAME]", control.Name)));
//No longer needed, the search dialog opens when you enter the value
//driver.ClickWhenAvailable(By.XPath(AppElements.Xpath[AppReference.Entity.TextFieldLookupSearchButton].Replace("[NAME]", control.Name)));

driver.WaitForTransaction();
}

Expand Down Expand Up @@ -2818,6 +2821,8 @@ internal BrowserCommandResult<bool> ClearValue(LookupItem control, bool removeAl
{
var fieldContainer = driver.WaitUntilAvailable(By.XPath(AppElements.Xpath[AppReference.Entity.TextFieldLookupFieldContainer].Replace("[NAME]", control.Name)));

fieldContainer.Hover(driver);

var existingValues = fieldContainer.FindElements(By.XPath(AppElements.Xpath[AppReference.Entity.LookupFieldDeleteExistingValue].Replace("[NAME]", control.Name)));

var expandCollapseButtons = fieldContainer.FindElements(By.XPath(AppElements.Xpath[AppReference.Entity.LookupFieldExpandCollapseButton].Replace("[NAME]", control.Name)));
Expand Down Expand Up @@ -3304,21 +3309,23 @@ internal BrowserCommandResult<bool> SelectTab(string tabName, string subTabName

internal void ClickTab(IWebElement tabList, string xpath, string name)
{
IWebElement moreTabsButton;
IWebElement listItem;
// Look for the tab in the tab list, else in the more tabs menu
IWebElement searchScope = null;
if(tabList.HasElement(By.XPath(string.Format(xpath, name))))
{
searchScope = tabList;

}
else if(tabList.TryFindElement(By.XPath(AppElements.Xpath[AppReference.Entity.MoreTabs]), out IWebElement moreTabsButton))
else if(tabList.TryFindElement(By.XPath(AppElements.Xpath[AppReference.Entity.MoreTabs]), out moreTabsButton))
{
moreTabsButton.Click();
searchScope = Browser.Driver.FindElement(By.XPath(AppElements.Xpath[AppReference.Entity.MoreTabsMenu]));
}


if (searchScope.TryFindElement(By.XPath(string.Format(xpath, name)), out IWebElement listItem))
if (searchScope.TryFindElement(By.XPath(string.Format(xpath, name)), out listItem))
{
listItem.Click(true);
}
Expand Down

0 comments on commit 9362303

Please sign in to comment.