We will need to see your exact code but one major thing to note is that a lot of people forget to literally return the variable, for instance they run this (C#):
driver.ExecuteScript("someVariable;");
Which, in real JavaScript and using the various Console's in each browser would actually work and print out the variable and it's contents, but in WebDriver, you'll have to explicitly return it, tell it I want the value back!
driver.ExecuteScript("return someVariable;");