diff --git a/Microsoft.Dynamics365.UIAutomation.Api.UCI/WebClient.cs b/Microsoft.Dynamics365.UIAutomation.Api.UCI/WebClient.cs index cd3313d9..0870da67 100644 --- a/Microsoft.Dynamics365.UIAutomation.Api.UCI/WebClient.cs +++ b/Microsoft.Dynamics365.UIAutomation.Api.UCI/WebClient.cs @@ -2336,25 +2336,23 @@ internal BrowserCommandResult SetValue(string field, string value, FormCon private void SetInputValue(IWebDriver driver, IWebElement input, string value, TimeSpan? thinktime = null) { - driver.WaitForTransaction(); - input.SendKeys(Keys.Control + "a"); - input.SendKeys(Keys.Control + "a"); - input.SendKeys(Keys.Backspace); - driver.WaitForTransaction(); - - if (string.IsNullOrWhiteSpace(value)) - { - input.Click(true); - return; - } - - if (string.IsNullOrEmpty(value)) + // Repeat set value if expected value is not set + // Do this to ensure that the static placeholder '---' is removed + driver.RepeatUntil(() => { - input.Click(true); - return; - } + input.Clear(); + input.Click(); + input.SendKeys(Keys.Control + "a"); + input.SendKeys(Keys.Control + "a"); + input.SendKeys(Keys.Backspace); + input.SendKeys(value); + driver.WaitForTransaction(); + }, + d => input.GetAttribute("value").IsValueEqualsTo(value), + TimeSpan.FromSeconds(9), 3, + failureCallback: () => throw new InvalidOperationException($"Timeout after 10 seconds. Expected: {value}. Actual: {input.GetAttribute("value")}") + ); - input.SendKeys(value, true); driver.WaitForTransaction(); }