Encountered a situation where Firefox was not entering text in a required textbox within a popup. Upon clicking the button, a warning flag appears indicating that the field is mandatory. After inspecting the HTML code, it was revealed that there was no value present in the textbox and the title
attribute indicated that the field is required.
Attempts were made to use JavaScript to input text into the textbox, however, this approach did not yield any success.
Snippet of the code used:
public static void UserName(string text)
{
try
{
IJavaScriptExecutor js = (IJavaScriptExecutor)Drivers._driverInstance;
IWebElement element = Drivers._driverInstance.FindElement(By.Id("newName"));
//js.ExecuteScript("document.getElementById('newName').setAttribute('value', '" + text + "')");
js.ExecuteScript("arguments[0].click();", element);
js.ExecuteScript("document.getElementById('newName').value='" + text + "';");
//Drivers._driverInstance.FindElement(By.Name("newName")).Clear();
//Drivers._driverInstance.FindElement(By.Name("newName")).SendKeys(text);
}
catch(Exception e)
{
throw new Exception("Couldn't send text to username textbox " + e);
}
}
HTML snippet for the textbox:
<div class="field-container">
<label>Username</label>
<input id="newName" class="input-validation-error" name="newName" data-bind="value: Name" title="This field is required." data-orig-title="This field is required." type="text"/>
<span class="validationMessage" style="">This field is required.</span>
https://i.sstatic.net/uD9t5.png
Seeking assistance on how to resolve this issue.
Software versions in use: Firefox-50.0 Selenium-3.0.0
Thank you.