diff --git a/Microsoft.Dynamics365.UIAutomation.Api.UCI/DTO/AppElementReference.cs b/Microsoft.Dynamics365.UIAutomation.Api.UCI/DTO/AppElementReference.cs index 2f9cff67..195b9bee 100644 --- a/Microsoft.Dynamics365.UIAutomation.Api.UCI/DTO/AppElementReference.cs +++ b/Microsoft.Dynamics365.UIAutomation.Api.UCI/DTO/AppElementReference.cs @@ -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')]" }, diff --git a/Microsoft.Dynamics365.UIAutomation.Api.UCI/WebClient.cs b/Microsoft.Dynamics365.UIAutomation.Api.UCI/WebClient.cs index 4c723cbd..2a797bc2 100644 --- a/Microsoft.Dynamics365.UIAutomation.Api.UCI/WebClient.cs +++ b/Microsoft.Dynamics365.UIAutomation.Api.UCI/WebClient.cs @@ -1802,6 +1802,7 @@ internal BrowserCommandResult 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 @@ -1814,7 +1815,9 @@ internal BrowserCommandResult 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(); } @@ -2818,6 +2821,8 @@ internal BrowserCommandResult 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))); @@ -3304,6 +3309,8 @@ internal BrowserCommandResult 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)))) @@ -3311,14 +3318,14 @@ internal void ClickTab(IWebElement tabList, string xpath, string 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); }