I'm encountering an issue when trying to assign a variable to the activeElement.value in my code. The error message that I am receiving is:
Exception in thread "main" org.openqa.selenium.WebDriverException: patientID is not defined Command duration or timeout: 66 milliseconds Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50' System info: host: 'MALTE', ip: '169.254.239.149', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_40' Driver info: org.openqa.selenium.firefox.FirefoxDriver Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=37.0.1, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}] Session ID: 9816aed6-75f7-48e2-90c5-4c018efd0af9 ...
The part of the code that's causing issues has to do with setting a variable (not working):
String patientID;
patientID = "n1n3";
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("document.activeElement.value = patientID;");
However, when directly using a string value in the code snippet, it works fine:
jse.executeScript("document.activeElement.value = 'n1n3';");
If you have any insights or suggestions on how to resolve this error, your help would be greatly appreciated! Thanks!