Skip to content

Commit

Permalink
GitHub issues #394 & #7 Fixes issues with UCI fields not clearing or …
Browse files Browse the repository at this point in the history
…not removing previous value when updating (#481)
  • Loading branch information
jlattimer authored and TYLEROL committed May 22, 2019
1 parent c68d55a commit 8216dbc
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions Microsoft.Dynamics365.UIAutomation.Api.UCI/WebClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1541,20 +1541,38 @@ internal BrowserCommandResult<bool> SetValue(string field, string value)
if (input != null)
{
input.Click();
input.SendKeys(value, true);
if (string.IsNullOrEmpty(value))
{
input.SendKeys(Keys.Control + "a");
input.SendKeys(Keys.Backspace);
}
else
{
input.SendKeys(value, true);
}
}
}
else if (fieldContainer.FindElements(By.TagName("textarea")).Count > 0)
{
fieldContainer.FindElement(By.TagName("textarea")).Click();
fieldContainer.FindElement(By.TagName("textarea")).Clear();
fieldContainer.FindElement(By.TagName("textarea")).SendKeys(value);
if (string.IsNullOrEmpty(value))
{
fieldContainer.FindElement(By.TagName("textarea")).SendKeys(Keys.Control + "a");
fieldContainer.FindElement(By.TagName("textarea")).SendKeys(Keys.Backspace);
}
else
{
fieldContainer.FindElement(By.TagName("textarea")).SendKeys(value, true);
}
}
else
{
throw new Exception($"Field with name {field} does not exist.");
}
// Needed to transfer focus out of special fields (email or phone)
driver.FindElement(By.TagName("body")).Click();
return true;
});
}
Expand Down

0 comments on commit 8216dbc

Please sign in to comment.