When attempting to use sendkeys on an input field, I encountered a warning that puzzled me:
org.openqa.selenium.InvalidElementStateException: Element must not be hidden, disabled or read-only (WARNING: The server did not provide any stacktrace information)
Here is the snippet of HTML code from the page source:
<span id="mini-7" class="mini-textbox mini-textbox-empty" style="border-width: 0pt; width: 342px;">
<input class="mini-textbox-input" type="text" autocomplete="off" style="width: 338px;">
<input type="hidden">
</span>
Initially, my code looked like this:
driver.findElement(By.cssSelector("#mini-7 > input.mini-textbox-input")).clear();
driver.findElement(By.cssSelector("#mini-7 > input.mini-textbox-input")).sendKeys("yy");
Subsequently, I made adjustments to my code as follows:
JavascriptExecutor jse = (JavascriptExecutor)driver;
((JavascriptExecutor) jse).executeScript("arguments[0].type ='text';",driver.findElement(By.xpath("//span[@id='mini-7']/input[2]")));
However, this modification resulted in a JavaScript error. What could be the reason behind this?
I made sure to target the first input element with sendkeys, which I believe is not hidden.