I want to use javascript to locate the controls and send value to it.
For example I want to change the text in the textbox(id=”ID”) into “123456”.
Here comes my code:
((IJavaScriptExecutor)driver).ExecuteScript("document.getElementById('ID').value='TextValue'");
but something get error. it show invalidoperateException.
Before this I try to use javascript to return the title and it works.
string title = (string)((IJavaScriptExecutor)driver).ExecuteScript("return document.title");
I cannot figure out what the problem is.
Here’s how I do it: