I\'ve been on a prowl looking for a way to access a non visible text field using selenium\'s webdriver. The only way i got it to work is using
driver.execut
If I am understanding the problem correctly you are trying to pass a var instead of hard coded XYZ
var
XYZ
driver.execute_script("document.getElementById('text_field').value+='" + var + "'");