Javascript call in Watin

I am trying to execute some JavaScript using a call to C # eval.

browser.Frames[1].Eval("myFunctionCall(" + Id + ", 1, " + RowNumber + ");"); 

It does not seem to be able to find the function because it is throwing a "JavaScriptException". The value of the myFunctionCall property is null or undefined, not a Function object "

Here is the background.
I found out by tracking JavaScript that this is a function called when an element of interest is clicked. So I lift the page in the browser and execute this JavaScript. When downloading, I get the above errors.
I am starting and I am not sure how to call remotely referenced JavaScript.

In conclusion, I would like to name the javascript method. Any ideas?

Thanks!

+4
source share
1 answer

I would start by saying that the JavaScript containing this function loads when used in WatiN. You can try to declare a function before calling it.

 Browser.Eval( "function myFunctionCall(Id, Num, RowNumber) {" + " var a = 0;" + " var b = 0;" + "}" + "myFunctionCall(" + Id + ", 1, " + RowNumber + ");"); 

Hope this helps!

Also, make sure the function is available from your frame. In other words, the frame has access to this function.

+1
source

Source: https://habr.com/ru/post/1414024/


All Articles