I am struggling to use JavaScript to locate specific controls and send values to them. One example is changing the text in a textbox with the ID "ID" to "123456".
Below is the code I tried:
((IJavaScriptExecutor)driver).ExecuteScript("document.getElementById('ID').value='TextValue'");
However, I encountered an error - InvalidOperationException
. Prior to this, I successfully used JavaScript to return the page title.
string title = (string)((IJavaScriptExecutor)driver).ExecuteScript("return document.title");
I am unsure of what the problem might be and could use some assistance.