1
I am developing an application that performs automation in internet explorer, I am using the Shdocvw to do this.
My problem is I can’t get the return of an injection of Javascript
public static void wJScript(string script) {
try {
Thread th = new Thread(ExecuteJavaScriptWorker);
th.SetApartmentState(ApartmentState.STA);
th.Start(script);
}
catch (Exception) {
throw;
}
}
private static void ExecuteJavaScriptWorker(object script) {
try {
IHTMLDocument2 document = IE.Document;
object resp = document.parentWindow.execScript(script.ToString(), "JScript");
Console.Write(resp);
}
catch (Exception) {
throw;
}
}
My variable Resp always returns null
The variable script can receive any Javascript command from a single document.getElementById('id').value even call a function I have on the page:
Let’s say I have following function on my page:
function soma(a,b) {
return a + b;
}
And pass as parameter to my function wJScript("soma(1,2)") it should return me the result of the function, but this does not occur!
You can order what the variable
scriptcontains?– danguilherme
@Danguilherme I edited the question... But clarifying, it can contain any Javascript command.
– lrpinheiro