In a MacOS X application, I create a Window containing a WebView. The WebView is initialized on a html page that contains an anchor: Go To Google.
I would like to click on that link from another class.
It seems clear that a simple javascript code would do the trick: document.getElementById("myLink").click();
So, I wrote that small objective-c code that should do it:
NSString *cmd = @"document.getElementById(\"myLink\").click();";
id result = [[attachedWebView windowScriptObject] evaluateWebScript:cmd];
if ([result isMemberOfClass:[WebUndefined class]]) {
NSLog(@"evaluation of <%@> returned WebUndefined", cmd)
But I can't make it work. If anybody has an idea, that would really help.