2011-04-14 4 views
3

"함수에없는 반환"나는이 예외 부딪히는 계속 - 여기셀레늄 예외 : 나는 C# 닷넷에서 셀레늄 테스트 스크립트를 작성하고

ERROR: Threw an exception: return not in function 

는 오류가 발생 코드 내 라인 -

string code = selenium.GetEval(
    "var win = this.browserbot.getUserWindow(); "+ 
    "return win.editAreaLoader.GetValue(win.loadedCodeEditorID);" 
); 

예외가 발생하는 이유와 GetValue javascript 함수에서 반환 값을 얻는 가장 좋은 방법은 무엇입니까?

감사합니다,

Saarthak에서

답변

2

selenium documentationGetEval의 : 당신은 단순히 생략 할 필요가 따라서

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.

return :

string code = selenium.GetEval(
    "var win = this.browserbot.getUserWindow(); "+ 
    "win.editAreaLoader.GetValue(win.loadedCodeEditorID);" 
); 
+0

이 오류를 얻었다 - 오류 : 예외 발생 : win.editAreaLoader.GetValue가 function – saarthak

+0

@saarthak -'editAreaLoader'는 무엇입니까? –

+0

오픈 소스 API. GetEval 어떤 값을 반환하지 않을 때 잘 작동합니다. – saarthak