I am writing Selenium开发者_开发技巧 test scripts in C#.Net and I keep bumping into this exception -
ERROR: Threw an exception: return not in function
Here is my line of code which throws the error -
string code = selenium.GetEval(
"var win = this.browserbot.getUserWindow(); "+
"return win.editAreaLoader.GetValue(win.loadedCodeEditorID);"
);
Can anyone please suggest why the exception is coming and what could be the best way to get a return value from GetValue javascript function?
Thanks,
Saarthak
From the selenium documentation for GetEval
:
Gets the result of evaluating the specified JavaScript snippet. The snippet may have multiple lines, but only the result of the last line will be returned.
Therefore you simply need to leave off the return
:
string code = selenium.GetEval(
"var win = this.browserbot.getUserWindow(); "+
"win.editAreaLoader.GetValue(win.loadedCodeEditorID);"
);
精彩评论