I am using C# and Selenium to navigate a site and was wondering how to pass variables into my JavaScriptExecutor command. If I write it like this:
((IJavaScriptExecutor)webdriver).ExecuteScript("document.getElementByID('text box1').value = 'hello'");
That works fine but when I try to pass it variables it says they are not defined:
var elementID = "text box1"
var fieldValue = "hello"
((IJavaScriptExecutor)webdriver).ExecuteScript("document.getElementByID(elementID).value = fieldValue");